/**
 * Shakti - Women's Helpline AI
 * Main Stylesheet
 * 
 * Color Palette:
 * - Primary: Deep Purple (#6B46C1)
 * - Accent: Soft Pink (#F8BBD9)
 * - Gold: (#D4A574)
 * - Background: Warm Cream (#FFF8F0)
 * - Text: Dark Purple (#2D1B4E)
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Colors */
    --color-primary: #6B46C1;
    --color-primary-light: #9F7AEA;
    --color-primary-dark: #4C1D95;
    --color-accent: #F8BBD9;
    --color-accent-light: #FDE8F0;
    --color-gold: #D4A574;
    --color-gold-light: #E8C9A8;
    
    /* Backgrounds */
    --bg-cream: #FFF8F0;
    --bg-white: #FFFFFF;
    --bg-gradient: linear-gradient(135deg, #FFF8F0 0%, #F5E6D8 100%);
    
    /* Text */
    --text-primary: #2D1B4E;
    --text-secondary: #5A4478;
    --text-muted: #8B7AA3;
    --text-light: #FFFFFF;
    
    /* Shadows */
    --shadow-soft: 0 4px 20px rgba(107, 70, 193, 0.1);
    --shadow-medium: 0 8px 30px rgba(107, 70, 193, 0.15);
    --shadow-glow: 0 0 20px rgba(107, 70, 193, 0.2);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Hindi text */
.hindi {
    font-family: 'Noto Sans Devanagari', sans-serif;
}

/* ============================================
   App Layout
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-white);
    box-shadow: var(--shadow-medium);
}

/* ============================================
   Header
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--text-light);
    padding: var(--space-md) var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.logo-text h1 .hindi {
    font-size: 1.2rem;
    opacity: 0.9;
}

.tagline {
    font-size: 0.85rem;
    opacity: 0.9;
}

.emergency-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pulse {
    width: 8px;
    height: 8px;
    background: #FF6B6B;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 107, 107, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}

.emergency-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ============================================
   Chat Container
   ============================================ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* ============================================
   Welcome Section
   ============================================ */
.welcome-section {
    max-width: 600px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-card {
    background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--bg-white) 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--color-accent);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    animation: float 3s ease-in-out infinite;
}

.welcome-card h2 {
    font-size: 1.75rem;
    color: var(--color-primary);
    margin-bottom: var(--space-md);
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.quick-topics {
    text-align: left;
}

.quick-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.topic-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.topic-chip {
    background: var(--bg-white);
    border: 1px solid var(--color-primary-light);
    color: var(--color-primary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.topic-chip:hover {
    background: var(--color-primary);
    color: var(--text-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

/* Helpline Cards */
.helpline-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.helpline-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(107, 70, 193, 0.1);
    transition: all var(--transition-fast);
}

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

.helpline-icon {
    font-size: 1.5rem;
}

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

.helpline-info strong {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.helpline-info a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}

/* ============================================
   Messages
   ============================================ */
.messages {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.message {
    display: flex;
    gap: var(--space-md);
    animation: fadeInUp 0.3s ease;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.user-message .message-avatar {
    background: var(--color-primary-light);
}

.assistant-message .message-avatar {
    background: var(--color-accent);
}

.message-bubble {
    max-width: 70%;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    line-height: 1.7;
}

.user-message .message-bubble {
    background: var(--color-primary);
    color: var(--text-light);
    border-bottom-right-radius: var(--radius-sm);
}

.assistant-message .message-bubble {
    background: var(--bg-white);
    border: 1px solid rgba(107, 70, 193, 0.1);
    box-shadow: var(--shadow-soft);
    border-bottom-left-radius: var(--radius-sm);
}

.message-bubble strong {
    color: var(--color-primary);
}

.user-message .message-bubble strong {
    color: var(--color-gold-light);
}

.message-bubble ul {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.message-bubble li {
    margin-bottom: var(--space-xs);
}

.phone-link {
    color: var(--color-gold);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed var(--color-gold);
}

.sources-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-md);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-accent-light);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--color-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sources-button:hover {
    background: var(--color-accent);
}

.error-message .message-bubble {
    background: #FFF0F0;
    border-color: #FFD0D0;
    color: #8B3A3A;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    color: var(--text-muted);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--color-primary-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.typing-text {
    font-size: 0.85rem;
    font-style: italic;
}

/* ============================================
   Input Area
   ============================================ */
.input-area {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-white);
    border-top: 1px solid rgba(107, 70, 193, 0.1);
}

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

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--bg-cream);
    border: 2px solid rgba(107, 70, 193, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: all var(--transition-fast);
}

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

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 150px;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.send-button:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid rgba(107, 70, 193, 0.1);
}

.modal-header h3 {
    color: var(--color-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--color-accent-light);
    color: var(--color-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: 60vh;
}

.source-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-cream);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

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

.source-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.source-details strong {
    color: var(--text-primary);
}

.source-file {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.source-relevance {
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 600;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .helpline-cards {
        grid-template-columns: 1fr;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .welcome-card {
        padding: var(--space-lg);
    }
    
    .topic-chips {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo-text h1 {
        font-size: 1.25rem;
    }
    
    .logo-icon {
        font-size: 2rem;
    }
    
    .chat-container {
        padding: var(--space-md);
    }
    
    .input-area {
        padding: var(--space-sm) var(--space-md);
    }
}
