/* Shared Header (new design) + Auth Dropdown compatibility */

:root {
  --blue-400: #4f8cff;
  --blue-500: #2b6fe6;
  --blue-50: #eef4ff;
  --blue-200: #b3cdff;
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f7;
  --gray-200: #e2e6ed;
  --gray-300: #c8ced9;
  --gray-400: #9aa2b1;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --surface-card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-blue: 0 4px 20px rgba(79, 140, 255, 0.25);
  --radius-sm: 8px;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 12px 24px;
  transition: all 0.3s ease;
}

.site-header.scrolled {
  background: rgba(250,250,251,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--gray-200);
  padding: 8px 24px;
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
}

.header-logo {
  display: inline-flex;
  align-items: center;
  color: var(--gray-900);
  padding: 10px 0;
}

.header-logo svg {
  width: 110px;
  height: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  transition: color 0.2s;
  text-decoration: none;
}

.header-nav a:hover {
  color: var(--gray-900);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.auth-guest {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}

.login-link:hover {
  color: var(--gray-900);
  background: var(--gray-100);
}

.signup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--blue-400);
  padding: 10px 22px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-blue);
}

.signup-btn:hover {
  background: var(--blue-500);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(79,140,255,0.3);
}

/* Auth user */
.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tier-badge.tier-free {
  background: #e5e7eb;
  color: #4b5563;
}

.tier-badge.tier-basic {
  background: #dbeafe;
  color: #1d4ed8;
}

.tier-badge.tier-pro {
  background: #f3e8ff;
  color: #7e22ce;
}

.tier-badge.tier-premium {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #78350f;
}

.user-dropdown {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.user-trigger:hover {
  background: var(--gray-100);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-400);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-arrow {
  transition: transform 0.2s ease;
  color: var(--gray-600);
  display: inline-flex;
}

.user-trigger.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface-card);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 1200;
}

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

.dropdown-content {
  padding: 8px 0;
}

.dropdown-user-info {
  padding: 12px 14px;
}

.dropdown-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.4;
  word-break: break-all;
}

.dropdown-tier {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 3px;
}

.dropdown-role {
  font-size: 11px;
  color: var(--blue-500);
  font-weight: 600;
  margin-top: 4px;
}

.dropdown-divider {
  margin: 8px 0;
  border: 0;
  border-top: 1px solid var(--gray-100);
}

.dropdown-usage {
  padding: 8px 14px;
  background: #fafbff;
}

.usage-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.usage-item:last-child {
  margin-bottom: 0;
}

.dropdown-item {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  text-decoration: none;
  transition: background 0.2s ease;
}

.dropdown-item:hover {
  background: var(--gray-50);
}

.dropdown-item.logout-item {
  color: #dc2626;
}

.dropdown-item.logout-item:hover {
  background: #fef2f2;
}

/* =============================================
   MOBILE HAMBURGER TOGGLE
   Hidden on desktop, shown on mobile
   ============================================= */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 1001;
  position: relative;
  color: var(--gray-700);
}

.mobile-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

.mobile-toggle.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-toggle.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mobile-toggle.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* =============================================
   OVERLAY BACKDROP
   Always in DOM, shown/hidden via JS class
   ============================================= */
.nav-overlay {
  display: none; /* JS adds display:block when needed */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-overlay.is-active {
  display: block;
}

.nav-overlay.is-visible {
  opacity: 1;
}

/* Mobile-only elements hidden on desktop */
.nav-mobile-divider,
.nav-mobile-actions {
  display: none;
}

/* =============================================
   MOBILE BREAKPOINT
   ============================================= */
@media (max-width: 989px) {
  .mobile-toggle {
    display: flex !important;
  }

  /* Show compact auth status on mobile */
  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 4px;
  }

  /* Never show guest auth pills in top bar on mobile */
  .header-actions .auth-guest {
    display: none !important;
  }

  /* Compact logged-in top bar: badge + avatar only */
  .header-actions .auth-user {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .header-actions .auth-user .user-name,
  .header-actions .auth-user .dropdown-arrow {
    display: none !important;
  }

  .header-actions .auth-user .user-trigger {
    padding: 0;
    border-radius: 999px;
    background: transparent;
  }

  .header-actions .auth-user .user-trigger:hover {
    background: transparent;
  }

  /* Desktop dropdown is not used directly on mobile top bar */
  .header-actions .auth-user .dropdown-menu {
    display: none !important;
  }

  .header-actions .auth-user .tier-badge {
    display: inline-flex !important;
  }

  /* Slide-in drawer */
  .header-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 85vw);
    background: #ffffff;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    z-index: 999;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    padding: 60px 28px 36px;
    gap: 0;
    transform: translateX(110%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    height: max-content;
  }

  .header-nav.is-open {
    transform: translateX(0);
  }

  /* Nav links in drawer */
  .header-nav > a {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-700);
    padding: 13px 0;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    transition: color 0.2s ease, padding-left 0.2s ease;
  }

  .header-nav > a:last-of-type {
    border-bottom: none;
  }

  .header-nav > a:hover {
    color: var(--blue-500);
    padding-left: 4px;
  }

  /* Show mobile-only elements */
  .nav-mobile-divider {
    display: block;
    height: 1px;
    background: var(--gray-200);
    margin: 20px 0;
  }

  .nav-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* When logged in, drawer renders cloned desktop dropdown content */
  .nav-mobile-actions.is-auth-user {
    gap: 0;
  }

  .nav-mobile-actions.is-auth-user .dropdown-content {
    padding: 0;
  }

  .nav-mobile-actions.is-auth-user .dropdown-menu {
    position: static;
    width: 100%;
    border: 0;
    box-shadow: none;
    background: transparent;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .nav-mobile-actions .btn-login {
    display: block;
    text-align: center;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    border: 1px solid var(--gray-200);
    transition: background 0.2s ease;
  }

  .nav-mobile-actions .btn-login:hover {
    background: var(--gray-50);
  }

  .nav-mobile-actions .btn-cta {
    display: block;
    text-align: center;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--blue-400);
    color: #fff;
    text-decoration: none;
    box-shadow: var(--shadow-blue);
    transition: background 0.2s ease, transform 0.15s ease;
  }

  .nav-mobile-actions .btn-cta:hover {
    background: var(--blue-500);
    transform: translateY(-1px);
  }

  .dropdown-user-info,
  .dropdown-usage,
  .dropdown-item {
    padding: 12px 0;
  }

  .dropdown-email,
  .usage-item, 
  .header-nav a.dropdown-item {
    font-size: 16px;
  }

  .dropdown-item.logout-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-main);
    font-weight: 600;
    color: var(--accent-rose);
    background: #FFF1F3;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid #FECDD6;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 25px;
    justify-content: center;
  }
}