/*
 * MERA KHATA V2.0 - PREMIUM DESIGN SYSTEM
 * Architecture: Mobile-First, Native App Feel, High-Fidelity UI
 * Fonts: 'Outfit' for headings, 'Inter' for UI data
 */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  /* ==========================================================================
     1. COLOR SYSTEM (Premium SaaS Palette)
     ========================================================================== */
  /* Brand Primary (Indigo/Violet Gradient Base) */
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #3B82F6;
  --brand-600: #1E3A8A;
  --brand-gradient: linear-gradient(135deg, #1E3A8A 0%, #172554 100%);
  --brand-glow: rgba(30, 58, 138, 0.4);

  /* Surface & Background */
  --bg-app: #f8fafc;        /* Very light cool gray for main app body */
  --bg-surface: #ffffff;    /* Pure white for cards */
  --bg-surface-glass: rgba(255, 255, 255, 0.85); /* For glassmorphism */
  
  /* Text & Neutrals (Slate) */
  --text-primary: #0f172a;  /* Near black for headings */
  --text-secondary: #475569;/* Subtle text */
  --text-muted: #94a3b8;    /* Disabled or placeholder text */
  --border-light: #e2e8f0;
  --border-focus: #cbd5e1;

  /* Semantic Colors */
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --success-solid: #10b981;
  
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --danger-solid: #ef4444;

  --warning-bg: #fef3c7;
  --warning-text: #b45309;
  --warning-solid: #f59e0b;

  /* ==========================================================================
     2. TYPOGRAPHY
     ========================================================================== */
  --font-display: 'Poppins', system-ui, sans-serif;
  --font-sans: 'Nunito', system-ui, sans-serif;

  /* ==========================================================================
     3. SPACING & SIZING (4px Base)
     ========================================================================== */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */

  /* Touch Targets (Mobile First strict requirement) */
  --touch-target: 48px;

  /* ==========================================================================
     4. RADII & SHADOWS (Premium Depth)
     ========================================================================== */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.12), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 8px 20px var(--brand-glow);

  /* ==========================================================================
     5. ANIMATIONS (Spring Physics)
     ========================================================================== */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms var(--ease-smooth);
  --transition-spring: 300ms var(--ease-spring);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Safe Area for Mobile Notches */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   NATIVE APP UTILITIES
   ========================================================================== */
.no-select {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Enforces Apple/Google minimum touch target guidelines */
.touch-target {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.glass-panel {
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   COMPONENT: BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: 0 var(--space-6);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn--primary:hover {
  box-shadow: var(--shadow-glow);
}

.btn--outline {
  background: transparent;
  color: var(--brand-600);
  border: 2px solid var(--brand-100);
}

.btn--outline:hover {
  background: var(--brand-50);
  border-color: var(--brand-500);
}

/* ==========================================================================
   COMPONENT: INPUTS
   ========================================================================== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.input-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.input-field {
  width: 100%;
  min-height: var(--touch-target);
  padding: 0 var(--space-4);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input-field:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-50);
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-center { text-align: center; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ==========================================================================
   GLOBAL BOTTOM NAVIGATION (MOBILE-FIRST)
   ========================================================================== */
.bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.06);
    z-index: 999;
    transition: all 0.3s ease;
}

[data-theme="dark"] .bottom-nav {
    background: rgba(15, 23, 42, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 14px;
    color: var(--text-muted, #64748b);
    font-family: var(--font-sans, 'Poppins', sans-serif);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 8px 0;
    text-decoration: none;
    position: relative;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.bnav-item:active {
    transform: scale(0.9);
}

.bnav-icon {
    font-size: 1.3rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bnav-item.active {
    color: var(--brand-600, #4f46e5);
    font-weight: 700;
}

.bnav-item.active .bnav-icon {
    background: rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.bnav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-600, #4f46e5), #6366f1);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.5);
}

.bnav-item .badge {
    position: absolute;
    top: 2px;
    right: 12px;
    background: var(--danger-solid, #ef4444);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 12px;
    border: 2px solid #fff;
    transform: translate(50%, -50%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .bnav-item .badge {
    border-color: var(--bg-surface-glass, #1e293b);
}

/* Hide Bottom Nav on Desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}
/* =======================================================================
   PLAN GATE - Subscription Feature Gating UI
   ======================================================================= */

.plan-lock-badge {
    display: inline-flex; align-items: center; gap: 3px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff; font-size: 0.6rem; font-weight: 700;
    padding: 2px 6px; border-radius: 20px;
    letter-spacing: 0.04em; margin-left: auto;
    flex-shrink: 0; text-transform: uppercase;
}

.plan-locked-link { opacity: 0.65; pointer-events: auto !important; }

.plan-gate-overlay {
    position: absolute; inset: 0;
    background: rgba(10, 15, 30, 0.88);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    z-index: 500; display: flex;
    align-items: center; justify-content: center;
    padding: 16px; border-radius: inherit;
}

.plan-gate-card {
    background: linear-gradient(160deg, #0f172a 0%, #1a2744 100%);
    border: 1px solid rgba(99, 102, 241, 0.25); border-radius: 24px;
    padding: 28px 24px; text-align: center;
    max-width: 360px; width: 100%;
    animation: pgPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5),
                inset 0 1px 0 rgba(255,255,255,0.05);
}
@media (max-width: 480px) {
    .plan-gate-card { padding: 22px 16px; border-radius: 20px; }
}
@keyframes pgPop {
    from { transform: scale(0.85) translateY(12px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.plan-gate-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.2));
    border: 1px solid rgba(99,102,241,0.35); color: #a5b4fc;
    font-size: 0.68rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.1em; padding: 4px 12px; border-radius: 99px;
    margin-bottom: 16px;
}

.plan-gate-icon {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid rgba(99,102,241,0.3); border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; font-size: 1.5rem; color: #818cf8;
    box-shadow: 0 8px 24px rgba(99,102,241,0.2);
}

.plan-gate-title {
    color: #f1f5f9; font-size: 1.15rem; font-weight: 800;
    margin: 0 0 8px; letter-spacing: -0.01em;
}

.plan-gate-sub {
    color: #94a3b8; font-size: 0.82rem;
    line-height: 1.6; margin: 0 0 16px;
}
.plan-gate-sub strong { color: #fbbf24; font-weight: 700; }

.plan-gate-benefits {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px; padding: 12px 14px;
    margin-bottom: 18px; text-align: left;
}

.plan-gate-benefit {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0; font-size: 0.81rem;
    color: #cbd5e1; font-weight: 500;
}
.plan-gate-benefit i { color: #34d399; font-size: 0.75rem; flex-shrink: 0; }

.plan-gate-btn {
    display: inline-flex; align-items: center;
    justify-content: center; gap: 8px; width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none; border-radius: 14px;
    padding: 13px 24px; font-size: 0.95rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
    margin-bottom: 12px;
}
.plan-gate-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(99,102,241,0.55); }
.plan-gate-btn:active { transform: scale(0.97); }

.plan-gate-price { color: #64748b; font-size: 0.78rem; }
.plan-gate-price strong { color: #94a3b8; }
.plan-gate-link { color: #818cf8; text-decoration: none; font-weight: 600; }
.plan-gate-link:hover { color: #a5b4fc; text-decoration: underline; }


/* ==========================================================================
   UNIFIED HEADERS (Desktop & Mobile)
   ========================================================================== */

/* --- Mobile App Header --- */
.app-header {
    padding: 30px 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.greeting-col p {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 4px;
}

.greeting-col h1 {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.theme-toggle:active {
    transform: scale(0.9);
}

.store-badge {
    background: rgba(22, 163, 74, 0.1);
    border: 1px solid rgba(22, 163, 74, 0.2);
    color: var(--success-solid);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-solid);
    border-radius: 50%;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* --- DESKTOP TOPBAR CSS --- */
.desk-topbar {
    display: none;
}

@media (min-width: 1024px) {
    .desk-topbar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: #0f172a;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        align-items: center;
        z-index: 1000;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .desk-topbar-inner {
        max-width: 1400px;
        margin: 0 auto;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 0 36px;
        width: 100%;
        position: relative;
    }

    .desk-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 1.35rem;
        font-weight: 800;
        color: #fff;
        text-decoration: none;
        letter-spacing: -0.02em;
    }

    .desk-brand i {
        color: #3b82f6;
        font-size: 1.5rem;
    }

    .desk-nav {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .desk-nav a {
        padding: 10px 18px;
        border-radius: 12px;
        color: #cbd5e1;
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .desk-nav a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .desk-nav a.is-active {
        background: rgba(59, 130, 246, 0.15);
        color: #60a5fa;
    }

    .app-header {
        position: fixed;
        top: 0;
        right: 36px;
        height: 64px;
        z-index: 1001;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 24px;
        width: auto;
    }

    .greeting-col {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .greeting-col p {
        margin: 0;
        color: #94a3b8;
        font-size: 0.85rem;
        border-right: 1px solid #334155;
        padding-right: 12px;
    }

    .greeting-col h1 {
        margin: 0;
        color: #fff;
        font-size: 1.1rem;
    }

    .header-actions {
        margin: 0;
    }

    .theme-toggle {
        background: #1e293b;
        border-color: #334155;
        color: #cbd5e1;
    }

    .theme-toggle:hover {
        color: #fff;
        background: #334155;
    }

    .store-badge {
        background: rgba(16, 185, 129, 0.15);
        border-color: rgba(16, 185, 129, 0.3);
        color: #10b981;
    }
}
