/* ============================================================
   MERCHANT PANEL - MODERN TOPBAR STYLES
   Clean, responsive header with proper dropdown positioning
   ============================================================ */

:root {
  --mt-height: 64px;
  --mt-bg: #ffffff;
  --mt-text: #1f2937;
  --mt-text-muted: #6b7280;
  --mt-accent: #3b82f6;
  --mt-accent-light: #2563eb;
  --mt-hover-bg: #f3f4f6;
  --mt-active-bg: rgba(59, 130, 246, 0.08);
  --mt-border: #e5e7eb;
  --mt-dropdown-bg: #ffffff;
  --mt-dropdown-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --mt-dropdown-radius: 12px;
  --mt-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Main Topbar ===== */
.merchant-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mt-height);
  background: var(--mt-bg);
  z-index: 1040;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.merchant-topbar-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  gap: 16px;
}

/* ===== Brand / Logo ===== */
.merchant-topbar-brand {
  flex-shrink: 0;
}

.merchant-topbar-brand a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.merchant-topbar-logo {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  filter: none;
}

/* ===== Center Navigation ===== */
.merchant-topbar-nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.merchant-nav-list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.merchant-nav-item {
  position: relative;
}

.merchant-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: var(--mt-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: all var(--mt-transition);
  white-space: nowrap;
}

.merchant-nav-link:hover {
  color: var(--mt-text);
  background: var(--mt-hover-bg);
  text-decoration: none;
}

.merchant-nav-link.active {
  color: var(--mt-text);
  background: var(--mt-active-bg);
}

.merchant-nav-link i:first-child {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.merchant-nav-arrow {
  font-size: 9px !important;
  margin-left: 2px;
  transition: transform var(--mt-transition);
}

.merchant-nav-dropdown:hover .merchant-nav-arrow,
.merchant-nav-dropdown .merchant-nav-link[aria-expanded="true"] .merchant-nav-arrow {
  transform: rotate(180deg);
}

/* ===== Right Actions ===== */
.merchant-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.merchant-action-item {
  position: relative;
  display: flex;
  align-items: center;
}

.merchant-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: var(--mt-hover-bg);
  color: var(--mt-text-muted);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--mt-transition);
  text-decoration: none;
  position: relative;
}

.merchant-action-btn:hover {
  background: var(--mt-active-bg);
  color: var(--mt-text);
  text-decoration: none;
}

.merchant-action-btn::after {
  display: none !important;
}

/* Quick Add Button */
.merchant-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: var(--mt-accent);
  color: #ffffff;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--mt-transition);
  box-shadow: 0 2px 8px rgba(126, 0, 149, 0.3);
}

.merchant-add-btn:hover {
  background: var(--mt-accent-light);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(126, 0, 149, 0.4);
}

.merchant-add-btn::after {
  display: none !important;
}

/* Notification Badge */
.merchant-notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--mt-bg);
}

/* Wallet Button */
.merchant-wallet-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--mt-accent), var(--mt-accent-light));
  color: #ffffff !important;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: all var(--mt-transition);
  white-space: nowrap;
}

.merchant-wallet-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(126, 0, 149, 0.35);
  color: #ffffff !important;
}

.merchant-wallet-btn i {
  font-size: 14px;
}

/* Profile Button */
.merchant-profile-btn {
  display: flex;
  align-items: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--mt-transition);
}

.merchant-profile-btn::after {
  display: none !important;
}

.merchant-profile-btn:hover {
  transform: scale(1.05);
}

.merchant-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--mt-border);
  transition: border-color var(--mt-transition);
}

.merchant-profile-btn:hover .merchant-avatar {
  border-color: var(--mt-accent);
}

/* ===== Dropdown Menus ===== */
.merchant-dropdown-menu {
  position: absolute;
  top: 100% !important;
  left: 0;
  bottom: auto !important;
  transform: none !important;
  inset: unset !important;
  min-width: 200px;
  background: var(--mt-dropdown-bg);
  border: none;
  border-radius: var(--mt-dropdown-radius);
  box-shadow: var(--mt-dropdown-shadow);
  padding: 8px;
  margin-top: 8px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 9999;
  display: block;
}

.merchant-dropdown-menu-end {
  left: auto;
  right: 0;
}

/* Show state - handled by body-clone script in footer */
.dropdown.show .merchant-dropdown-menu,
.merchant-nav-dropdown:hover .merchant-dropdown-menu {
  display: none !important;
}

.merchant-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #374151 !important;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  transition: all var(--mt-transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.merchant-dropdown-item:hover {
  background: #f3f4f6;
  color: var(--mt-accent) !important;
  text-decoration: none;
}

.merchant-dropdown-item.active {
  background: rgba(126, 0, 149, 0.06);
  color: var(--mt-accent) !important;
}

.merchant-dropdown-item i {
  width: 18px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
}

.merchant-dropdown-item:hover i {
  color: var(--mt-accent);
}

.merchant-dropdown-item-danger {
  color: #ef4444 !important;
}

.merchant-dropdown-item-danger i {
  color: #ef4444 !important;
}

.merchant-dropdown-item-danger:hover {
  background: #fef2f2;
  color: #dc2626 !important;
}

/* ===== Notification Panel ===== */
.merchant-notification-panel {
  width: 320px;
  max-height: 400px;
  padding: 0;
  overflow: hidden;
}

.merchant-notification-header {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
}

.merchant-notification-header h6 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.merchant-notification-body {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}

.merchant-notification-body::-webkit-scrollbar {
  width: 4px;
}

.merchant-notification-body::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 4px;
}

/* ===== Profile Menu ===== */
.merchant-profile-menu {
  width: 240px;
  padding: 0;
  overflow: hidden;
}

.merchant-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, var(--mt-accent), var(--mt-accent-light));
}

.merchant-profile-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.merchant-profile-header h6 {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
}

.merchant-profile-header small {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.merchant-profile-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 4px 8px;
}

.merchant-profile-menu .merchant-dropdown-item {
  margin: 0 8px;
  width: calc(100% - 16px);
}

/* ===== Mobile Menu Toggle ===== */
.merchant-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  border: none;
  background: var(--mt-hover-bg);
  border-radius: 8px;
  cursor: pointer;
  padding: 10px;
  transition: all var(--mt-transition);
}

.merchant-menu-toggle:hover {
  background: var(--mt-active-bg);
}

.merchant-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--mt-text);
  border-radius: 2px;
  transition: all var(--mt-transition);
}

/* ===== Language Dropdown ===== */
.merchant-lang-dropdown .flag-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.merchant-lang-dropdown .merchant-dropdown-menu .flag-icon {
  width: 18px;
  height: 14px;
  border-radius: 2px;
}

/* ===== Responsive Adjustments ===== */

/* Adjust main content top padding when topbar is present */
.merchant-topbar~.dashboard-ecommerce,
.merchant-topbar~main.dashboard-ecommerce {
  padding-top: 0 !important;
}

.dashboard-main-wrapper:has(.merchant-topbar) {
  padding-top: var(--mt-height) !important;
}

/* Fallback for browsers without :has() support - applied via JS */
body.has-merchant-topbar .dashboard-main-wrapper {
  padding-top: var(--mt-height) !important;
}

/* Override old mobile reset of padding-top */
@media only screen and (max-width: 991px) {

  .dashboard-main-wrapper:has(.merchant-topbar),
  body.has-merchant-topbar .dashboard-main-wrapper {
    padding-top: var(--mt-height) !important;
  }
}

/* Sidebar positioning adjustment */
@media screen and (min-width: 992px) {
  body:has(.merchant-topbar) .sidebar-wrapper,
  body.has-merchant-topbar .sidebar-wrapper {
    top: var(--mt-height) !important;
    height: calc(100vh - var(--mt-height)) !important;
  }

  body:has(.merchant-topbar) .nav-left-sidebar,
  body.has-merchant-topbar .nav-left-sidebar {
    padding-top: 10px;
  }
}

/* Large screens - Compact nav items */
@media screen and (min-width: 992px) and (max-width: 1200px) {
  .merchant-nav-link {
    padding: 8px 10px;
    font-size: 12px;
  }

  .merchant-nav-link i:first-child {
    display: none;
  }
}

/* Extra large screens */
@media screen and (min-width: 1400px) {
  .merchant-topbar-inner {
    padding: 0 32px;
  }

  .merchant-nav-link {
    padding: 8px 16px;
    font-size: 14px;
  }
}

/* Tablet */
@media screen and (max-width: 991px) {
  .merchant-topbar-inner {
    padding: 0 16px;
  }

  .merchant-topbar-nav {
    display: none !important;
  }

  .merchant-wallet-btn span {
    display: none;
  }

  .merchant-wallet-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
}

/* Mobile */
@media screen and (max-width: 576px) {
  .merchant-topbar {
    height: 56px;
  }

  .merchant-topbar-inner {
    padding: 0 12px;
    gap: 8px;
  }

  .merchant-topbar-logo {
    height: 28px;
    max-width: 120px;
  }

  .merchant-action-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .merchant-add-btn {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .merchant-avatar {
    width: 32px;
    height: 32px;
  }

  .merchant-topbar-actions {
    gap: 6px;
  }

  body.has-merchant-topbar .dashboard-main-wrapper {
    padding-top: 56px !important;
  }

  body.has-merchant-topbar .sidebar-wrapper {
    top: 56px !important;
  }

  .merchant-notification-panel {
    width: 280px;
    right: -40px;
  }

  .merchant-profile-menu {
    right: -10px;
  }
}

/* ===== Offcanvas Mobile Nav ===== */
.merchant-mobile-offcanvas {
  background: var(--mt-bg);
  max-width: 300px;
}

.merchant-mobile-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--mt-border);
  padding: 16px 20px;
}

.merchant-mobile-offcanvas .offcanvas-header h5 {
  color: var(--mt-text);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

/* ===== Override conflicting styles ===== */
.merchant-topbar .dropdown-toggle::after {
  display: none !important;
}

.merchant-topbar .dropdown-menu {
  display: none;
}

.merchant-topbar .dropdown.show .dropdown-menu {
  display: block;
}

/* Use merchant-dropdown-menu instead of bootstrap dropdown-menu */
.merchant-topbar .merchant-dropdown-menu {
  display: none;
}

/* Hide old navbar styles that might conflict */
.merchant-topbar .navbar,
.merchant-topbar .navbar-nav,
.merchant-topbar .nav-item,
.merchant-topbar .nav-link {
  all: unset;
}

/* Ensure the old fixed-top navbar doesn't show */
nav.merchant-navbar.navbar.navbar-expand-lg.center-nav.transparent.navbar-light.p-3.fixed-top {
  display: none !important;
}

/* Isolate merchant-topbar from generic navbar styles */
.merchant-topbar {
  border: none !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
}

.merchant-topbar * {
  box-sizing: border-box;
}

.merchant-topbar .dropdown {
  position: relative;
}

.merchant-topbar .flag-icon {
  display: inline-block;
  line-height: 1;
}

/* Override for hover-based dropdowns on desktop - disabled, using clone */
@media (min-width: 992px) {
  .merchant-nav-dropdown:hover>.merchant-dropdown-menu {
    display: none !important;
  }
}

/* Ensure dropdown items are colored correctly */
.merchant-topbar .merchant-dropdown-item,
.merchant-topbar .merchant-dropdown-menu a {
  color: #374151 !important;
}

.merchant-topbar .merchant-dropdown-item:hover,
.merchant-topbar .merchant-dropdown-menu a:hover {
  color: var(--mt-accent) !important;
  background: #f3f4f6 !important;
}

.merchant-topbar .merchant-dropdown-item-danger {
  color: #ef4444 !important;
}

.merchant-topbar .merchant-dropdown-item-danger:hover {
  color: #dc2626 !important;
  background: #fef2f2 !important;
}

/* Prevent old mobile styles from affecting topbar dropdowns */
@media only screen and (max-width: 991px) {

  .merchant-topbar .merchant-dropdown-item,
  .merchant-topbar .merchant-dropdown-menu a,
  .merchant-topbar .merchant-dropdown-menu button {
    color: #374151 !important;
    background: transparent !important;
    width: auto !important;
  }

  .merchant-topbar .merchant-dropdown-item:hover,
  .merchant-topbar .merchant-dropdown-menu a:hover,
  .merchant-topbar .merchant-dropdown-menu button:hover {
    color: var(--mt-accent) !important;
    background: #f3f4f6 !important;
  }

  .merchant-topbar .merchant-dropdown-menu {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
  }
}