/* ==========================================================
   WISAXIS — APP HEADER COMPONENT (2026 SaaS Design System)
   Glassmorphic sticky navigation bar, brand typography,
   active indicator tabs, user avatar, and responsive drawer.
   ========================================================== */

/* ===== HEADER BASE (Mobile-first) ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header, 1200);
  display: flex;
  justify-content: center;
  align-items: center;
  height: var(--mobile-navbar-height, 72px);

  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

html[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.88);
  border-bottom-color: var(--border-default);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
}

.app-header.scrolled {
  background: var(--bg-overlay);
  box-shadow: var(--shadow-md);
  border-bottom-color: var(--border-strong);
}

html[data-theme="light"] .app-header.scrolled {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

/* ===== HEADER INNER ===== */
.header-inner {
  width: 100%;
  max-width: 1400px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

@media (min-width: 820px) {
  .header-inner {
    padding: 0 var(--space-5);
    gap: var(--space-4);
  }
}

/* ===== BRAND ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  user-select: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 0 10px var(--primary-glow));
  transition: transform 0.35s var(--ease-spring), filter 0.35s ease;
  flex-shrink: 0;
}

.brand:hover .brand-logo {
  transform: scale(1.12) rotate(6deg);
  filter: drop-shadow(0 0 18px var(--primary-glow));
}

.brand-text {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: var(--tracking-tighter);
  color: var(--text-main);
  white-space: nowrap;
}

.brand-text span {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  margin-left: 4px;
}

/* ===== HEADER ACTIONS CLUSTER ===== */
.header-actions-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== DESKTOP NAV ===== */
.desktop-nav {
  display: none;
}

@media (min-width: 820px) {
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 4px;
  }
}

.desktop-nav a {
  text-decoration: none;
  font-family: var(--font-body);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-normal);
  transition: all 0.2s var(--ease-out-smooth);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.desktop-nav a:hover {
  color: var(--text-main);
  background: var(--surface-card-hover);
}

html[data-theme="light"] .desktop-nav a:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.05);
}

/* Active Nav State */
.desktop-nav a[aria-current="page"],
.desktop-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 700;
}

.desktop-nav a.btn-primary {
  background: var(--gradient-brand);
  color: #ffffff !important;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px var(--primary-glow);
  margin-left: 6px;
}

.desktop-nav a.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 22px var(--primary-glow);
  filter: brightness(1.08);
}

/* ===== MOBILE NAV PILLS ===== */
.mobile-nav-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (min-width: 820px) {
  .mobile-nav-pills {
    display: none;
  }
}

.mobile-nav-login {
  text-decoration: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  transition: all 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-login:hover,
.mobile-nav-login:active {
  color: var(--text-main);
  background: var(--surface-2);
  transform: scale(0.96);
}

.mobile-nav-signup {
  text-decoration: none;
  background: var(--gradient-brand);
  color: #ffffff !important;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 800;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px var(--primary-glow);
  white-space: nowrap;
  transition: transform 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-signup:hover,
.mobile-nav-signup:active {
  transform: scale(0.96);
}

/* ===== ICON BUTTONS & THEME TOGGLE ===== */
.nav-icon-btn,
#theme-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition:
    transform 0.4s var(--ease-spring),
    background 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-icon-btn:hover,
#theme-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  transform: rotate(180deg) scale(1.1);
  box-shadow: 0 0 20px var(--primary-glow);
}

.nav-icon-btn:active,
#theme-toggle:active {
  transform: rotate(360deg) scale(0.92);
}

.nav-icon-btn svg,
#theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s var(--ease-spring);
}

/* ===== USER DROPDOWN ===== */
.user-dropdown {
  position: relative;
  z-index: var(--z-header-dropdown, 1300);
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  transition: all 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

.user-dropdown-trigger:hover,
.user-dropdown-trigger:active {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: scale(0.97);
}

.user-name {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-main);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .user-name {
    max-width: 70px;
  }
}

.dropdown-chevron {
  color: var(--text-muted);
  transition: transform 0.3s var(--ease-spring);
}

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

/* ===== DROPDOWN MENU ===== */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-header-dropdown, 1300);
  transform-origin: top right;

  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.93);
  pointer-events: none;
  transition:
    opacity 0.22s var(--ease-out-smooth),
    transform 0.25s var(--ease-spring),
    visibility 0.22s ease;
}

.user-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-menu a,
.dropdown-menu button {
  height: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-spring);
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover,
.dropdown-menu a:active,
.dropdown-menu button:active {
  background: var(--surface-2);
  color: var(--text-main);
  transform: translateX(3px);
}

.dropdown-menu svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.dropdown-menu a:hover svg {
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: 4px 0;
}

.dropdown-logout {
  color: var(--danger) !important;
}

.dropdown-logout:hover {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
}

/* ===== DESKTOP SIZE TWEAKS (≥ 820px) ===== */
@media (min-width: 820px) {
  .app-header {
    height: var(--desktop-navbar-height, 76px);
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-text {
    font-size: 1.15rem;
  }
}

/* ===== MOBILE HEADER REFINEMENTS (≤500px) ===== */
@media (max-width: 500px) {
  .app-header {
    height: var(--mobile-navbar-height, 64px);
  }

  .header-inner {
    padding: 0 var(--space-3);
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand-text {
    font-size: clamp(0.88rem, 3.8vw, 1.05rem);
  }

  .header-actions-wrap {
    gap: 6px;
  }

  .nav-icon-btn,
  #theme-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .nav-icon-btn svg,
  #theme-toggle svg {
    width: 16px;
    height: 16px;
  }

  .user-dropdown-trigger {
    height: 36px;
    min-height: 36px;
    padding: 0 10px 0 8px;
    gap: 5px;
    font-size: var(--text-xs);
  }

  .user-name {
    font-size: var(--text-xs);
    max-width: 56px;
  }

  .dropdown-chevron {
    width: 12px;
    height: 12px;
  }

  /* Anchored floating mobile dropdown */
  .dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: auto;
    bottom: auto;
    width: 240px;
    max-width: calc(100vw - 20px);
    border-radius: var(--radius-xl);
    padding: 8px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform-origin: top right;
    transform: translateY(-8px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 9999;
  }

  .user-dropdown.active .dropdown-menu {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .dropdown-menu a,
  .dropdown-menu button {
    height: 42px;
    min-height: 42px;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 0 12px;
    gap: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: var(--text-secondary);
  }

  .dropdown-menu a:hover,
  .dropdown-menu a:active {
    background: var(--surface-2);
    color: var(--text-main);
  }

  /* Mobile nav pills adjustments */
  .mobile-nav-pills {
    gap: 5px;
  }

  .mobile-nav-login {
    font-size: 11px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
  }

  .mobile-nav-signup {
    font-size: 11px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
  }
}

/* ===== ULTRA-COMPACT HEADER (≤380px) ===== */
@media (max-width: 380px) {
  .brand-text span {
    display: none;
  }

  .brand-text {
    font-size: 0.95rem;
  }

  .user-name {
    display: none;
  }

  .user-dropdown-trigger {
    padding: 0 8px;
    gap: 4px;
  }

  .mobile-nav-login,
  .mobile-nav-signup {
    font-size: 10px;
    padding: 0 8px;
    min-height: 32px;
  }
}
