:root {
  --primary-color: #3b82f6;
  --secondary-color: #1e40af;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --white: #ffffff;
  --font-main: "Poppins", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-main);
}

body {
  padding-top: 70px;
}

.navbar {
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  height: 70px;
  display: flex;
  align-items: center;
}

.navigation-container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}
.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Logo */
.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Navigation Links */
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 25px;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}
.nav-links a:hover {
  color: var(--primary-color);
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  color: var(--white) !important;
  padding: 10px 24px;
  border-radius: 50px;
  transition: background 0.3s;
}
.btn-primary:hover {
  background-color: var(--secondary-color);
}

.btn-login {
  border: 1px solid #e5e7eb;
  padding: 8px 20px;
  border-radius: 50px;
  transition: all 0.2s;
}
.btn-login:hover {
  border-color: var(--text-dark);
  background-color: var(--text-dark);
  color: var(--white) !important;
}

/* Green Cart Button */
.btn-cart-action {
  background-color: #10b981;
  color: white !important;
  padding: 8px 18px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-cart-action:hover {
  background-color: #059669;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(16, 185, 129, 0.35);
}
.cart-badge {
  background: white;
  color: #10b981;
  font-size: 0.75rem;
  font-weight: 800;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- DESKTOP DROPDOWN --- */
.user-dropdown {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}
.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dark);
  font-weight: 500;
  transition: background 0.2s;
}
.profile-btn:hover {
  background: #f3f4f6;
  color: var(--primary-color);
}
.dropdown-arrow {
  transition: transform 0.3s;
  font-size: 0.8rem;
}

/* Bridge for hover stability */
.user-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 20px;
  background: transparent;
}

.dropdown-menu {
  position: absolute;
  top: 160%;
  right: 0;
  background: white;
  width: 220px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 8px;
  list-style: none;
  border: 1px solid #f3f4f6;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease-in-out;
}
.dropdown-menu li {
  width: 100%;
  margin: 0;
}
.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  border-radius: 8px;
  color: var(--text-dark);
  font-size: 0.9rem;
  width: 100%;
}
.dropdown-menu a:hover {
  background: #eff6ff;
  color: var(--primary-color);
}

/* Desktop Hover Logic */
@media (min-width: 769px) {
  .user-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    top: 130%;
    transform: translateY(0);
  }
  .user-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
  }
}

.dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 6px 0;
}
.logout-item {
  color: #ef4444 !important;
}
.logout-item:hover {
  background: #fef2f2 !important;
}

/* --- TOGGLE BUTTON (HAMBURGER) --- */
.nav-toggle {
  display: none;
}
.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 10px;
}
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  background: var(--text-dark);
  height: 3px;
  width: 28px;
  border-radius: 2px;
  position: relative;
  transition: all 0.3s;
}
.nav-toggle-label span::before {
  content: "";
  position: absolute;
  bottom: 8px;
}
.nav-toggle-label span::after {
  content: "";
  position: absolute;
  top: 8px;
}

/* --- MOBILE STYLES --- */
@media (max-width: 768px) {
  .nav-container {
    position: static;
  } /* Ensures relative context works */

  .nav-toggle-label {
    display: block;
    z-index: 1001;
  }

  /* Mobile Nav Container */
  .nav-links {
    position: absolute;
    top: 70px;
    left: 0;
    width: 100%;
    background: var(--white);
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    border-top: 1px solid #f3f3f3;
    max-height: 0;
    overflow: hidden; /* Hide by default */
    transition: max-height 0.3s ease-in-out;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  }

  /* Show Nav when Checked */
  .nav-toggle:checked ~ .nav-links {
    max-height: 500px; /* Large enough to fit content */
    overflow-y: auto;
  }

  /* Toggle Animation */
  .nav-toggle:checked ~ .nav-toggle-label span {
    background: transparent;
  }
  .nav-toggle:checked ~ .nav-toggle-label span::before {
    transform: rotate(45deg);
    bottom: 0;
  }
  .nav-toggle:checked ~ .nav-toggle-label span::after {
    transform: rotate(-45deg);
    top: 0;
  }

  .nav-links li {
    width: 100%;
    border-bottom: 1px solid #f8f9fa;
  }
  .nav-links li a {
    display: block;
    padding: 15px 20px;
    width: 100%;
  }

  /* --- MOBILE DROPDOWN (ACCORDION STYLE) --- */
  .user-dropdown {
    display: block;
    width: 100%;
    cursor: pointer;
  }
  .profile-btn {
    width: 100%;
    padding: 15px 20px;
    justify-content: space-between;
    background: transparent;
  }
  .user-dropdown:hover {
    background: transparent;
  } /* Remove hover bg on mobile parent */

  .dropdown-menu {
    position: static; /* Stack naturally */
    box-shadow: none;
    border: none;
    width: 100%;
    padding: 0;
    background: #f8fafc; /* Grey background for sub-items */
    opacity: 1;
    visibility: visible;
    transform: none;

    /* Accordion Logic */
    display: none;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
  }

  /* Show when Active (Triggered by JS) */
  .user-dropdown.mobile-active .dropdown-menu {
    display: block;
    animation: slideDown 0.3s ease;
  }

  .dropdown-menu a {
    padding-left: 40px;
    font-size: 0.9rem;
  } /* Indent items */

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Special Buttons in Mobile */
  .btn-primary,
  .btn-login,
  .btn-cart-action {
    margin: 15px 20px;
    width: calc(100% - 40px);
    text-align: center;
    justify-content: center;
  }
  #dynamic-cart-li {
    border-bottom: none;
  }
}
