/**
 * Narayanika Astro Reader — Timed Chat Consultation Interface (Phase 7)
 * High-Contrast, Accessible, Responsive Vanilla CSS Design System
 */

/* ==========================================================================
   1. Floating Chat Trigger Button
   ========================================================================== */
.chat-float-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #0C1322 0%, #1A2744 100%);
    color: #F8FAFC;
    border: 2px solid #D4AF37;
    border-radius: 50px;
    padding: 12px 20px;
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(12, 19, 34, 0.4), 0 0 15px rgba(212, 175, 55, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
}

.chat-float-trigger:hover,
.chat-float-trigger:focus-visible {
    background: linear-gradient(135deg, #1A2744 0%, #0C1322 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 30px -5px rgba(12, 19, 34, 0.5), 0 0 20px rgba(212, 175, 55, 0.5);
    outline: 2px solid #D4AF37;
    outline-offset: 3px;
}

.chat-float-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-float-pulse {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.chat-float-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #EF4444;
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    border: 2px solid #FFFFFF;
}

.chat-float-free-tag {
    position: absolute;
    top: -12px;
    left: 14px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: #FFFFFF;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.45);
    letter-spacing: 0.05em;
    animation: freePulse 2.2s infinite ease-in-out;
    white-space: nowrap;
    border: 1.5px solid #FFFFFF;
    text-transform: uppercase;
}

@keyframes freePulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-2px) scale(1.06); }
}

/* ==========================================================================
   2. Floating Chat Dock / Modal Panel
   ========================================================================== */
.chat-dock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 19, 34, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-dock-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.chat-dock-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 640px;
    max-height: calc(100vh - 48px);
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(12, 19, 34, 0.3), 0 0 0 1px rgba(12, 19, 34, 0.1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
}

.chat-dock-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   3. Chat Header & Astrologer Identity
   ========================================================================== */
.chat-header {
    background: linear-gradient(135deg, #0C1322 0%, #1A2744 100%);
    color: #F8FAFC;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #D4AF37;
    flex-shrink: 0;
}

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

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #D4AF37;
    color: #0C1322;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    border: 2px solid #F3D188;
    flex-shrink: 0;
    position: relative;
}

.chat-avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background-color: #10B981;
    border: 2px solid #0C1322;
    border-radius: 50%;
}

.chat-header-meta h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #F8FAFC;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-verified-badge {
    color: #38BDF8;
    font-size: 0.85rem;
    display: inline-flex;
}

.chat-header-subtitle {
    font-size: 0.75rem;
    color: #F3D188;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
}

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

.chat-header-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #F8FAFC;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.chat-header-btn:hover,
.chat-header-btn:focus-visible {
    background: rgba(255, 255, 255, 0.15);
    border-color: #D4AF37;
    color: #D4AF37;
}

/* ==========================================================================
   4. Authoritative Live Countdown Timer Bar
   ========================================================================== */
.chat-timer-bar {
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #334155;
    flex-shrink: 0;
    gap: 8px;
    min-height: 44px;
    box-sizing: border-box;
}

.chat-timer-bar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
}

.chat-timer-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-session-badge {
    font-family: var(--font-heading, monospace);
    font-weight: 700;
    color: #0F172A;
    background: #E2E8F0;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    line-height: 1;
}

.chat-timer-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: #0F172A;
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    padding: 3px 8px;
    border-radius: 12px;
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    white-space: nowrap;
    line-height: 1.2;
}

.chat-timer-display .timer-digits {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-timer-display .timer-tag {
    background: #10B981;
    color: #FFFFFF;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 2px;
}

.chat-timer-display.is-warning {
    background: #FEE2E2;
    border-color: #FCA5A5;
    color: #DC2626;
    animation: timerPulse 1s infinite alternate;
}

@keyframes timerPulse {
    from { transform: scale(1); }
    to { transform: scale(1.04); }
}

.chat-live-connect-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #FFFBEB;
    border: 1.5px solid #D97706;
    color: #B45309;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    line-height: 1.2;
}

.chat-live-connect-pill:hover {
    background: #FEF3C7;
    border-color: #B45309;
    color: #78350F;
    transform: translateY(-1px);
}

.chat-end-btn {
    background: transparent;
    color: #64748B;
    border: 1px solid #CBD5E1;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.2;
}

.chat-end-btn:hover {
    background: #FEE2E2;
    border-color: #EF4444;
    color: #DC2626;
}

/* ==========================================================================
   5. Message Stream Ledger
   ========================================================================== */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F8FAFC;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* System Notice Bubble */
.chat-msg-system {
    align-self: center;
    background: #E2E8F0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    max-width: 90%;
    text-align: center;
    margin: 4px 0;
    border: 1px solid #CBD5E1;
}

/* Message Groups */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    word-break: break-word;
}

/* Customer Message (Right-aligned) */
.chat-msg-customer {
    align-self: flex-end;
}

.chat-msg-customer .chat-bubble {
    background: #FFFBEB;
    color: #0F172A;
    border: 1.5px solid #FCD34D;
    border-radius: 14px 14px 2px 14px;
    padding: 10px 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Consultant Message (Left-aligned) */
.chat-msg-consultant {
    align-self: flex-start;
}

.chat-msg-consultant .chat-bubble {
    background: #0C1322;
    color: #F8FAFC;
    border: 1.5px solid #D4AF37;
    border-radius: 14px 14px 14px 2px;
    padding: 10px 14px;
    box-shadow: 0 4px 6px -1px rgba(12, 19, 34, 0.15);
}

/* AI Vedic Assistant Message (Left-aligned with distinctive violet/gold styling) */
.chat-msg-ai {
    align-self: flex-start;
}

.chat-msg-ai .chat-bubble,
.chat-msg-ai .chat-bubble-ai {
    background: #FAF5FF;
    color: #1E1B4B;
    border: 1.5px solid #C084FC;
    border-radius: 14px 14px 14px 2px;
    padding: 10px 14px;
    box-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1);
    line-height: 1.45;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #64748B;
    margin-top: 3px;
    padding: 0 4px;
}

.chat-msg-customer .chat-msg-meta {
    justify-content: flex-end;
}

/* ==========================================================================
   6. Alert & Status Banners
   ========================================================================== */
.chat-status-banner {
    padding: 10px 14px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-banner-warning {
    background: #FEF3C7;
    color: #92400E;
    border-bottom: 1px solid #FDE68A;
}

.chat-banner-expired {
    background: #FEE2E2;
    color: #991B1B;
    border-bottom: 1px solid #FCA5A5;
    flex-direction: column;
    text-align: center;
    gap: 6px;
    padding: 14px;
}

.chat-banner-reconnecting {
    background: #DBEAFE;
    color: #1E40AF;
    border-bottom: 1px solid #BFDBFE;
}

/* ==========================================================================
   7. Input Bar
   ========================================================================== */
.chat-input-container {
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    padding: 12px 16px;
    flex-shrink: 0;
}

.chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1.5px solid #CBD5E1;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #0F172A;
    background: #F8FAFC;
    resize: none;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-textarea:focus {
    outline: none;
    border-color: #D4AF37;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.chat-textarea:disabled {
    background: #F1F5F9;
    color: #94A3B8;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0C1322 0%, #1A2744 100%);
    color: #F8FAFC;
    border: 1.5px solid #D4AF37;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    touch-action: manipulation;
}

.chat-send-btn:hover:not(:disabled),
.chat-send-btn:focus-visible:not(:disabled) {
    background: linear-gradient(135deg, #D4AF37 0%, #B89628 100%);
    color: #0C1322;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: #E2E8F0;
    border-color: #CBD5E1;
    color: #94A3B8;
    cursor: not-allowed;
}

.chat-input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 0.72rem;
    color: #64748B;
}

/* ==========================================================================
   8. Intake / Plan Selection Modal Form
   ========================================================================== */
.chat-intake-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #FFFFFF;
}

.chat-plan-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.chat-plan-card {
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-plan-card:hover {
    border-color: #F3D188;
    background: #FFFDF9;
}

.chat-plan-card.is-selected {
    border-color: #D4AF37;
    background: #FFFBEB;
    box-shadow: 0 0 0 1px #D4AF37;
}

.chat-plan-card input[type="radio"] {
    accent-color: #D4AF37;
    margin-right: 10px;
}

.chat-plan-price {
    font-weight: 800;
    color: #0C1322;
    font-size: 1.1rem;
}

.chat-form-group {
    margin-bottom: 14px;
}

.chat-form-group label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.chat-form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #CBD5E1;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: #0F172A;
    background: #F8FAFC;
    transition: border-color 0.2s ease;
}

.chat-form-input:focus {
    outline: none;
    border-color: #D4AF37;
    background: #FFFFFF;
}

/* ==========================================================================
   9. Dedicated /chat Standalone Page Layout
   ========================================================================== */
.chat-page-section {
    padding: var(--space-xl, 40px) 0;
    background: #F8FAFC;
    min-height: calc(100vh - 200px);
}

.chat-page-card {
    max-width: 900px;
    margin: 0 auto;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 15px 35px -5px rgba(12, 19, 34, 0.15), 0 0 0 1px rgba(12, 19, 34, 0.05);
    display: flex;
    flex-direction: column;
    height: 750px;
    overflow: hidden;
}

/* ==========================================================================
   10. Responsive Mobile Layout (<600px, 320px - 414px)
   ========================================================================== */
@media (max-width: 600px) {
    .chat-float-trigger {
        bottom: 16px;
        right: 16px;
        padding: 10px 16px;
        font-size: 0.875rem;
    }

    .chat-dock-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-page-card {
        height: calc(100vh - 120px);
        border-radius: 0;
        box-shadow: none;
    }

    .chat-msg {
        max-width: 90%;
    }
}
