/* ===== MODERN TOPBAR STYLES ===== */

/* Root variables for topbar */
:root {
  --topbar-height: 80px;
  --topbar-bg: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  --topbar-text: #ffffff;
  --topbar-text-secondary: rgba(255, 255, 255, 0.8);
  --search-bg: #ffffff;
  --search-border: #e5e7eb;
  --search-button-bg: #f59e0b;
  --search-button-hover: #d97706;
  --nav-item-hover: rgba(255, 255, 255, 0.1);
  --nav-item-active: rgba(255, 255, 255, 0.2);
  --mobile-breakpoint: 768px;
  --transition-all: all 0.2s ease;
}

/* Topbar container */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
}

/* Main navigation bar */
.main-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 2rem;
  height: var(--topbar-height);
  max-width: 1400px;
  margin: 0 auto;
}

/* Brand section */
.brand {
  flex-shrink: 0;
}

.brand-link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  transition: var(--transition-all);
}

.brand-link:hover {
  transform: scale(1.05);
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-all);
  gap: 4px;
}

.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--topbar-text);
  border-radius: 1px;
  transition: var(--transition-all);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Search container */
.search-container {
  flex: 1;
  max-width: 600px;
  margin: 0 1rem;
}

.search-form {
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 50px 0 16px;
  background: var(--search-bg);
  border: 2px solid var(--search-border);
  border-radius: 22px;
  font-size: 0.95rem;
  color: #374151;
  transition: var(--transition-all);
  outline: none;
}

.search-input:focus {
  border-color: var(--search-button-bg);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-button {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: var(--search-button-bg);
  border: none;
  border-radius: 20px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-all);
}

.search-button:hover {
  background: var(--search-button-hover);
  transform: translateY(-50%) scale(1.05);
}

.search-icon {
  width: 18px;
  height: 18px;
}

/* Navigation actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--topbar-text);
  text-decoration: none;
  border-radius: 8px;
  transition: var(--transition-all);
  min-height: 44px;
}

.nav-link:hover {
  background: var(--nav-item-hover);
  color: var(--topbar-text);
  text-decoration: none;
}

.nav-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.nav-label {
  font-size: 0.75rem;
  color: var(--topbar-text-secondary);
  font-weight: 400;
}

.nav-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--topbar-text);
}

/* Location selector */
.location-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--topbar-text);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: var(--transition-all);
  min-height: 44px;
}

.location-button:hover {
  background: var(--nav-item-hover);
}

.location-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.location-label {
  font-size: 0.75rem;
  color: var(--topbar-text-secondary);
  font-weight: 400;
}

.location-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--topbar-text);
}

/* Cart specific styling */
.cart-link {
  flex-direction: column;
  gap: 4px;
  text-align: center;
  min-width: 60px;
}

.cart-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-icon {
  width: 24px;
  height: 24px;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cart-text {
  font-size: 0.875rem;
  font-weight: 600;
}

/* Icons styling */
.account-icon,
.orders-icon,
.location-icon {
  flex-shrink: 0;
}

/* Overlay for mobile menu */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 998;
  transition: var(--transition-all);
}

.overlay.show {
  display: block;
}

/* ===== INTEGRATION WITH EXISTING SIDEBAR ===== */

/* Ensure topbar works with existing sidebar.css */
/* No additional sidebar styles needed - using your existing sidebar.css */

/* Sidebar Profile */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-icon {
  flex-shrink: 0;
  color: var(--topbar-text);
}

.profile-text {
  flex: 1;
}

.profile-greeting {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--topbar-text);
  margin-bottom: 4px;
}

.profile-link {
  font-size: 0.875rem;
  color: var(--topbar-text-secondary);
  text-decoration: none;
  transition: var(--transition-all);
}

.profile-link:hover {
  color: var(--topbar-text);
  text-decoration: underline;
}

/* Sidebar Menu */
.sidebar-menu {
  padding: 1rem 0;
}

.menu-section {
  margin-bottom: 1.5rem;
}

.menu-section:last-child {
  margin-bottom: 0;
}

.menu-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--topbar-text);
  padding: 0 1rem;
  margin: 0 0 0.75rem 0;
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-list li {
  margin: 0;
}

.menu-list a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--topbar-text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition-all);
  border-left: 3px solid transparent;
}

.menu-list a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--topbar-text);
  border-left-color: var(--topbar-text);
  text-decoration: none;
}

/* ===== MODERN MOBILE-FIRST RESPONSIVE DESIGN ===== */

/* Mobile first (small screens) - Base styles already applied above */

/* Small screens and up */
@media (min-width: 480px) {
  .main-navbar {
    padding: 0 1rem;
  }
  
  .brand-logo {
    height: 42px;
  }
  
  .search-container {
    max-width: 500px;
  }
  
  .search-input {
    height: 46px;
    padding: 0 52px 0 18px;
    font-size: 1rem;
  }
  
  .search-button {
    width: 42px;
    height: 42px;
  }
}

/* Tablets and up */
@media (min-width: 768px) {
  .main-navbar {
    padding: 0 1.5rem;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
  
  .nav-actions {
    display: flex;
  }
  
  .search-container {
    max-width: 600px;
  }
  
  .nav-text {
    display: flex;
  }
  
  .location-text {
    display: flex;
  }
}

/* Large tablets and small desktops */
@media (min-width: 992px) {
  .main-navbar {
    padding: 0 2rem;
    gap: 1.5rem;
  }
  
  .search-container {
    max-width: 650px;
  }
  
  .nav-actions {
    gap: 1rem;
  }
  
  .nav-link {
    padding: 10px 14px;
  }
}

/* Large desktops and up */
@media (min-width: 1200px) {
  .main-navbar {
    padding: 0 2.5rem;
    gap: 2rem;
  }
  
  .search-container {
    max-width: 700px;
    margin: 0 2rem;
  }
  
  .nav-actions {
    gap: 1.5rem;
  }
}

/* Mobile-specific styles */
@media (max-width: 767px) {
  :root {
    --topbar-height: 60px;
  }
  
  .main-navbar {
    padding: 0 1rem;
    gap: 0.5rem;
  }
  
  .mobile-menu-toggle {
    display: flex;
    order: -1;
  }
  
  .brand {
    order: 1;
  }
  
  .search-container {
    order: 2;
    margin: 0 0.5rem;
    max-width: none;
    flex: 1;
  }
  
  .nav-actions {
    display: none;
  }
  
  .brand-logo {
    height: 36px;
  }
  
  .search-input {
    height: 40px;
    padding: 0 45px 0 16px;
    font-size: 0.9rem;
    border-radius: 20px;
  }
  
  .search-button {
    width: 36px;
    height: 36px;
    border-radius: 18px;
  }
  
  .search-icon {
    width: 16px;
    height: 16px;
  }
}

/* Extra small mobile screens */
@media (max-width: 479px) {
  :root {
    --topbar-height: 56px;
  }
  
  .main-navbar {
    padding: 0 0.75rem;
  }
  
  .brand-logo {
    height: 32px;
  }
  
  .search-container {
    margin: 0 0.25rem;
  }
  
  .search-input {
    height: 38px;
    padding: 0 42px 0 14px;
    font-size: 0.85rem;
  }
  
  .search-button {
    width: 34px;
    height: 34px;
  }
  
  .mobile-menu-toggle {
    width: 40px;
    height: 40px;
  }
  
  .hamburger-line {
    width: 18px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .brand-logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Focus styles for keyboard navigation */
@media (hover: none) and (pointer: coarse) {
  .nav-link,
  .location-button,
  .search-button,
  .mobile-menu-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Hover states only for devices that support hover */
@media (hover: hover) and (pointer: fine) {
  .brand-link:hover {
    transform: scale(1.02);
  }
  
  .nav-link:hover {
    background: var(--nav-item-hover);
  }
  
  .location-button:hover {
    background: var(--nav-item-hover);
  }
  
  .search-button:hover {
    background: var(--search-button-hover);
    transform: translateY(-50%) scale(1.05);
  }
  
  .mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}
