/* ============================================
   SiraAI — Main Stylesheet
   A calming, professional mental health UI
   Inspired by: Stripe, Notion, Headspace, Calm
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Primary palette — calming purple-teal */
    --primary-50: #F0EEFF;
    --primary-100: #DDD9FF;
    --primary-200: #BBB3FF;
    --primary-300: #9990FF;
    --primary-400: #7E75FF;
    --primary-500: #6C63FF;
    --primary-600: #5A52D9;
    --primary-700: #4842B3;
    --primary-800: #36338C;
    --primary-900: #252366;

    /* Accent — soothing teal */
    --accent-50: #E6FAF8;
    --accent-100: #C0F2EC;
    --accent-200: #8DE8DC;
    --accent-300: #5DDECF;
    --accent-400: #4ECDC4;
    --accent-500: #3DBDB4;
    --accent-600: #2FA89F;
    --accent-700: #218E86;
    --accent-800: #14746E;
    --accent-900: #0A5A55;

    /* Neutral — warm grays */
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F7;
    --gray-200: #E8E8ED;
    --gray-300: #D1D1D8;
    --gray-400: #A1A1AB;
    --gray-500: #71717A;
    --gray-600: #52525B;
    --gray-700: #3F3F46;
    --gray-800: #27272A;
    --gray-900: #18181B;

    /* Semantic colors */
    --success: #22C55E;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;

    /* Emotion colors */
    --emotion-joy: #FFD93D;
    --emotion-sadness: #6B9BD2;
    --emotion-anger: #FF6B6B;
    --emotion-fear: #A78BFA;
    --emotion-surprise: #FB923C;
    --emotion-disgust: #84CC16;
    --emotion-neutral: #94A3B8;
    --emotion-anxiety: #C084FC;
    --emotion-love: #F472B6;
    --emotion-gratitude: #34D399;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.15);
    --shadow-glow-accent: 0 0 20px rgba(78, 205, 196, 0.15);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --navbar-height: 64px;
    --sidebar-width: 260px;
    --max-width: 1200px;
    --max-width-narrow: 680px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--primary-500); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-600); }
button { cursor: pointer; font-family: var(--font-sans); }
input, textarea, select { font-family: var(--font-sans); }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--gray-900);
}

h1 { font-size: 2.5rem; letter-spacing: -0.025em; }
h2 { font-size: 2rem; letter-spacing: -0.02em; }
h3 { font-size: 1.5rem; letter-spacing: -0.015em; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }

.display-heading {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--gray-500);
    font-weight: 400;
    line-height: 1.7;
}

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--gray-200);
    z-index: 1000;
    transition: all var(--transition-base);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--gray-900);
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.logo-accent {
    background: linear-gradient(135deg, var(--primary-500), var(--accent-400));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-link {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-link:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.nav-link.active {
    color: var(--primary-500);
    background: var(--primary-50);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    padding: var(--space-2);
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: all var(--transition-base);
}

/* --- Main Content --- */
.main-content {
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
}

/* --- Footer --- */
.app-footer {
    background: var(--gray-900);
    color: var(--gray-400);
    padding: var(--space-6) 0;
    font-size: 0.8rem;
}

.footer-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    text-align: center;
}

.ai-disclaimer {
    color: var(--gray-500);
    margin-bottom: var(--space-3);
    font-size: 0.78rem;
    line-height: 1.5;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.footer-sep {
    color: var(--gray-700);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.15), rgba(255,255,255,0));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after { opacity: 1; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.4);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateY(-1px);
    color: var(--gray-700);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-400), var(--accent-500));
    color: white;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(78, 205, 196, 0.4);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-lg {
    padding: 0.8rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--gray-800);
    background: white;
    transition: all var(--transition-base);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 120px;
    line-height: 1.7;
}

.form-error {
    font-size: 0.8rem;
    color: var(--error);
    margin-top: var(--space-1);
}

.form-helper {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: var(--space-1);
}

/* --- Cards --- */
.card {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: var(--space-6);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- Badge / Pill --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-emotion {
    background: var(--gray-100);
    color: var(--gray-700);
}

.badge-joy { background: #FFF8E1; color: #B8860B; }
.badge-sadness { background: #E3F2FD; color: #1565C0; }
.badge-anger { background: #FFEBEE; color: #C62828; }
.badge-fear { background: #F3E5F5; color: #6A1B9A; }
.badge-surprise { background: #FFF3E0; color: #E65100; }
.badge-disgust { background: #F1F8E9; color: #558B2F; }
.badge-neutral { background: #ECEFF1; color: #546E7A; }
.badge-anxiety { background: #F3E5F5; color: #7B1FA2; }
.badge-love { background: #FCE4EC; color: #C2185B; }
.badge-gratitude { background: #E8F5E9; color: #2E7D32; }

/* --- Loading States --- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: var(--space-4);
}

.loading-page .spinner {
    width: 44px;
    height: 44px;
}

.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: calc(var(--navbar-height) + var(--space-4));
    right: var(--space-4);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--primary-500);
    font-size: 0.9rem;
    min-width: 300px;
    max-width: 450px;
    animation: slideInRight 0.3s ease-out;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 var(--space-1);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: white;
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.3s var(--transition-spring);
}

.crisis-modal {
    text-align: center;
    max-width: 520px;
}

.crisis-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    color: var(--warning);
}

.crisis-modal h2 {
    margin-bottom: var(--space-3);
    font-size: 1.5rem;
}

.crisis-modal p {
    color: var(--gray-600);
    margin-bottom: var(--space-5);
}

.crisis-resources {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.crisis-resource {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.resource-label {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.resource-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-600);
}

.crisis-note {
    font-size: 0.8rem !important;
    color: var(--gray-500) !important;
}

/* --- Page Layout Helpers --- */
.page-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

.page-container-narrow {
    max-width: var(--max-width-narrow);
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

.page-header {
    margin-bottom: var(--space-8);
}

.page-header h1 {
    margin-bottom: var(--space-2);
}

.page-header .subtitle {
    max-width: 600px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-4);
    color: var(--gray-300);
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.empty-state p {
    color: var(--gray-500);
    max-width: 400px;
    margin: 0 auto var(--space-6);
}

/* --- Stat Card --- */
.stat-card {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --navbar-height: 56px;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    .display-heading { font-size: 2.25rem; }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: var(--space-4) var(--space-6);
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow-lg);
    }

    .nav-links.open { display: flex; }

    .nav-toggle { display: flex; }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-container, .page-container-narrow {
        padding: var(--space-6) var(--space-4);
    }

    .modal {
        width: 95%;
        padding: var(--space-6);
    }
}

@media (max-width: 480px) {
    .display-heading { font-size: 1.85rem; }
    .btn-lg {
        width: 100%;
        padding: 0.85rem;
    }
}
