/* ==========================================================================
   PlotWeaver Conversational Agent — Responsive Design System & Stylesheet
   ========================================================================== */

:root {
    --bg-main: #060911;
    --bg-surface: #0c1322;
    --bg-card: #111c33;
    --bg-card-hover: #162442;
    --border-color: #1d2c4e;
    --border-light: rgba(255, 255, 255, 0.08);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --primary-blue: #3b82f6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-rose: #f43f5e;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.app-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

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

.brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: var(--text-main);
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.header-badges {
    display: flex;
    align-items: center;
    gap: 14px;
}

.live-pill {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all 0.3s ease;
}

.live-dot {
    width: 7px;
    height: 7px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    animation: blink-pulse 1.4s infinite ease-in-out;
}

@keyframes blink-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.8); }
}

.lang-selector-pills {
    display: flex;
    gap: 5px;
}

.lang-selector-pills .badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--text-muted);
}

.lang-selector-pills .badge.active {
    border-color: var(--primary-blue);
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */
.app-workspace {
    display: grid;
    grid-template-columns: 1fr 450px;
    min-height: calc(100vh - 61px);
    width: 100%;
}

/* ==========================================================================
   Voice Interaction Stage (Left)
   ========================================================================== */
.stage-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-right: 1px solid var(--border-color);
    background: radial-gradient(circle at 50% 30%, rgba(59, 130, 246, 0.08) 0%, transparent 65%);
    gap: 20px;
    overflow-y: auto;
}

.orb-container {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-top: 8px;
}

.orb {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.2);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.12);
}

.clay-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.orb.speaking {
    transform: scale(1.15);
    background: linear-gradient(135deg, #065f46, #10b981);
    box-shadow: 0 0 80px rgba(16, 185, 129, 0.7);
    animation: orb-speaking-pulse 1.2s infinite ease-in-out;
}

.orb.listening {
    transform: scale(1.06);
    background: linear-gradient(135deg, #92400e, #f59e0b);
    box-shadow: 0 0 70px rgba(245, 158, 11, 0.6);
    animation: orb-listening-pulse 1s infinite ease-in-out;
}

.orb.thinking {
    transform: scale(0.95);
    background: linear-gradient(135deg, #5b21b6, #8b5cf6);
    box-shadow: 0 0 70px rgba(139, 92, 246, 0.6);
}

@keyframes orb-speaking-pulse {
    0%, 100% { transform: scale(1.12); box-shadow: 0 0 65px rgba(16, 185, 129, 0.6); }
    50% { transform: scale(1.22); box-shadow: 0 0 90px rgba(16, 185, 129, 0.85); }
}

@keyframes orb-listening-pulse {
    0%, 100% { transform: scale(1.04); }
    50% { transform: scale(1.12); }
}

.status-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.status-heading {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.status-description {
    font-size: 13px;
    color: var(--text-muted);
}

/* Microphone Visualizer */
.mic-visualizer {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    background: var(--bg-card);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.mic-icon { font-size: 13px; }
.mic-track {
    width: 110px;
    height: 6px;
    background: #1e293b;
    border-radius: 3px;
    overflow: hidden;
}

.mic-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-emerald);
    transition: width 0.05s ease-out;
}

.mic-val {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 32px;
}

/* Subtitles Banner */
.subtitles-banner {
    width: 100%;
    max-width: 620px;
    min-height: 105px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.subtitles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.speaker-tag {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.lang-tag {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 6px;
    text-transform: uppercase;
}

.lang-tag.yo { background: #854d0e; color: #fef08a; }
.lang-tag.pcm { background: #065f46; color: #a7f3d0; }
.lang-tag.ha { background: #831843; color: #fbcfe8; }
.lang-tag.ig { background: #581c87; color: #e9d5ff; }
.lang-tag.en { background: #1e3a8a; color: #bfdbfe; }

.subtitles-body {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: #f1f5f9;
    min-height: 24px;
}

.subtitles-body.interim {
    color: var(--accent-cyan);
    font-style: italic;
    font-weight: 500;
}

/* Quick Chips */
.quick-chips-wrapper {
    width: 100%;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chips-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.prompt-chip {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
}

.prompt-chip:hover {
    color: var(--text-main);
    border-color: var(--primary-blue);
    background: var(--bg-card);
    transform: translateY(-1px);
}

/* Action Bar */
.action-bar {
    width: 100%;
    max-width: 620px;
    display: flex;
    justify-content: center;
    gap: 14px;
    align-items: center;
}

.btn-call {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 50px;
    flex: 1;
    max-width: 260px;
    justify-content: center;
}

.btn-call:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(16, 185, 129, 0.6);
}

.btn-call.active {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
}

.btn-mute {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    min-height: 50px;
}

.btn-mute:hover:not(:disabled) {
    background: var(--bg-surface);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.btn-mute:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-mute.muted {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Notice */
.permission-notice {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fde68a;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 620px;
}

/* ==========================================================================
   Sidebar & Chat Feed (Right)
   ========================================================================== */
.sidebar-section {
    background: var(--bg-surface);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.card-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.telemetry-badge, .chat-count-badge {
    font-size: 10.5px;
    font-weight: 700;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Waterfall Body */
.waterfall-body {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.wf-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.wf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.wf-dot.asr { background: var(--accent-amber); }
.wf-dot.brain { background: var(--accent-purple); }
.wf-dot.search { background: var(--accent-cyan); }
.wf-dot.tts { background: var(--accent-emerald); }

.wf-name { color: var(--text-muted); font-weight: 600; flex: 1; margin-left: 4px; }
.wf-time { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text-main); }

.wf-bar-wrapper {
    height: 8px;
    background: #1e293b;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    margin-top: 4px;
}

.wf-segment { height: 100%; transition: width 0.3s ease; }
.wf-segment.asr { background: var(--accent-amber); }
.wf-segment.brain { background: var(--accent-purple); }
.wf-segment.search { background: var(--accent-cyan); }
.wf-segment.tts { background: var(--accent-emerald); }

.wf-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 2px;
}

.wf-total-label { font-size: 11.5px; font-weight: 800; color: var(--text-main); }
.wf-total-val { font-size: 16px; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: #38bdf8; }

/* Chat Stream Container */
.chat-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-stream {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 6px;
    scroll-behavior: smooth;
}

.chat-stream::-webkit-scrollbar { width: 5px; }
.chat-stream::-webkit-scrollbar-track { background: transparent; }
.chat-stream::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.chat-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    width: 100%;
}

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

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar.user { background: #2563eb; color: white; }
.avatar.assistant { background: #059669; color: white; }

.bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 84%;
}

.chat-row.user .bubble-wrap {
    align-items: flex-end;
}

.bubble-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sender-name { font-weight: 700; color: #cbd5e1; }
.lang-pill {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
}
.lang-pill.yo { background: #854d0e; color: #fef08a; }
.lang-pill.pcm { background: #065f46; color: #a7f3d0; }
.lang-pill.ha { background: #831843; color: #fbcfe8; }
.lang-pill.ig { background: #581c87; color: #e9d5ff; }
.lang-pill.en { background: #1e3a8a; color: #bfdbfe; }

.bubble-content {
    padding: 11px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-row.user .bubble-content {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.chat-row.assistant .bubble-content {
    background: #182236;
    color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 960px) {
    .app-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }
    .stage-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px 16px;
    }
    .sidebar-section {
        padding: 20px 16px;
    }
    .btn-call {
        max-width: 100%;
    }
    .chat-stream {
        max-height: 500px;
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 10px 14px;
    }
    .brand-title {
        font-size: 15px;
    }
    .header-badges {
        gap: 8px;
    }
    .lang-selector-pills {
        display: none;
    }
    .stage-section {
        padding: 16px 12px;
        gap: 16px;
    }
    .orb-container {
        width: 130px;
        height: 130px;
    }
    .orb {
        width: 95px;
        height: 95px;
    }
    .subtitles-banner {
        padding: 12px 14px;
        min-height: 90px;
    }
    .subtitles-body {
        font-size: 13.5px;
    }
    .btn-call {
        padding: 14px 20px;
        font-size: 15px;
    }
}
