/* ═══════════════════════════════════════════════════════════════════════
   sz-header-fix v3 — ALWAYS dark header with white text (ALL themes)
   
   User's design choice:
     SPEC = white (#fff)
     ZAP  = red (#ef4444)
     บทความ = white (#fff)
     Privacy = white (#fff)
   
   Uses html[data-theme] body prefix to beat v3-light.css specificity.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Header background: dark + glass (BOTH themes) ───────────── */
html[data-theme="light"] body header.p-header,
html[data-theme="light"] body nav.p-header,
html[data-theme="light"] body nav.p-nav,
html[data-theme="light"] body header.p-header.p-header,
html[data-theme="dark"] body header.p-header,
html[data-theme="dark"] body nav.p-header,
html[data-theme="dark"] body nav.p-nav,
.p-header, .p-nav,
header.p-header,
nav.p-header, nav.p-nav {
  background: rgba(6, 1, 3, 0.95) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: saturate(180%) blur(24px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(24px) !important;
  box-shadow: none !important;
}

/* ── Logo: SPEC = white, ZAP = red ───────────────────────────── */
html[data-theme="light"] body header .p-logo,
html[data-theme="light"] body .p-header .p-logo,
html[data-theme="light"] body a.p-logo,
html[data-theme="light"] body nav .p-logo,
html[data-theme="light"] .p-logo,
.p-logo,
header a.p-logo,
nav a.p-logo,
a.p-logo {
  color: #ffffff !important;
}
html[data-theme="light"] body header .p-logo span,
html[data-theme="light"] body .p-header .p-logo span,
html[data-theme="light"] body a.p-logo > span,
html[data-theme="light"] body nav .p-logo span,
html[data-theme="light"] .p-logo span,
html[data-theme="light"] .p-logo > span:not(.kana),
.p-logo span:not(.kana),
.p-logo > span:not(.kana) {
  color: #ef4444 !important;
}
html[data-theme="light"] body header .p-logo .kana,
html[data-theme="light"] body .p-header .p-logo .kana,
html[data-theme="light"] body .p-logo .kana,
.p-logo .kana {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* ── Nav links: บทความ, Privacy = white ──────────────────────── */
html[data-theme="light"] body header .nav-link,
html[data-theme="light"] body .p-header .nav-link,
html[data-theme="light"] body .p-nav-actions a,
html[data-theme="light"] body .p-nav-actions .nav-link,
html[data-theme="light"] body .nav-links a,
html[data-theme="light"] body nav .nav-link,
html[data-theme="light"] .nav-link,
html[data-theme="light"] .p-nav-actions a,
html[data-theme="light"] .nav-links a,
.nav-link,
.p-nav-actions a,
.nav-links a,
header .nav-link,
nav .nav-link {
  color: #ffffff !important;
  font-weight: 600 !important;
}
html[data-theme="light"] body header .nav-link:hover,
html[data-theme="light"] body .p-nav-actions a:hover,
html[data-theme="light"] body .nav-links a:hover,
html[data-theme="light"] body .nav-link.nav-active,
.nav-link:hover,
.p-nav-actions a:hover,
.nav-links a:hover,
.nav-link.nav-active {
  color: #ef4444 !important;
}

/* ── Language toggle ─────────────────────────────────────────── */
html[data-theme="light"] body .lang-toggle,
html[data-theme="light"] body .shared-lang-toggle,
.lang-toggle,
.shared-lang-toggle {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}
html[data-theme="light"] body .lang-toggle button,
html[data-theme="light"] body .shared-lang-toggle button,
.lang-toggle button,
.shared-lang-toggle button {
  color: rgba(255, 255, 255, 0.7) !important;
  background: transparent !important;
  font-weight: 600 !important;
}
html[data-theme="light"] body .lang-toggle button.active,
html[data-theme="light"] body .shared-lang-toggle button.active,
.lang-toggle button.active,
.shared-lang-toggle button.active {
  background: #ef4444 !important;
  color: #ffffff !important;
}

/* ── Theme toggle ────────────────────────────────────────────── */
html[data-theme="light"] body .theme-toggle,
.theme-toggle {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
}
html[data-theme="light"] body .theme-toggle:hover,
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  color: #ef4444 !important;
}

/* ── Quota badge ─────────────────────────────────────────────── */
html[data-theme="light"] body .quota-badge,
.quota-badge {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  color: #fca5a5 !important;
}
html[data-theme="light"] body .quota-badge svg,
html[data-theme="light"] body .quota-badge span,
html[data-theme="light"] body #quota-text,
.quota-badge svg,
.quota-badge span,
#quota-text {
  color: #fca5a5 !important;
}

/* Google auth controls in the always-dark header */
html[data-theme="light"] body .auth-signin-btn,
html[data-theme="light"] body .auth-user-menu,
.auth-signin-btn,
.auth-user-menu {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  height: 36px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  padding: 0 12px !important;
}
html[data-theme="light"] body .auth-signin-btn[hidden],
html[data-theme="light"] body .auth-user-menu[hidden],
.auth-signin-btn[hidden],
.auth-user-menu[hidden] {
  display: none !important;
}
.auth-signin-btn {
  cursor: pointer !important;
}
.auth-signin-btn:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
}
.auth-avatar {
  width: 22px !important;
  height: 22px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.16) !important;
}
.auth-name {
  max-width: 128px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  color: #ffffff !important;
}
.auth-signout-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(239, 68, 68, 0.14) !important;
  color: #fca5a5 !important;
  cursor: pointer !important;
}
@media (max-width: 760px) {
  .auth-name,
  .auth-signin-btn span {
    display: none !important;
  }
  /* Ensure sign-in button has adequate touch target on mobile (min 44px) */
  .auth-signin-btn {
    min-width: 44px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    justify-content: center !important;
    position: relative !important;
    z-index: 100 !important;
    -webkit-tap-highlight-color: rgba(239, 68, 68, 0.3) !important;
    touch-action: manipulation !important;
  }
}

@media (max-width: 520px) {
  .p-nav .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 8px !important;
  }
  .p-nav-actions,
  .nav-right {
    gap: 8px !important;
    min-width: 0 !important;
  }
  .p-nav-actions .nav-link,
  .nav-links {
    display: none !important;
  }
  .quota-badge {
    display: none !important;
  }
  .lang-toggle button,
  .shared-lang-toggle button {
    padding-left: 9px !important;
    padding-right: 9px !important;
  }
  .quota-badge {
    padding-left: 9px !important;
    padding-right: 9px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Our Apps dropdown — always dark + readable text (fixes light-theme bug
   where white text sat on a white card and became invisible)
   ═══════════════════════════════════════════════════════════════════════ */
.ourapps-wrap { position: relative; margin-left: 2px; }
.ourapps-trigger {
  font-family: inherit !important; font-weight: 600 !important; font-size: 0.78rem !important;
  padding: 5px 10px !important;
  color: #ffffff !important;
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 8px !important; cursor: pointer;
  display: inline-flex !important; align-items: center !important; gap: 5px !important;
  transition: all 0.2s ease; white-space: nowrap; letter-spacing: 0.03em;
}
.ourapps-trigger:hover {
  background: rgba(239,68,68,0.15) !important;
  border-color: rgba(239,68,68,0.4) !important;
  color: #ffffff !important;
}
.ourapps-trigger .caret { font-size: 9px; opacity: 0.85; transition: transform 0.2s ease; }
.ourapps-wrap:hover .caret { transform: rotate(180deg); }
.ourapps-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 280px; padding: 8px;
  background: #14181f !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 9999;
}
.ourapps-wrap:hover .ourapps-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.ourapps-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  text-decoration: none !important; color: #ffffff !important;
  transition: background 0.15s ease;
}
.ourapps-item:hover { background: rgba(255,255,255,0.06) !important; }
.ourapps-item-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ourapps-item-icon.sz { background: rgba(239,68,68,0.18) !important; color: #ef4444 !important; }
.ourapps-item-icon.iz { background: rgba(251,191,36,0.15) !important; color: #fbbf24 !important; }
.ourapps-item-info { flex: 1; min-width: 0; }
.ourapps-item-name {
  font-weight: 700; font-size: 0.85rem; color: #ffffff !important;
  display: flex; align-items: center; gap: 6px;
}
.ourapps-item-desc {
  font-size: 0.72rem; color: rgba(255,255,255,0.55) !important; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ourapps-here-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(239,68,68,0.18) !important; color: #ef4444 !important; white-space: nowrap;
}
.ourapps-free-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(16,185,129,0.18) !important; color: #10b981 !important; white-space: nowrap;
}
.ourapps-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 12px; }
@media (max-width: 640px) {
  .ourapps-dropdown { left: auto; right: -40px; min-width: 260px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Header inner layout — makes the nav lay out horizontally on EVERY page
   (these rules used to live inline only in index.html, so sub-pages broke)
   ═══════════════════════════════════════════════════════════════════════ */
.p-nav .container {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px;
  flex-wrap: nowrap;
}
.nav-left  { display: flex !important; align-items: center; gap: 20px; }
.nav-links { display: flex !important; align-items: center; gap: 16px; }
.nav-right { display: flex !important; align-items: center; gap: 12px; }
.theme-toggle {
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; padding: 0;
}
.theme-toggle svg { width: 16px; height: 16px; }
@media (max-width: 560px) {
  .nav-links { display: none !important; }
}
