/**
 * PolySM Studio — Ultra-Glassmorphic Header Stylesheet
 * Elite-Web-Engineering: Specular Hairlines, Channel Switcher, Auth Beacons, User Hub
 */

.app-header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 500;
  background: rgba(3, 5, 8, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), var(--border-specular-glow, inset 0 1px 0 rgba(255, 255, 255, 0.08));
  transition: background-color var(--transition-base, 0.2s ease), border-color var(--transition-base, 0.2s ease);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
}

/* Brand & Logo Group */
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-primary, #ffffff);
  transition: opacity 0.2s ease;
}

.header-brand:hover {
  opacity: 0.9;
}

.header-logo-img {
  height: 36px;
  width: auto;
  max-width: 190px;
  display: block;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* Desktop Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-link {
  padding: 0.45rem 0.8rem;
  font-size: 0.845rem;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  border-radius: var(--radius-sm, 8px);
  transition: all var(--transition-fast, 0.15s ease);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #ffffff;
  background: var(--bg-surface-2, rgba(22, 28, 48, 0.88));
  border: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Channel Switcher Dropdown */
.channel-switcher {
  position: relative;
}

.channel-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.85rem;
  background: var(--bg-surface-1, #090c15);
  border: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  color: var(--text-primary, #ffffff);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.3));
}

.channel-btn:hover {
  background: var(--bg-surface-2, rgba(22, 28, 48, 0.88));
  border-color: var(--border-hairline-hover, rgba(255, 255, 255, 0.16));
}

.channel-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs, 6px);
  background: rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
}

.channel-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-surface-elevated, #0e121e);
  border: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 550;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.channel-dropdown-menu.is-open {
  display: flex;
}

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

.channel-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm, 8px);
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  border: 1px solid transparent;
  text-decoration: none;
}

.channel-menu-item:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.06);
}

.channel-menu-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #ffffff;
  border-color: rgba(99, 102, 241, 0.3);
}

.channel-menu-divider {
  height: 1px;
  background: var(--border-hairline-subtle, rgba(255, 255, 255, 0.06));
  margin: 0.35rem 0;
}

/* Header Controls Right */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Language Toggle Button */
.lang-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  background: var(--bg-surface-1, #090c15);
  border: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  color: var(--text-secondary, #94a3b8);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
}

.lang-toggle-btn:hover {
  background: var(--bg-surface-2, rgba(22, 28, 48, 0.88));
  color: var(--text-primary, #ffffff);
  border-color: var(--border-hairline-hover, rgba(255, 255, 255, 0.16));
}

/* User Profile & Credit Indicator */
.user-deck {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.775rem;
  font-weight: 600;
  color: #c7d2fe;
  text-decoration: none;
  transition: all 0.15s ease;
}

.credit-pill:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
}

.user-hub-wrapper {
  position: relative;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.user-avatar-disc {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill, 9999px);
  background: linear-gradient(135deg, var(--color-indigo, #6366f1), var(--color-cyan, #06b6d4));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  color: #ffffff;
  border: 2px solid var(--bg-surface-1, #090c15);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.user-avatar-btn:hover .user-avatar-disc {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.6);
}

.user-avatar-disc-lg {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* =========================================================================
   ELEVATED USER HUB DROPDOWN MENU
   ========================================================================= */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 310px;
  background: var(--bg-surface-elevated, #0e121e);
  border: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  padding: 0.85rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 550;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu.is-open {
  display: flex;
}

/* 1. Identity & Plan */
.user-hub-profile {
  padding: 0.4rem 0.35rem 0.25rem;
}

.user-hub-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.user-hub-identity {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.user-hub-name {
  font-family: var(--font-display, 'Outfit', sans-serif);
  font-weight: 700;
  font-size: 0.925rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-hub-email {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-hub-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  padding-top: 0.35rem;
}

.user-hub-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.user-hub-plan-link {
  font-size: 0.75rem;
  color: var(--color-indigo, #6366f1);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.user-hub-plan-link:hover {
  color: #818cf8;
  text-decoration: underline;
}

/* 2. Credits Breakdown Card */
.user-hub-credits-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-md, 12px);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-hub-credits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-hub-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #64748b);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.user-hub-total-credits {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

.user-hub-credits-breakdown {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-xs, 6px);
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.credit-subitem {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.credit-subitem-label {
  color: var(--text-muted, #64748b);
  font-size: 0.72rem;
}

.credit-subitem-val {
  font-weight: 700;
}

/* 3. Active Channel Card */
.user-hub-channel-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-md, 12px);
  padding: 0.6rem 0.75rem;
}

.user-hub-channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.user-hub-edit-channel-link {
  font-size: 0.72rem;
  color: var(--color-cyan, #06b6d4);
  text-decoration: none;
  font-weight: 600;
}

.user-hub-edit-channel-link:hover {
  text-decoration: underline;
}

.user-hub-channel-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-hub-channel-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 4. Quick Links */
.user-hub-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-hub-link-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm, 8px);
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.user-hub-link-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.user-hub-link-item .svg-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted, #64748b);
  transition: color 0.15s ease;
}

.user-hub-link-item:hover .svg-icon {
  color: var(--color-indigo, #6366f1);
}

/* 5. Logout Button */
.user-hub-footer {
  padding-top: 0.2rem;
}

.btn-user-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm, 8px);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.28);
  color: #fda4af;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-user-logout:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.5);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.25);
}

/* Mobile Hamburger Toggle */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary, #ffffff);
  padding: 0.4rem;
  cursor: pointer;
}

/* Mobile Drawer Overlay */
.mobile-drawer {
  position: fixed;
  top: 68px;
  left: 0;
  width: 100%;
  height: calc(100vh - 68px);
  background: rgba(3, 5, 8, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-hairline, rgba(255, 255, 255, 0.08));
  z-index: 490;
  display: none;
  flex-direction: column;
  padding: 1.5rem;
  gap: 0.85rem;
}

.mobile-drawer.is-open {
  display: flex;
}

@media (max-width: 900px) {
  .header-nav { display: none; }
  .channel-switcher { display: none; }
  .mobile-nav-toggle { display: inline-flex; }
}
