/* ==========================================================================
   Japanese Shikhi Kanji Portal — Minimalist Aesthetic Design System
   Matches https://www.japaneseshikhi.com/ with crisp CJK & Bengali typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700;800&family=Noto+Serif+JP:wght@400;600;700;900&family=Hind+Siliguri:wght@400;500;600;700&display=swap');

:root {
  /* Japanese Shikhi Core Color Palette */
  --js-crimson: #E63946;
  --js-crimson-hover: #d42e3a;
  --js-navy: #1D3557;
  --js-navy-dark: #0f172a;
  --js-teal: #2A9D8F;
  --js-amber: #F4A261;
  --js-purple: #6B21A8;

  /* Theme Defaults (Dark / Indigo Night by default) */
  --bg-app: #090B14;
  --bg-nav: linear-gradient(135deg, #0a0c18 0%, #0f0d1f 55%, #13102a 100%);
  --bg-card: #121526;
  --bg-card-hover: #181c33;
  --bg-subtle: #171b30;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);

  --text-primary: #f8fafc;
  --text-secondary: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.45);
  --text-inverse: #090B14;

  --accent-primary: var(--js-crimson);
  --accent-hover: var(--js-crimson-hover);
  --accent-secondary: var(--js-teal);
  --accent-highlight: var(--js-amber);

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 35px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(230, 57, 70, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-cjk: 'Noto Sans JP', var(--font-sans);
  --font-serif: 'Noto Serif JP', Georgia, serif;
  --font-bn: 'Hind Siliguri', var(--font-sans);
}

/* Light Theme (Clean Minimalist White & Deep Navy) */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-nav: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;

  --text-primary: #1D3557;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(230, 57, 70, 0.12);
}

/* Base Resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Background Ambient Orbs and Subtle Watermarks */
.ambient-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb-1 {
  position: absolute;
  top: -100px;
  right: -100px;
  width: 450px;
  height: 450px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(107, 33, 168, 0.12) 0%, transparent 70%);
  filter: blur(80px);
}

.ambient-orb-2 {
  position: absolute;
  top: 35%;
  left: -80px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 57, 70, 0.08) 0%, transparent 70%);
  filter: blur(80px);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.8;
}

[data-theme="light"] .ambient-grid {
  background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
}

.watermark-kanji {
  position: fixed;
  font-family: var(--font-serif);
  color: var(--text-primary);
  opacity: 0.025;
  font-size: 160px;
  font-weight: 900;
  user-select: none;
  pointer-events: none;
  z-index: 0;
  line-height: 1;
}

.wm-1 { top: 120px; right: 40px; }
.wm-2 { bottom: 80px; left: 40px; }

/* Bengali Typography */
[lang="bn"] body, 
[lang="bn"] .brand-kanji-sub,
[lang="bn"] h1, [lang="bn"] h2, [lang="bn"] h3, [lang="bn"] h4,
[lang="bn"] .card-meaning-title,
[lang="bn"] .hero-meaning,
[lang="bn"] .formula-quote,
[lang="bn"] .q-prompt-text,
[lang="bn"] .nav-tab-btn {
  font-family: var(--font-bn);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
}

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

/* Brand Logo */
.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--js-crimson);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-cjk);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 2px 10px rgba(230, 57, 70, 0.35);
  transition: transform 0.2s ease;
}

.brand-group:hover .brand-icon {
  transform: scale(1.05);
}

.brand-text-col {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-tag {
  background: rgba(230, 57, 70, 0.15);
  color: var(--js-crimson);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-kanji-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nav Tabs */
.app-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
}

.nav-tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .nav-tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Header Utilities */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Header Pro Upgrade Button */
.btn-header-pro {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, #e63946, #d42e3a);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-header-pro:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.5);
}

.btn-header-pro .pro-sparkle {
  color: #fef08a;
}

/* User Profile & Sign In Header Controls */
.btn-header-signin {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-header-signin:hover {
  background: var(--bg-card-hover);
  border-color: var(--js-crimson);
}

.user-profile-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  padding: 0;
  overflow: visible;
  transition: all 0.15s ease;
}

.user-avatar-btn:hover, .user-avatar-btn.admin-avatar {
  border-color: var(--js-crimson);
}

.avatar-pro-dot {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #f59e0b;
  color: #ffffff;
  font-size: 0.6rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 230px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.15s ease;
}

.user-dropdown-menu.hidden {
  display: none !important;
}

.dropdown-header {
  padding: 0.85rem 1rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dropdown-header strong {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.user-email-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
}

.user-badge-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.badge-status {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.badge-status.pro { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-status.free { background: var(--bg-surface); color: var(--text-muted); }
.badge-status.admin { background: rgba(230, 57, 70, 0.2); color: var(--js-crimson); }

.dropdown-items-list {
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-item.admin-link {
  color: var(--js-crimson);
  background: rgba(230, 57, 70, 0.06);
}

.dropdown-item.logout {
  color: var(--js-crimson);
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.25rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Google Sign In Button */
.btn-google-login {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.15s ease;
}

.btn-google-login:hover {
  background: #f9fafb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.5rem 0;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}

.auth-divider span {
  padding: 0 0.5rem;
}

.email-auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.btn-email-submit {
  width: 100%;
}

.auth-brand-logo {
  width: 48px;
  height: 48px;
  background: var(--js-crimson);
  color: #ffffff;
  font-family: var(--font-cjk);
  font-size: 1.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  margin: 0 auto 0.75rem;
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4);
}

/* Clean Language Pill Selector */
.header-lang-wrapper {
  display: flex;
  align-items: center;
}

.header-lang-select {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.header-lang-select:hover, .header-lang-select:focus {
  border-color: var(--js-crimson);
}

/* Minimalist Search Bar */
.header-search-box {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  width: 220px;
  transition: all 0.2s ease;
}

.header-search-box:focus-within {
  border-color: var(--js-crimson);
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.2);
  width: 260px;
}

.header-search-icon {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 0.4rem;
}

.header-search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  width: 100%;
}

.header-search-input::placeholder {
  color: var(--text-muted);
}

.search-kbd-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
}

[data-theme="light"] .search-kbd-hint {
  background: #e2e8f0;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.btn-theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--js-crimson);
}

/* ==========================================================================
   Main Viewport
   ========================================================================== */
.app-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
  position: relative;
  z-index: 1;
}

/* Common Control Buttons */
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.ctrl-btn:hover {
  background: var(--bg-card-hover);
}

.ctrl-btn.primary {
  background: var(--js-crimson);
  color: #ffffff;
  border-color: var(--js-crimson);
  box-shadow: 0 2px 10px rgba(230, 57, 70, 0.25);
}

.ctrl-btn.primary:hover {
  background: var(--js-crimson-hover);
}

.ctrl-btn.danger {
  background: transparent;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.ctrl-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Responsive adjustments */
@media (max-width: 900px) {
  .header-inner {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }
  .app-nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .header-search-box {
    width: 160px;
  }
}
