/* Header Styles */
header {
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

header.scrolled {
  background-color: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* Disable blur when mobile menu is open to prevent stacking context bugs */
body.menu-open header {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: white !important;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-right {
  display: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo img {
  width: 100px;
  height: auto;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
}

/* ===== NAVIGATION ===== */
nav {
  display: flex;
  align-items: center;
  gap: 30px;
}

nav a {
  text-decoration: none;
  color: #64748b;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.3s;
  padding: 8px 16px;
  border-radius: 8px;
}

nav a:hover, .nav-link.has-caret:hover {
  background-color: #f1f5f9;
  color: #2c3e50;
}

nav a.active {
  color: #2c3e50;
  font-weight: 600;
}

/* ===== SEARCH BOX ===== */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: white;
}

.search-box #icon-search {
  color: #94a3b8;
  width: 18px;
  height: 18px;
}

.search-box input {
  border: none;
  outline: none;
  font-size: 13px;
  width: 180px;
  background: transparent;
}

/* ===== NAV DROPDOWN ===== */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-link.has-caret {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: #64748b;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s;
}

.nav-link.has-caret .caret {
  transition: transform 0.2s ease;
}

.nav-dropdown.open .caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 120%;
  left: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 8px;
  display: none;
  z-index: 1000;
}

.nav-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: #334155;
  text-decoration: none;
  font: 500 13px/1.2 Inter, system-ui, sans-serif;
}

.dropdown-menu a:hover {
  background: #f1f5f9;
  color: #111827;
}

/* ===== AUTH SECTION ===== */
.auth-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-section .btn-user-login,
.auth-section .btn-login,
.auth-section .btn-register {
  padding: 8px 18px;
  background: #2c3e50;
  color: #f1f5f9;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
  text-transform: none;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
}

.auth-section .btn-register {
  background: transparent;
  border: 1.5px solid #2c3e50;
  color: #2c3e50;
}

.auth-section .btn-user-login:hover,
.auth-section .btn-login:hover,
.auth-section .btn-register:hover {
  background: #3b5c92;
  color: white;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-user-login:active,
.btn-register:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Icon styling */
.btn-user-login svg,
.btn-register svg {
  width: 16px;
  height: 16px;
}

/* Nav auth section - only visible on mobile (inside side nav) */
.nav-auth-section {
  display: none;
}

/* User Profile Section in Navbar (Shared) */
.user-profile {
  display: flex !important;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}

.btn-logout {
  font-size: 12px;
  color: #ef4444 !important;
  text-decoration: none;
  font-weight: 700;
  margin-left: 8px;
  border-left: 1px solid #e2e8f0;
  padding-left: 10px;
  transition: opacity 0.2s;
}

.btn-logout:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ===== GUEST PROFILE (Global) ===== */
.guest-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 50px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1.5px solid #e2e8f0;
  background: white;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.guest-profile:hover {
  background: #f8fafc;
  border-color: #2c3e50;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.guest-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 16px;
  transition: all 0.3s ease;
}

.guest-profile:hover .guest-avatar {
  background: #2c3e50;
  color: white;
}

.guest-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  transition: color 0.3s ease;
}

.guest-profile:hover .guest-label {
  color: #2c3e50;
}

/* Responsive untuk mobile */
@media (max-width: 768px) {
  .logo img {
    width: 80px;
  }
  
  .header-container {
    padding: 15px 20px;
  }

  .auth-section {
    display: none !important;
  }

  .btn-user-login,
  .btn-login,
  .btn-register {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
  }

  /* Mobile Header Profiling */
  .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .mobile-auth-header {
    display: block;
  }

  .mobile-auth-header .guest-profile {
    padding: 2px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .mobile-auth-header .guest-label {
    display: none;
  }

  .mobile-auth-header .guest-avatar {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    color: #64748b;
  }

  .mobile-avatar-container {
    position: relative;
    display: flex;
    align-items: center;
  }

  .mobile-header-avatar {
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    transition: transform 0.2s;
  }

  .mobile-header-avatar:active {
    transform: scale(0.9);
  }

  .mobile-logout-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: -10px;
    background: white;
    min-width: 200px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border: 1px solid #e2e8f0;
    padding: 10px;
    display: none;
    z-index: 2000;
    animation: fadeInScale 0.2s ease-out;
  }

  .mobile-logout-dropdown.active {
    display: block;
  }

  .dropdown-user-info {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
  }

  .dropdown-user-info strong {
    font-size: 14px;
    color: #1e293b;
    display: block;
  }

  .dropdown-user-info span {
    font-size: 12px;
    color: #64748b;
  }

  .btn-logout-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #ef4444;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.2s;
  }

  .btn-logout-mobile:hover {
    background: #fef2f2;
  }

  @keyframes fadeInScale {
    from {
      opacity: 0;
      transform: scale(0.95) translateY(-10px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  /* Nav & Dropdown for Mobile - Fixed Drawer */
  nav {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 80% !important;
    max-width: 300px !important;
    height: 100vh !important;
    background: white !important;
    flex-direction: column !important;
    padding: 2.5rem 0 !important;
    gap: 0 !important;
    transition: left 0.3s ease !important;
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.1) !important;
    z-index: 9999 !important; /* Extremely high to beat any blur context */
    display: flex !important;
    overflow-y: auto !important;
    align-items: stretch !important;
  }

  nav.active {
    left: 0 !important;
  }

  /* Logo inside sidebar */
  .nav-logo {
    display: block !important;
    padding: 1rem 1.5rem 2rem !important;
    border-bottom: 1px solid #f0f0f0 !important;
    margin-bottom: 8px !important;
  }

  .nav-logo img {
    width: 80px !important;
    height: auto !important;
  }

  /* Auth section at bottom of sidebar */
  .nav-auth-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 1.5rem !important;
    border-top: 1px solid #f0f0f0 !important;
    margin-top: auto !important;
  }

  .nav-dropdown {
    width: 100% !important;
    position: static !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .nav-link.has-caret {
    width: 100%;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .nav-dropdown .dropdown-menu {
    position: static !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: #f8fafc !important;
    padding: 5px 0 5px 20px !important;
    margin-top: 0 !important;
    display: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }

  .nav-dropdown.open .dropdown-menu {
    display: block !important;
  }

  .nav-dropdown .dropdown-menu a {
    padding: 10px 16px;
  }
}

/* ===== NAVBAR SEARCH BAR (Desktop) ===== */
.navbar-search-container {
  position: relative;
  box-sizing: border-box;
  width: fit-content;
  display: flex;
  align-items: center;
  margin-right: 15px;
  order: 3;
}

.navbar-search-mainbox {
  box-sizing: border-box;
  position: relative;
  width: 230px;
  height: 44px;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  border-radius: 160px;
  background-color: #2c3e50;
  transition: all 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.navbar-search-checkbox {
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  position: absolute;
  right: 17px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9;
  cursor: pointer;
  appearance: none;
  margin: 0;
}

.navbar-search-checkbox:checked ~ .navbar-search-mainbox {
  width: 44px;
}

.navbar-search-checkbox:checked ~ .navbar-search-mainbox .navbar-search-input {
  width: 0;
  opacity: 0;
  padding: 0;
  pointer-events: none;
}

.navbar-search-input {
  box-sizing: border-box;
  height: 100%;
  width: 170px;
  background-color: transparent;
  border: none;
  outline: none;
  padding-bottom: 2px;
  padding-left: 15px;
  font-size: 14px;
  color: #f1f5f9;
  transition: all 0.3s ease;
}

.navbar-search-icon-container {
  box-sizing: border-box;
  padding-top: 4px;
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 12px;
  flex-shrink: 0;
}

.navbar-search-icon {
  fill: #f1f5f9;
  font-size: 1.3em;
}

/* Flex Order for Desktop Layout */
.logo { order: 1; }
nav { order: 2; }
.auth-section { order: 4; }

/* ===== MOBILE RESPONSIVE (Search & Layout) ===== */
@media (max-width: 768px) {
  .header-container .logo {
    order: 1 !important;
    margin-right: auto !important;
  }

  .header-container .navbar-search-container {
    order: 2 !important;
    margin-right: 5px !important;
    display: block !important;
    position: relative;
    z-index: 1010;
    width: 42px;
    height: 42px;
  }

  .header-container .header-right {
    order: 3 !important;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .header-container .hamburger-menu {
    order: 4 !important;
    position: relative;
    display: flex !important;
  }

  /* Mobile Search Bar Behavior */
  .navbar-search-mainbox {
    width: 42px;
    height: 42px;
    background-color: transparent;
    box-shadow: none;
  }

  .navbar-search-checkbox:checked ~ .navbar-search-mainbox {
    width: 42px;
  }

  .navbar-search-checkbox:checked ~ .navbar-search-mainbox .navbar-search-icon {
    fill: #2c3e50;
    font-size: 1.5em;
  }

  .navbar-search-checkbox:not(:checked) ~ .navbar-search-mainbox {
    width: 85vw;
    height: 48px;
    position: fixed;
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background-color: #2c3e50;
    border-radius: 100px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: row-reverse;
  }

  .navbar-search-checkbox:not(:checked) ~ .navbar-search-mainbox .navbar-search-input {
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    padding-left: 15px;
    color: white;
  }
}
