/* North Health GPT — Stylesheet (v3.0) */
/* Adjustments: No label headers | Dots-only loading | Clean bubbles | ⚠️ error style */

:root {
    --bg-main:           #FFFFFF;
    --bg-header:         #0F172A;
    --text-header:       #FFFFFF;
    --accent-green:      #059669;
    --accent-green-hover:#047857;
    --accent-red:        #DC2626;
    --text-primary:      #1E293B;
    --text-secondary:    #64748B;
    --bubble-user:       #ECFDF5;
    --bubble-assistant:  #F1F5F9;
    --border-color:      #E2E8F0;
    --radius-pill:       9999px;
    --radius-card:       12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

html {
    height: 100%;
}

body {
    background-color: #F8FAFC;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* UNICEF Evaluation Banner */
.eval-strip {
    background-color: #FEF3C7;
    color: #92400E;
    border-bottom: 1px solid #FCD34D;
    padding: 8px 16px;
    font-size: 0.85rem;
    text-align: center;
}

/* Main Container */
.app-container {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    background-color: var(--bg-main);
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

/* App Header */
.app-header {
    background-color: var(--bg-header);
    color: var(--text-header);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.8rem;
    background: rgba(255,255,255,0.1);
    padding: 6px;
    border-radius: 8px;
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.header-brand .subtitle {
    font-size: 0.8rem;
    color: #94A3B8;
}

.header-status {
    font-size: 0.8rem;
    color: #34D399;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #34D399;
    border-radius: 50%;
    display: inline-block;
}

/* Mode Switcher Tabs */
.mode-switcher-container {
    padding: 12px 20px;
    background-color: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.pill-tabs {
    display: flex;
    background: #E2E8F0;
    padding: 4px;
    border-radius: var(--radius-pill);
    gap: 4px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: #FFFFFF;
    color: var(--accent-green);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.tab-icon {
    width: 16px;
    height: 16px;
}

/* Chat Viewport — scrolls internally, page never scrolls */
.chat-viewport {
    flex: 1;
    min-height: 0;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.welcome-card {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-card);
    padding: 16px;
    margin-bottom: 12px;
}

.welcome-card h2 {
    font-size: 1.05rem;
    color: #166534;
    margin-bottom: 6px;
}

.welcome-card p {
    font-size: 0.88rem;
    color: #15803D;
    line-height: 1.4;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Message Bubbles — no label headers (Adjustment 2) ────────────────────── */
.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.5;
}

.message-bubble.user {
    align-self: flex-end;
    background-color: var(--bubble-user);
    border: 1px solid #A7F3D0;
    color: #065F46;
    border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
    align-self: flex-start;
    background-color: var(--bubble-assistant);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* ── ⚠️ Error bubble (replaces "Tsarikan Tsaro") ──────────────────────────── */
.message-bubble.system {
    align-self: center;
    background-color: #FFFBEB;
    border: 1px solid #FCD34D;
    color: #B45309;
    font-size: 0.85rem;
    max-width: 90%;
}

/* ── Adjustment 1: Dots-only loading bubble — compact, no text ─────────────── */
.loading-bubble {
    padding: 10px 14px !important;
    width: auto;
    min-width: unset;
    max-width: fit-content;
}

/* ── Animated Dots ─────────────────────────────────────────────────────────── */
.dots-pulse {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.dots-pulse span {
    width: 9px;
    height: 9px;
    background-color: var(--accent-green);
    border-radius: 50%;
    display: inline-block;
    animation: dotsBouncing 1.4s infinite ease-in-out both;
}

.dots-pulse span:nth-child(1) { animation-delay: -0.32s; }
.dots-pulse span:nth-child(2) { animation-delay: -0.16s; }
.dots-pulse span:nth-child(3) { animation-delay:  0s;    }

@keyframes dotsBouncing {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.3; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ── Voice Audio Bubble (Adjustment 4) ────────────────────────────────────── */
.voice-audio-bubble {
    min-width: 260px;
}

.audio-player-container audio {
    width: 100%;
    height: 40px;
    outline: none;
    margin-bottom: 2px;
}

/* ── PHC Referral Button ───────────────────────────────────────────────────── */
.referral-container {
    margin-top: 10px;
}

.hospital-referral-btn {
    display: inline-block;
    background-color: #DC2626;
    color: #FFFFFF;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background-color 0.2s;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}

.hospital-referral-btn:hover {
    background-color: #B91C1C;
}

/* ── Shortcut Cards ────────────────────────────────────────────────────────── */
.shortcuts-section {
    padding: 12px 20px;
    background: #FAFAFA;
    border-top: 1px solid var(--border-color);
}

.shortcuts-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.shortcuts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shortcut-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.shortcut-card:hover {
    border-color: var(--accent-green);
    background: #F0FDF4;
}

.shortcut-card small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ── Input Panels ──────────────────────────────────────────────────────────── */
.input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: #FFFFFF;
}

.input-panel {
    display: none;
}

.input-panel.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Mic Controls */
.mic-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.mic-button {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background-color: var(--accent-green);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
    transition: transform 0.2s, background-color 0.2s;
    z-index: 2;
    position: relative;
}

.mic-button:hover {
    background-color: var(--accent-green-hover);
    transform: scale(1.04);
}

.mic-button.recording {
    background-color: var(--accent-red);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
}

.mic-svg {
    width: 28px;
    height: 28px;
}

.recording-pulse {
    position: absolute;
    top: -6px; left: -6px;
    right: -6px; bottom: -6px;
    border-radius: 50%;
    border: 3px solid var(--accent-red);
    opacity: 0;
    z-index: 1;
}

.recording-pulse.active {
    animation: pulseWave 1.5s infinite;
}

@keyframes pulseWave {
    0%   { transform: scale(1);   opacity: 0.8; }
    100% { transform: scale(1.4); opacity: 0;   }
}

.voice-status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Text Input */
.text-input-wrapper {
    display: flex;
    width: 100%;
    gap: 8px;
    background: #F8FAFC;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 6px 12px;
}

.text-input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 0.92rem;
    padding: 6px;
}

.send-button {
    background: var(--accent-green);
    color: #FFFFFF;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button svg {
    width: 18px;
    height: 18px;
}

/* App Footer */
.app-footer {
    padding: 10px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: #F1F5F9;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 480px) {
    .shortcuts-grid     { flex-direction: column; }
    .shortcut-card      { font-size: 0.75rem; padding: 6px 8px; }
    .message-bubble     { max-width: 92%; }
    .voice-audio-bubble { min-width: 220px; }
}
