/*
 * Unified Navigation Component - Shared nav header and cart system
 * Ensures consistent navigation and cart styling across all pages
 * v1.0 - Extracted from index.html to create unified system
 */

/* Navigation header base styles - MOBILE OVERRIDE: Static positioning for normal scrolling */
.nav-header {
  border-bottom: 1px solid #e5e5e5;
  padding: 0;
  position: static; /* Changed from sticky to static for normal scrolling behavior */
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile specific: ensure nav header always scrolls naturally */
@media (max-width: 920px) {
  .nav-header {
    position: static !important; /* Force static on mobile */
  }
}

/* Landscape mobile: prevent any sticky behavior */
@media (max-width: 920px) and (orientation: landscape) {
  .nav-header {
    position: static !important; /* Force static in landscape */
  }
}

/* Default light theme background - only applied when no theme class is present */
body:not(.theme-dark):not(.theme-light) .nav-header,
body.theme-light .nav-header {
  background: #fff;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #333;
  font-weight: 600;
}

.nav-brand img {
  height: 34px;
  display: block;
  object-fit: contain;
}

/* RTA brand pill */
.brand-rta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 800; /* match index visual */
  font-size: 14px;
  letter-spacing: 0.08em; /* match index visual */
  line-height: 1;
  border: 1px solid var(--brand-rta-border, #cbd5e1);
  background: var(--brand-rta-bg, #eef2f6);
  color: var(--brand-rta-fg, #1e293b);
}

/* Slight emphasis on the letter A */
.brand-rta .brand-rta-a { font-size: 1.1em; line-height: 1; color: #38bdf8; }

/* Default/light theme values */
body:not(.theme-dark):not(.theme-light) .brand-rta,
body.theme-light .brand-rta {
  --brand-rta-bg: #eef2f6;  /* slate-100 */
  --brand-rta-fg: #1e293b;  /* slate-800 */
  --brand-rta-border: #cbd5e1; /* slate-300 */
}

/* Dark theme values */
body.theme-dark .brand-rta {
  --brand-rta-bg: #233042;  /* slightly lighter panel tone */
  --brand-rta-fg: #e2e8f0;  /* readable on dark */
  --brand-rta-border: #2d4256; /* stronger, defined edge */
  border-width: 2px; /* more defined outline on dark */
}

.nav-menu {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-button {
  padding: 10px 18px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  text-decoration: none;
  color: #495057;
  font-weight: 500;
  transition: all 0.3s ease;
  cursor: pointer;
  font-size: 14px;
}

/* Default light theme nav-button styles */
body:not(.theme-dark):not(.theme-light) .nav-button,
body.theme-light .nav-button {
  background: #f8f9fa;
}

body:not(.theme-dark):not(.theme-light) .nav-button:hover,
body.theme-light .nav-button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  color: #343a40;
}

.nav-button.active {
  background: #1a5a99;
  border-color: #1a5a99;
  color: #fff;
}

.nav-button.active:hover {
  background: #144a82;
  border-color: #144a82;
}

/* Header cart button */
.header-cart {
  padding: 10px 16px;
  background: #007cba;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
  font-size: 14px;
}

.header-cart:hover {
  background: #005a87;
}

/* Theme toggle button - Positioned before cart button */
.header-theme-toggle {
  padding: 8px 14px;
  background: #6c757d;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  margin-right: 8px; /* Space between theme toggle and cart button */
  transition: background 0.3s ease;
}

.header-theme-toggle:hover {
  background: #5a6268;
}

/* Floating cart summary */
#floatingCartSummary {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #007cba;
  color: #fff;
  padding: 12px 16px;
  border-radius: 25px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-weight: 600;
  z-index: 999;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

#floatingCartSummary:hover {
  background: #005a87;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* Responsive navigation */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: 15px;
    text-align: center;
    position: relative;
    padding: 15px 20px;
  }

  .nav-menu {
    position: static;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-button, .header-cart {
    padding: 8px 16px;
    font-size: 13px;
    width: 90px;
    margin: 0;
    text-align: center;
  }

  .nav-brand {
    margin-left: 0;
  }

  .header-cart {
    margin-right: 0;
    width: auto;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
    min-width: 120px; /* Ensure cart button is big enough to tap */
  }
  
  .header-cart:hover {
    background: #005a87;
  }

  #floatingCartSummary {
    bottom: 15px;
    right: 15px;
    font-size: 12px;
    padding: 10px 14px;
  }
}

/* Portrait mobile: specific cart positioning */
@media (max-width: 768px) and (orientation: portrait) {
  .header-cart {
    padding: 12px 18px; /* Bigger tap target in portrait */
    min-width: 140px;
  }
}

/* Landscape mobile: adjust cart button for landscape */
@media (max-width: 920px) and (orientation: landscape) {
  .header-cart {
    padding: 8px 12px; /* Smaller in landscape to save space */
    font-size: 12px;
  }
}

/* Cart overlay styles */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.cart-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Cart sidebar styles */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: -350px;
  width: 300px;
  height: 100%;
  background: #fff;
  border-left: 1px solid #ccc;
  box-shadow: -2px 0 5px rgba(0,0,0,0.2);
  padding: 20px;
  overflow-y: auto;
  transition: right 0.3s ease;
  z-index: 999;
}

.cart-sidebar.open {
  right: 0;
}

/* Mobile cart sidebar improvements */
@media (max-width: 768px) {
  .cart-sidebar {
    width: 280px;
    right: -300px;
    z-index: 10001; /* Higher z-index for mobile */
    box-shadow: -4px 0 8px rgba(0,0,0,0.3);
  }
  
  .cart-sidebar.open {
    right: 0;
  }
  
  /* Ensure cart overlay works on mobile */
  .cart-overlay.show {
    opacity: 1;
    visibility: visible;
    z-index: 10000; /* Below cart sidebar */
  }
}

.cart-item {
  border-bottom: 1px solid #eee;
  padding: 10px 0;
  font-size: 14px;
}

.cart-group-header {
  background: #f8f9fa;
  padding: 8px;
  margin: 5px 0;
  border-radius: 4px;
  font-weight: bold;
  color: #333;
}

.cart-group-header strong {
  color: #007bff;
}

.remove-btn {
  background: #dc3545 !important;
  color: white;
  border: none;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  margin-top: 5px;
}

.remove-btn:hover {
  background: #c82333 !important;
}
