/* ═══════════════════════════════════════════
   fikcentX v14.1.1 — Premium Header Upgrade
   Glassmorphism sticky bar, animated hamburger,
   nav indicator pills, slide-down mobile drawer,
   refined icon buttons & badges.
   ═══════════════════════════════════════════ */

/* ── STICKY GLASSMORPHISM TOPBAR ───────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 14px;
  flex-wrap: nowrap;
  background: rgba(11, 13, 19, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid rgba(30, 36, 54, 0.6);
  transition: background 0.35s, box-shadow 0.35s, padding 0.3s;
}
.topbar.scrolled {
  background: rgba(6, 7, 11, 0.88);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(59, 125, 255, 0.08);
  padding: 8px 0;
}

/* Glowing bottom line — upgraded with animation */
.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 212, 255, 0.25) 20%,
    rgba(59, 125, 255, 0.55) 50%,
    rgba(167, 139, 250, 0.3) 80%,
    transparent 100%
  );
  z-index: 1;
  animation: headerGlow 6s ease-in-out infinite alternate;
}
@keyframes headerGlow {
  0% { opacity: 0.5; filter: hue-rotate(0deg); }
  100% { opacity: 1; filter: hue-rotate(15deg); }
}

/* ── BRAND ─────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-logo {
  display: flex;
  align-items: center;
  position: relative;
}
.brand-logo::after {
  content: '';
  position: absolute;
  inset: -10px -14px;
  background: radial-gradient(ellipse at center, rgba(0, 212, 255, 0.07), transparent 70%);
  border-radius: 14px;
  pointer-events: none;
  z-index: -1;
  transition: opacity 0.3s;
}
.brand-logo:hover::after {
  opacity: 1.4;
}
.brand-logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.brand-logo img,
.brand-logo .brand-logo-img {
  height: 34px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
  filter: brightness(1.1) drop-shadow(0 0 8px rgba(0, 212, 255, 0.18));
  transition: filter 0.3s ease, transform 0.3s ease;
}
.brand-logo img:hover,
.brand-logo .brand-logo-img:hover {
  filter: brightness(1.25) drop-shadow(0 0 16px rgba(0, 212, 255, 0.4)) drop-shadow(0 0 6px rgba(59, 125, 255, 0.2));
  transform: scale(1.03) translateY(-1px);
}

/* Version badge */
.brand-version {
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.18);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.brand:hover .brand-version {
  opacity: 1;
}

/* ── NAV BAR (pill container) ──────────── */
.topbar-nav {
  display: flex;
  align-items: center;
  background: rgba(16, 19, 27, 0.6);
  border: 1px solid var(--border-1);
  border-radius: 10px;
  padding: 3px;
  position: relative;
  overflow: hidden;
}
.topbar-nav-track {
  display: flex;
  align-items: center;
  gap: 1px;
}
.topbar-nav-item {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 500;
  color: var(--t-40);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.2s, background 0.25s, transform 0.15s;
  letter-spacing: 0.2px;
  white-space: nowrap;
  position: relative;
  user-select: none;
}
.topbar-nav-item:hover {
  color: var(--t-80);
  background: rgba(255, 255, 255, 0.03);
}
.topbar-nav-item:active {
  transform: scale(0.97);
}

/* Active nav item — glowing pill */
.topbar-nav-item.active {
  background: linear-gradient(135deg, rgba(59, 125, 255, 0.14), rgba(0, 212, 255, 0.08));
  color: var(--t-100);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(59, 125, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.topbar-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

/* ── NAV BADGES ────────────────────────── */
.nav-badge {
  font-family: var(--font-data);
  font-size: 8px;
  font-weight: 700;
  padding: 1.5px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: top;
  letter-spacing: 0.5px;
  display: inline-block;
  line-height: 1.3;
}
/* Also keep old class working */
.nav-badge-new {
  font-family: var(--font-data);
  font-size: 8px;
  font-weight: 700;
  padding: 1.5px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: top;
  letter-spacing: 0.5px;
}
.nav-badge--ai {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.2);
  animation: badgePulse 3s ease-in-out infinite;
}
.nav-badge--new {
  color: var(--amber);
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.2);
}
@keyframes badgePulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; box-shadow: 0 0 6px rgba(167, 139, 250, 0.3); }
}

/* ── META ACTIONS (right side) ─────────── */
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Status tag */
.topbar-tag {
  font-family: var(--font-data);
  font-size: 10.5px;
  color: var(--t-60);
  background: rgba(16, 19, 27, 0.7);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: all 0.3s;
}
.topbar-tag.loading { color: var(--t-20); }
.topbar-tag .spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--t-20);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
}

/* ── ICON BUTTONS (theme/history/notif) ── */
.icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  background: rgba(21, 25, 35, 0.7);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--t-60);
  font-size: 14px;
  padding: 0;
}
.icon-btn:hover {
  border-color: var(--border-2);
  background: var(--bg-4);
  color: var(--t-100);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.icon-btn:active {
  transform: translateY(0) scale(0.96);
}
.icon-btn-svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Fix: keep history-btn backward-compat display */
.history-btn.icon-btn {
  font-size: 14px;
}

/* Notification button using icon-btn base */
.notif-btn.icon-btn {
  font-size: 14px;
}

/* ── AUTH BUTTON ────────────────────────── */
.auth-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, var(--blue), #5b8fff);
  border: none;
  border-radius: 8px;
  color: white;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.auth-nav-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.12));
  opacity: 0;
  transition: opacity 0.3s;
}
.auth-nav-btn:hover {
  box-shadow: 0 4px 20px rgba(59, 125, 255, 0.35);
  transform: translateY(-1px);
}
.auth-nav-btn:hover::before { opacity: 1; }
.auth-nav-btn:active {
  transform: translateY(0) scale(0.98);
}
.auth-btn-label { position: relative; z-index: 1; }
.auth-btn-arrow {
  position: relative;
  z-index: 1;
  opacity: 0.8;
  transition: transform 0.2s, opacity 0.2s;
}
.auth-nav-btn:hover .auth-btn-arrow {
  transform: translateX(2px);
  opacity: 1;
}

/* ── HAMBURGER MENU — animated X morph ─── */
.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(21, 25, 35, 0.7);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  padding: 9px 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  order: 99;
}
.mobile-menu-btn:hover {
  border-color: var(--border-2);
  background: var(--bg-4);
}
.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--t-80);
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55),
              opacity 0.2s ease,
              width 0.3s ease;
  transform-origin: center;
}

/* X morphing when open */
.mobile-menu-btn[aria-expanded="true"] {
  border-color: var(--blue);
  background: rgba(59, 125, 255, 0.08);
}
.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
  width: 18px;
}
.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
  width: 18px;
}

@media (min-width: 701px) {
  .mobile-menu-btn { display: none; }
}

/* ── MOBILE BACKDROP ───────────────────── */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 11, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 997;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mobile-backdrop.show {
  display: block;
  opacity: 1;
}

/* ── MOBILE NAV DRAWER ─────────────────── */
@media (max-width: 700px) {
  .topbar-nav {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: rgba(11, 13, 19, 0.95);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--border-1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(59, 125, 255, 0.06);
    z-index: 998;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                transform 0.3s ease;
  }
  .topbar-nav.open {
    display: block;
    max-height: 500px;
    opacity: 1;
    transform: translateY(0);
  }
  .topbar-nav-track {
    flex-direction: column;
    gap: 2px;
  }
  .topbar-nav-item {
    padding: 12px 16px;
    font-size: 13px;
    border-radius: 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
    width: 100%;
  }
  .topbar-nav-item.active::after {
    display: none;
  }
  .topbar-nav-item.active {
    background: linear-gradient(135deg, rgba(59, 125, 255, 0.12), rgba(0, 212, 255, 0.06));
    border-left: 3px solid var(--blue);
    padding-left: 13px;
  }
}

/* ── RESPONSIVE REFINEMENTS ────────────── */
@media (max-width: 1100px) {
  .topbar-nav-item { padding: 6px 10px; font-size: 10.5px; }
}
@media (max-width: 900px) {
  .topbar-tag { display: none; }
}
@media (max-width: 700px) {
  .topbar { padding: 10px 0; gap: 8px; }
  .topbar-meta { gap: 6px; }
  .topbar-tag { display: none; }
  .auth-nav-btn { font-size: 10px; padding: 6px 12px; }
  .auth-btn-arrow { display: none; }
  .brand-logo-img { height: 28px; }
  .brand-version { font-size: 8px; padding: 2px 5px; }
}
@media (max-width: 400px) {
  .brand-version { display: none; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn-svg { width: 14px; height: 14px; }
}

/* ── SCROLL SHADOW (JS-driven class) ───── */
.topbar.scrolled .brand-logo img {
  height: 30px;
}
.topbar.scrolled .topbar-nav-item {
  padding-top: 5px;
  padding-bottom: 5px;
}

/* ── PRINT RESET ───────────────────────── */
@media print {
  .topbar, .mobile-backdrop { display: none !important; }
}
