/**
 * Project W.E — Women Empowerment
 * Premium UI Design System
 * 
 * Version: 2.1 — Premium Edition
 * Theme: Luxurious, Empowering, Trustworthy
 */

/* ============================================
   GOOGLE FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+Devanagari:wght@400;600&display=swap');

/* ============================================
   CSS DESIGN SYSTEM — VARIABLES
   ============================================ */
:root {
    /* ═══════════════════════════════════════════
       Primary Palette — Trust & Empowerment
       ═══════════════════════════════════════════ */
    --color-primary: #0F766E;
    --color-primary-light: #14B8A6;
    --color-primary-dark: #0D5852;
    --color-primary-subtle: rgba(15, 118, 110, 0.08);

    /* Accent — Warmth & Action */
    --color-accent: #F97316;
    --color-accent-light: #FFEDD5;
    --color-accent-dark: #EA580C;

    /* Emergency — Urgency */
    --color-emergency: #DC2626;
    --color-emergency-light: #FEE2E2;

    /* Success/Safety */
    --color-success: #22C55E;
    --color-success-light: #DCFCE7;

    /* Warning */
    --color-warning: #F59E0B;
    --color-warning-light: #FEF3C7;

    /* ═══════════════════════════════════════════
       Background Colors — Light Mode
       ═══════════════════════════════════════════ */
    --bg-primary: #FAFAF9;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #F5F5F4;
    --bg-elevated: #FFFFFF;

    /* ═══════════════════════════════════════════
       Text Colors
       ═══════════════════════════════════════════ */
    --text-primary: #1C1917;
    --text-secondary: #57534E;
    --text-muted: #A8A29E;
    --text-inverse: #FFFFFF;

    /* ═══════════════════════════════════════════
       Shadows & Effects — Premium
       ═══════════════════════════════════════════ */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-glow-primary: 0 0 32px rgba(15, 118, 110, 0.25), 0 0 8px rgba(15, 118, 110, 0.15);
    --shadow-glow-accent: 0 0 32px rgba(249, 115, 22, 0.30), 0 0 8px rgba(249, 115, 22, 0.20);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-blur: blur(20px);

    /* Gradient Accents */
    --gradient-primary: linear-gradient(135deg, #0F766E 0%, #14B8A6 50%, #2DD4BF 100%);
    --gradient-accent: linear-gradient(135deg, #F97316 0%, #FB923C 50%, #FDBA74 100%);
    --gradient-premium: linear-gradient(135deg, #0F766E 0%, #14B8A6 25%, #F97316 75%, #FB923C 100%);
    --gradient-shine: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);

    /* ═══════════════════════════════════════════
       Typography
       ═══════════════════════════════════════════ */
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-hindi: 'Noto Sans Devanagari', sans-serif;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* ═══════════════════════════════════════════
       Spacing Scale
       ═══════════════════════════════════════════ */
    --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;

    /* ═══════════════════════════════════════════
       Border Radius
       ═══════════════════════════════════════════ */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 9999px;

    /* ═══════════════════════════════════════════
       Transitions
       ═══════════════════════════════════════════ */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════ */
[data-theme="dark"] {
    --color-primary: #2DD4BF;
    --color-primary-light: #5EEAD4;
    --color-primary-dark: #14B8A6;
    --color-primary-subtle: rgba(45, 212, 191, 0.10);

    --color-accent: #FB923C;
    --color-accent-light: rgba(251, 146, 60, 0.15);

    --color-emergency: #F87171;
    --color-emergency-light: rgba(248, 113, 113, 0.15);

    --bg-primary: #0C0A09;
    --bg-secondary: #1C1917;
    --bg-card: #292524;
    --bg-input: #1C1917;
    --bg-elevated: #292524;

    --text-primary: #FAFAF9;
    --text-secondary: #A8A29E;
    --text-muted: #78716C;

    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.7);
    --shadow-glow-primary: 0 0 40px rgba(45, 212, 191, 0.35), 0 0 12px rgba(45, 212, 191, 0.20);

    /* Glassmorphism Dark */
    --glass-bg: rgba(28, 25, 23, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
}

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

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: var(--leading-normal);
    font-weight: 400;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Hindi/Devanagari Typography */
.hindi {
    font-family: var(--font-hindi);
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    background-color: var(--bg-primary);
    overflow: hidden;
}

@media (min-width: 1024px) {
    .app-container {
        border-left: 1px solid rgba(0, 0, 0, 0.05);
        border-right: 1px solid rgba(0, 0, 0, 0.05);
    }

    [data-theme="dark"] .app-container {
        border-color: rgba(255, 255, 255, 0.05);
    }
}

/* ═══════════════════════════════════════════════════
   HEADER — Premium Glassmorphism
   ═══════════════════════════════════════════════════ */
.header {
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    transition: all var(--transition-base);
    position: relative;
}

/* Subtle gradient line at bottom */
.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-primary), var(--color-accent), transparent);
    opacity: 0.3;
}

[data-theme="dark"] .header {
    background: var(--glass-bg);
    border-bottom-color: var(--glass-border);
}

.header-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow-primary);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.logo-icon:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
}

.logo-icon::before {
    content: 'W';
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.logo-icon::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-shine);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.logo-text h1 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.logo-text h1 .we-highlight {
    color: var(--color-primary);
}

.tagline {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-top: 2px;
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Theme Toggle */
.theme-toggle-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    transform: rotate(15deg);
}

/* Purple Heart Button — Header */
.heart-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(147, 51, 234, 0.1);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    position: relative;
}

.heart-button::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(147, 51, 234, 0.3);
    animation: heart-pulse 2s ease-in-out infinite;
}

.heart-button:hover {
    transform: scale(1.15);
    background: rgba(147, 51, 234, 0.2);
}

.heart-button:hover::before {
    animation-duration: 1s;
}

@keyframes heart-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Welcome Card Heart Button */
.welcome-heart-btn {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.15), rgba(249, 115, 22, 0.1));
    border-radius: var(--radius-xl);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-base);
    animation: float 4s ease-in-out infinite;
}

.welcome-heart-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: var(--radius-xl);
    border: 2px dashed rgba(147, 51, 234, 0.4);
    animation: rotate-slow 20s linear infinite;
}

.welcome-heart-btn:hover {
    transform: scale(1.1) translateY(-4px);
    box-shadow: 0 12px 32px rgba(147, 51, 234, 0.25);
}

.welcome-heart-btn:hover::after {
    border-color: rgba(147, 51, 234, 0.6);
    animation-duration: 8s;
}

/* Emergency Badge */
.emergency-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-emergency-light);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid rgba(220, 38, 38, 0.2);
    transition: all var(--transition-fast);
}

.emergency-badge:hover {
    transform: scale(1.02);
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.15);
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: var(--color-emergency);
    border-radius: var(--radius-full);
    animation: pulse-emergency 1.5s infinite;
}

@keyframes pulse-emergency {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

.emergency-link {
    color: var(--color-emergency);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--text-sm);
    letter-spacing: 0.02em;
}

[data-theme="dark"] .emergency-link {
    color: #F87171;
}

/* ═══════════════════════════════════════════════════
   CHAT CONTAINER
   ═══════════════════════════════════════════════════ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    scroll-behavior: smooth;
    background: var(--bg-primary);
}

/* Custom Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════
   WELCOME SECTION
   ═══════════════════════════════════════════════════ */
.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 75vh;
    gap: var(--space-8);
    animation: fadeIn 0.6s ease-out;
    padding: var(--space-4) 0;
}

.welcome-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: var(--space-12) var(--space-8);
    border-radius: var(--radius-2xl);
    text-align: center;
    max-width: 580px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.welcome-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(15, 118, 110, 0.1);
}

[data-theme="dark"] .welcome-card {
    border-color: var(--glass-border);
    box-shadow: var(--shadow-xl), 0 0 80px rgba(45, 212, 191, 0.08);
}

/* Premium gradient border effect */
.welcome-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-premium);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

/* Subtle inner glow */
.welcome-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 120px;
    background: radial-gradient(ellipse at center top, var(--color-primary-subtle), transparent 70%);
    pointer-events: none;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: linear-gradient(135deg, var(--color-primary-subtle), var(--color-accent-light));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    position: relative;
    animation: float 4s ease-in-out infinite;
}

.welcome-icon::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: var(--radius-xl);
    border: 2px dashed var(--color-primary);
    opacity: 0.3;
    animation: rotate-slow 20s linear infinite;
}

@keyframes rotate-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-card h2 {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.welcome-card h2 span {
    color: var(--color-primary);
}

/* Stylish W.E brand in heading — Iconic Symbol Design */
.we-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F766E 0%, #14B8A6 40%, #9333EA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: 0.05em;
    position: relative;
    padding: 0 4px;
}

/* Subtle embracing underline — represents protection */
.we-brand::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120%;
    height: 8px;
    background: radial-gradient(ellipse at center, rgba(147, 51, 234, 0.2), transparent 70%);
    border-radius: 50%;
}

/* Gentle glow aura — calming presence */
.we-brand::after {
    content: 'W.E';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0F766E, #9333EA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: blur(8px);
    opacity: 0.4;
    z-index: -1;
}

/* Heart hint text */
.heart-hint {
    font-size: var(--text-sm);
    color: var(--color-primary);
    font-weight: 500;
    margin-bottom: var(--space-4);
    opacity: 0.8;
    animation: gentle-pulse 3s ease-in-out infinite;
}

@keyframes gentle-pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Welcome subtitle */
.welcome-subtitle {
    font-size: var(--text-lg);
    color: var(--color-primary);
    font-weight: 500;
    font-style: italic;
    margin-bottom: var(--space-3) !important;
}

.welcome-card>p {
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-6);
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

/* Quick Topics */
.quick-topics {
    width: 100%;
}

.quick-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    display: block;
    font-weight: 500;
}

.topic-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
}

.topic-chip {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-family: var(--font-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    overflow: hidden;
}

.topic-chip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.topic-chip:hover {
    border-color: var(--color-primary);
    color: var(--text-inverse);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), var(--shadow-glow-primary);
}

.topic-chip:hover::before {
    opacity: 1;
}

.topic-chip:hover>* {
    position: relative;
    z-index: 1;
}

.topic-chip:active {
    transform: translateY(0);
}

/* Helpline Cards */
.helpline-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
    width: 100%;
    max-width: 700px;
}

.helpline-card {
    background: var(--bg-card);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 180px;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.helpline-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.helpline-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    font-size: 1.3rem;
    flex-shrink: 0;
}

.helpline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.helpline-info strong {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.helpline-info a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--text-lg);
    transition: color var(--transition-fast);
}

.helpline-info a:hover {
    color: var(--color-primary);
}

/* ═══════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════ */
.messages {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding-bottom: var(--space-8);
}

.message {
    display: flex;
    gap: var(--space-3);
    max-width: 85%;
    animation: slideUp 0.3s ease-out;
}

.assistant-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    font-weight: 600;
}

.assistant-message .message-avatar {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
}

.assistant-message .message-avatar::before {
    content: 'W';
}

.user-message .message-avatar {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.user-message .message-avatar::before {
    content: '👤';
    font-size: 0.9rem;
}

.message-bubble {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    position: relative;
}

.assistant-message .message-bubble {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .assistant-message .message-bubble {
    border-color: rgba(255, 255, 255, 0.06);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: var(--text-inverse);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.error-message .message-bubble {
    border: 1px solid var(--color-emergency);
    background: var(--color-emergency-light);
    color: var(--text-primary);
}

.message-bubble strong {
    font-weight: 600;
}

.phone-link {
    color: var(--color-primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.user-message .phone-link {
    color: var(--text-inverse);
}

/* Sources Badge */
.sources-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-input);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    font-family: var(--font-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sources-button:hover {
    background: var(--color-primary);
    color: var(--text-inverse);
    border-color: var(--color-primary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-left: calc(36px + var(--space-3));
    padding: var(--space-2) 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    opacity: 0.6;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.typing-text {
    margin-left: var(--space-2);
}

/* ═══════════════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════════════ */
.input-area {
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

[data-theme="dark"] .input-area {
    border-top-color: rgba(255, 255, 255, 0.06);
}

.input-form {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: var(--bg-input);
    border-radius: var(--radius-xl);
    border: 2px solid transparent;
    padding: var(--space-2);
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    background: var(--bg-card);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow-primary);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-family: var(--font-primary);
    resize: none;
    max-height: 150px;
    min-height: 24px;
    outline: none;
    color: var(--text-primary);
    line-height: var(--leading-normal);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-button {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: var(--text-inverse);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow-primary);
}

.send-button:active:not(:disabled) {
    transform: scale(0.98);
}

.send-button:disabled {
    background: var(--text-muted);
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.send-button svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.input-hint::before {
    content: '🔒';
    font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════
   SOURCES MODAL
   ═══════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.modal-overlay[style*="display: flex"] {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    padding: var(--space-8);
    border-radius: var(--radius-2xl);
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(24px) scale(0.96);
    transition: transform var(--transition-base);
}

.modal-overlay[style*="display: flex"] .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.modal-close {
    width: 36px;
    height: 36px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-full);
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-emergency-light);
    color: var(--color-emergency);
}

.source-item {
    padding: var(--space-4);
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
    transition: all var(--transition-fast);
}

.source-item:hover {
    background: var(--color-primary-subtle);
}

.source-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.source-details {
    flex: 1;
    min-width: 0;
}

.source-details strong {
    display: block;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-1);
    word-break: break-word;
}

.source-file {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: block;
    margin-bottom: var(--space-2);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-relevance {
    font-size: var(--text-xs);
    color: var(--color-primary);
    font-weight: 600;
    background: var(--color-primary-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* ═══════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════ */

/* Tablets & Large Phones */
@media (max-width: 768px) {
    :root {
        --text-base: 0.9375rem;
    }

    .header {
        padding: var(--space-3) var(--space-4);
    }

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

    .logo-text h1 {
        font-size: var(--text-lg);
    }

    .tagline {
        display: none;
    }

    .welcome-card {
        padding: var(--space-6) var(--space-4);
        margin: 0 var(--space-2);
    }

    .welcome-card h2 {
        font-size: var(--text-xl);
    }

    .topic-chip {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }

    .helpline-cards {
        gap: var(--space-3);
    }

    .helpline-card {
        min-width: calc(50% - var(--space-2));
        padding: var(--space-3);
    }

    .message {
        max-width: 92%;
    }

    .input-area {
        padding: var(--space-3) var(--space-4);
    }
}

/* Small Phones */
@media (max-width: 480px) {
    .header-content {
        gap: var(--space-2);
    }

    .emergency-badge {
        padding: var(--space-1) var(--space-2);
    }

    .emergency-link {
        font-size: var(--text-xs);
    }

    .welcome-section {
        min-height: auto;
        padding: var(--space-4) 0;
        gap: var(--space-4);
    }

    .welcome-icon {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }

    .helpline-card {
        min-width: 100%;
    }

    .modal-content {
        padding: var(--space-5);
        margin: var(--space-4);
        max-height: 90vh;
    }
}

/* Tall Phones (notch area) */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: max(var(--space-4), env(safe-area-inset-top));
    }

    .input-area {
        padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}