/* ============================================================
   JamieGPT – Unified Demo Interface CSS
   Responsive design for both Desktop and Mobile.
   ============================================================ */

:root {
    --primary: #1E293B;
    --accent: #3B82F6;
    --accent-dark: #2563EB;
    --accent-glow: rgba(59, 130, 246, 0.18);
    --bg: #F1F5F9;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --text: #1E293B;
    --text-muted: #64748B;
    --bot-bubble-bg: #FFFFFF;
    --user-bubble-bg: #3B82F6;
    --user-bubble-tx: #FFFFFF;
    --online-green: #10B981;
    --header-h: 70px;
    --input-bar-h: 80px;
    --radius-bubble: 18px;
    --font: 'Outfit', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    background: var(--bg);
    font-family: var(--font);
    color: var(--text);
    overflow: hidden;
}

.demo-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    background: var(--surface);
    position: relative;
}

/* Header */
.demo-header {
    background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    color: white;
    padding: 0 20px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
}

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

.header-avatar-wrap { position: relative; }
.header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--online-green);
    border-radius: 50%;
    border: 2px solid #1E293B;
}

.header-name { 
    font-size: 18px; 
    font-weight: 700; 
    line-height:1.2;
    margin-bottom: 2px;
}
.header-status { 
    font-size: 13px; 
    opacity: 0.9; 
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.header-btn:hover { background: rgba(255,255,255,0.2); }
.report-btn:hover { color: #FCD34D; }

/* Messages */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #F8FAFC;
}

.msg-row { display: flex; align-items: flex-end; gap: 10px; }
.bot-row { justify-content: flex-start; }
.user-row { justify-content: flex-end; }

.bubble-avatar { width: 34px; height: 34px; border-radius: 50%; }

.bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--radius-bubble);
    font-size: 16px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

.bot-bubble { background: white; border-bottom-left-radius: 4px; }
.user-bubble { background: var(--accent); color: white; border-bottom-right-radius: 4px; }

/* Bot-message wrapper used when the bubble needs an action bar beneath it */
.bot-bubble-wrap { display: flex; flex-direction: column; gap: 6px; max-width: 75%; }
.bot-bubble-wrap .bubble { max-width: 100%; }

.message-actions { display: flex; gap: 8px; padding-left: 4px; }

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
}
.action-btn:hover { background: #F8FAFC; border-color: var(--accent); color: var(--accent); }
.action-btn svg { width: 14px; height: 14px; }
.action-btn.success { background: #DCFCE7; border-color: #16A34A; color: #166534; }

/* ── Rich formatting inside bot bubbles (report output, etc.) ────────── */
.bot-bubble .chat-h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 2px 0 8px;
    color: #0F172A;
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.bot-bubble .chat-h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--accent);
    line-height: 1.3;
}
.bot-bubble .chat-h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 10px 0 4px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bot-bubble .chat-h1:first-child,
.bot-bubble .chat-h2:first-child,
.bot-bubble .chat-h3:first-child { margin-top: 0; }
.bot-bubble strong { font-weight: 600; color: #0F172A; }
.bot-bubble em { color: #64748B; font-style: italic; }
.bot-bubble .chat-link { color: var(--accent); text-decoration: underline; }

/* Inline action links (e.g. "Full recap →" in the digest) — look like a
   button-styled link rather than a plain text link. */
.bot-bubble .chat-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-top: 2px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.bot-bubble .chat-action:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px -2px rgba(59, 130, 246, 0.4);
}

/* Clickable quick-pick tiles below a bot message (e.g. /report group + timeframe picker) */
.quick-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 4px;
    margin-top: 4px;
}
.quick-pick {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2),
                box-shadow 0.18s ease,
                border-color 0.18s ease,
                background 0.18s ease,
                color 0.18s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    user-select: none;
}
.quick-pick:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent) 0%, #2563EB 100%);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -4px rgba(59, 130, 246, 0.45),
                0 2px 4px rgba(15, 23, 42, 0.08);
}
.quick-pick:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 6px -2px rgba(59, 130, 246, 0.35);
}
.quick-pick:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
}
.quick-pick.selected {
    background: linear-gradient(135deg, var(--accent) 0%, #2563EB 100%);
    border-color: var(--accent);
    color: white;
    opacity: 1;
    box-shadow: 0 4px 12px -3px rgba(59, 130, 246, 0.45);
}

/* Dropdown mode for group picker (many options) */
.quick-picks.dropdown-mode {
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
.quick-picks.dropdown-mode .quick-pick.featured {
    background: linear-gradient(135deg, var(--accent) 0%, #2563EB 100%);
    border-color: var(--accent);
    color: white;
    width: 100%;
    justify-content: center;
    box-shadow: 0 2px 8px -2px rgba(59, 130, 246, 0.4);
}
.quick-picks.dropdown-mode .quick-pick.featured:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px -3px rgba(59, 130, 246, 0.5);
}
.group-dropdown,
.digest-dropdown {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    background: white;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.group-dropdown:focus,
.digest-dropdown:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.group-dropdown:disabled,
.digest-dropdown:disabled {
    opacity: 0.4;
    cursor: default;
}
/* Subtle blue tint marks the digest dropdown as the shortcut route,
   replacing the old gradient-filled "featured" button. */
.digest-dropdown {
    border-color: var(--accent);
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    color: #1E40AF;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.15);
}

/* Input */
.input-bar {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--border);
}

.input-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #F1F5F9;
    padding: 10px 10px 10px 18px;
    border-radius: 24px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    max-height: 150px;
    outline: none;
    padding: 4px 0;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.close-modal { font-size: 24px; border: none; background: none; cursor: pointer; }

.modal-body textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    margin-top: 10px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-secondary { background: #E2E8F0; color: var(--text); border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; }

.hidden { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -0.5px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    display: inline-block !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* Typing */
.dot { width: 6px; height: 6px; background: #94A3B8; border-radius: 50%; display: inline-block; margin: 0 2px; animation: bounce 1.4s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Mobile optimization */
@media (max-width: 600px) {
    .demo-app { 
        max-width: 100%; 
        height: 100vh;
        height: -webkit-fill-available;
        height: 100dvh; 
    }
    .bubble { max-width: 85%; }
    .header-inner { height: 72px; gap: 8px; }
    .header-name { font-size: 16px; }
    .header-status { font-size: 11px; line-height: 1.2; }
    .header-avatar { width: 40px; height: 40px; }
    .auth-user-bar { display: none !important; }
    .input-bar { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
