*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 0;
}

/* ===== HEADER STYLES ===== */
header {
  height: 64px;
  background-color: #ffffff;
  box-shadow: 0 1px 30px rgba(56, 56, 56, 0.214);
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  align-items: center;
}

header.scrolled {
  background-color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
  border-bottom: 1px solid #f1f5f9 !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* 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: #ffffff !important;
  z-index: 10000;
}

.header-container {
  max-width: 1200px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.header-right {
  display: none;
}

/* ===== HAMBURGER MENU & OVERLAY ===== */
.hamburger-menu {
  display: none;
  width: 42px;
  height: 42px;
  padding: 10px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  z-index: 10001;
}

.hamburger-menu span {
  display: block;
  width: 100%;
  height: 2px;
  background: #1e293b;
  border-radius: 999px;
  transform-origin: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-menu.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-overlay {
  position: fixed;
  inset: 0;
  display: block;
  background: rgba(15, 23, 42, 0.52);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 9999;
}

.nav-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.menu-open {
  overflow: hidden;
}

/* ===== LOGO ===== */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 200px;
  min-width: 200px;
  height: 100%;
  justify-content: flex-start;
  order: 1;
}

.logo a {
  display: flex;
  align-items: center;
  height: 100%;
  text-decoration: none;
  line-height: 1;
}

.logo img {
  width: 100px;
  height: 36px;
  max-height: 36px;
  display: block;
  object-fit: contain;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
}

.nav-logo {
  display: none;
}

/* ===== NAVIGATION ===== */
nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  order: 2;
}

nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #64748b;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  padding: 8px 18px;
  border-radius: 8px;
  background-color: transparent;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

nav a:hover, .nav-link.has-caret:hover {
  background-color: #f8fafc;
  color: #1e293b;
}

nav a.active {
  background-color: transparent;
  color: #2c3e50;
  font-weight: 600;
  box-shadow: none;
  position: relative;
}


/* ===== 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;
}

.search-box input:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* ===== 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: 'Montserrat', 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 'Montserrat', system-ui, sans-serif;
}

.dropdown-menu a:hover {
  background: #f1f5f9;
  color: #111827;
}

/* ===== AUTH SECTION ===== */
.auth-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 200px;
  min-width: 200px;
  justify-content: flex-end;
  order: 3;
}

.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;
}

.btn-register.icon-only,
.user-profile.btn-register.icon-only,
.guest-profile.btn-register.icon-only {
  width: 44px;
  height: 44px;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  gap: 0 !important;
}

.user-profile.btn-register.icon-only .user-avatar, 
.guest-profile.btn-register.icon-only .guest-avatar {
  margin: 0 !important;
}

.auth-section .btn-user-login:hover,
.auth-section .btn-login:hover,
.auth-section .btn-register:hover {
  background: #34495e;
  color: white;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.25);
}

.btn-user-login:active,
.btn-register:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-auth-section {
  display: none;
}

/* ===== USER PROFILE DROPDOWN MENU ===== */
.user-profile {
  position: relative;
  display: flex !important;
  align-items: center;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 50px;
  transition: all 0.2s ease;
  background: transparent;
  border: 1.5px solid #2c3e50;
  color: #2c3e50;
  padding: 4px 8px 4px 4px;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
}

.user-profile-trigger:hover {
  background: #f8fafc;
}

.user-profile-caret {
  color: #64748b;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.user-profile.open .user-profile-caret {
  transform: rotate(180deg);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1a252f, #2c3e50);
  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;
}

.user-profile-menu-header {
  padding: 10px 12px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-profile-menu-header strong {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-menu-header span {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
}

.user-profile.open .user-profile-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-profile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #334155;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.user-profile-menu-item svg,
.user-profile-menu-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.user-profile-menu-item:hover {
  background: #f1f5f9;
}

.user-profile-menu-item--danger {
  color: #ef4444;
  border-top: 1px solid #f1f5f9;
  margin-top: 6px;
  padding-top: 12px;
}

.user-profile-menu-item--danger:hover {
  background: #fef2f2;
}

/* ===== GUEST PROFILE ===== */
.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;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-container {
    padding: 0.75rem;
  }

  .header-container .logo {
    order: 1 !important;
    margin-right: auto !important;
    flex: 0 0 auto;
    min-width: 0;
  }

  .logo img {
    width: 80px;
  }

  .header-container .header-right {
    order: 2 !important;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .header-container .hamburger-menu {
    order: 3 !important;
    position: relative;
    display: flex !important;
  }

  .auth-section {
    display: none !important;
  }

  .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 {
    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;
    width: min(280px, calc(100vw - 28px));
    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;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dropdown-user-info span {
    font-size: 12px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .btn-logout-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #334155;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.2s;
  }

  .btn-logout-mobile:hover {
    background: #f1f5f9;
  }

  .btn-logout-mobile#btnMobileLogout {
    color: #ef4444;
    border-top: 1px solid #f1f5f9;
    margin-top: 6px;
    padding-top: 12px;
  }

  .btn-logout-mobile#btnMobileLogout:hover {
    background: #fef2f2;
  }

  @keyframes fadeInScale {
    from {
      opacity: 0;
      transform: scale(0.95) translateY(-10px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  /* Nav Drawer Mobile */
  nav {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: translateX(-105%) !important;
    width: min(84vw, 320px) !important;
    height: 100dvh !important;
    background: white !important;
    flex-direction: column !important;
    padding: max(1rem, env(safe-area-inset-top)) 0 1.5rem !important;
    gap: 0 !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.1) !important;
    z-index: 10000 !important;
    display: flex !important;
    overflow-y: auto !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    text-align: left !important;
  }

  nav.active {
    transform: translateX(0) !important;
  }

  nav > a {
    width: calc(100% - 24px) !important;
    margin: 4px 12px !important;
    padding: 12px 18px !important;
    border-radius: 10px !important;
    font-size: 14.5px !important;
    justify-content: flex-start !important;
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
  }

  nav > a.active {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
  }

  .nav-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    order: -1 !important;
    align-self: stretch !important;
    width: 100% !important;
    margin: 0 0 10px !important;
    padding: 0.25rem 1.25rem 1rem !important;
    border-bottom: 1px solid #f0f0f0 !important;
    text-align: left !important;
    flex: 0 0 auto !important;
  }

  .nav-logo a,
  .nav-logo .logo-link {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .nav-logo img {
    width: 78px !important;
    height: auto !important;
    margin: 0 !important;
    display: block !important;
  }

  .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-auth-section .user-profile-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    padding: 8px 0 0;
    margin-top: 10px;
    display: none;
  }

  .nav-auth-section .user-profile.open .user-profile-menu {
    display: block;
  }

  .nav-dropdown {
    width: 100% !important;
    position: static !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .nav-link.has-caret {
    width: calc(100% - 24px) !important;
    margin: 4px 12px !important;
    justify-content: space-between !important;
    padding: 12px 18px !important;
    text-align: left !important;
    border-radius: 10px !important;
    font-size: 14.5px !important;
    display: flex !important;
    align-items: center !important;
  }

  .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 18px;
    justify-content: flex-start !important;
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 10px 14px;
  }

  .logo img {
    width: 72px;
  }

  .header-container .header-right {
    gap: 8px;
  }

  .hamburger-menu {
    width: 40px;
    height: 40px;
    padding: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  header,
  nav,
  .nav-overlay,
  .hamburger-menu span {
    transition: none !important;
  }
}