/* ============================================================
   Logo — Voice Agent Styles
   ============================================================ */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #252536;
    --bg-hover: #2e2e44;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6868808c;
    --accent: #6c63ff;
    --accent-hover: #7d75ff;
    --accent-glow: rgba(108, 99, 255, 0.3);
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --user-bubble: #2a2a42;
    --assistant-bubble: #1e1e32;
    --border: #2a2a3e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;                            /* fallback */
    height: calc(var(--vh, 1vh) * 100);       /* JS-calculated real viewport */
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
}

@supports (height: 100dvh) {
    #app {
        height: 100dvh;
    }
}

/* ---- Header ---- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.build-label {
    font-size: 0.65rem;
    color: var(--text-muted, #888);
    font-weight: 400;
    opacity: 0.45;
    user-select: none;
    margin-left: 6px;
    align-self: baseline;
}

.agent-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    width: 100%;
}

.agent-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.agent-select:focus {
    border-color: var(--accent);
}

/* ---- Auth UI ---- */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-area {
    display: flex;
    align-items: center;
}

/* ---- Agent Select Row ---- */
.agent-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.agent-select-row .agent-select {
    flex: 1;
}

.btn-login {
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-login:hover {
    background: var(--accent-hover);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 0.82rem;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-logout:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* ---- Agent Banner (removed — emotion display now in select row) ---- */

/* ---- Emotion Display ---- */
.emotion-display {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
    flex-shrink: 0;
}

.emotion-emoji {
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.emotion-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emotion-display.emotion-pop .emotion-emoji {
    animation: emotion-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emotion-bounce {
    0%   { transform: scale(0.5); opacity: 0.5; }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- Chat Area ---- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    color: var(--text-secondary);
    text-align: center;
    gap: 8px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.empty-state .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Message Bubbles ---- */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    line-height: 1.5;
    animation: fadeIn 0.2s ease;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--assistant-bubble);
    border-bottom-left-radius: 4px;
}

.message .role-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.message.user .role-label {
    color: var(--accent);
}

.message.assistant .role-label {
    color: var(--success);
}

.message.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    padding: 6px 12px;
}

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

/* ---- Status Bar ---- */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-indicator.connected {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-indicator.connecting {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.status-indicator.error {
    background: var(--danger);
}

.status-indicator.speaking {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse 0.6s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Controls ---- */
.controls {
    padding: 12px 20px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.text-input:focus {
    border-color: var(--accent);
}

.text-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

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

.btn-send {
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    width: 42px;
    height: 42px;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-mic {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-mic:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-mic.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 36px var(--accent-glow); }
}

.hidden {
    display: none !important;
}

/* ---- Scrollbar ---- */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    #app {
        max-width: 100%;
    }

    .header {
        padding: 10px 14px;
    }

    .header-right {
        gap: 8px;
    }

    .user-name {
        max-width: 100px;
        font-size: 0.75rem;
    }

    .btn-login {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .btn-logout {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .user-info {
        gap: 6px;
    }

    /* Agent select row */
    .agent-select-row {
        padding: 6px 14px;
    }

    .agent-select {
        font-size: 0.82rem;
        padding: 7px 10px;
    }

    /* Agent banner compact (removed) */

    .emotion-display {
        padding: 4px 10px;
        gap: 4px;
    }

    .emotion-emoji {
        font-size: 1.2rem;
    }

    .emotion-label {
        font-size: 0.65rem;
    }

    /* Chat */
    .chat-area {
        padding: 14px;
    }

    .message {
        max-width: 90%;
        padding: 10px 12px;
        font-size: 0.88rem;
    }

    /* Bottom controls — pushed above Android nav bar */
    .controls {
        padding: 8px 14px;
        padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    }

    .input-row {
        gap: 6px;
    }

    .text-input {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .btn-send {
        width: 38px;
        height: 38px;
    }

    .btn-mic {
        width: 38px;
        height: 38px;
    }

    .status-bar {
        padding: 4px 14px;
        font-size: 0.68rem;
        flex-shrink: 0;
    }
}


/* ============================================================
   Side Panel (History)
   ============================================================ */

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

.side-panel.hidden {
    display: none;
}

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

.side-panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.side-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.side-panel-empty,
.side-panel-loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 32px 16px;
    font-size: 0.85rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-date {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.history-id {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: monospace;
}


/* ============================================================
   Overlay / Dialog (Settings)
   ============================================================ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay.hidden {
    display: none;
}

.dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 420px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

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

.dialog-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dialog-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.field-textarea,
.field-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 10px 12px;
    resize: vertical;
}

.field-textarea:focus,
.field-select:focus {
    outline: none;
    border-color: var(--accent);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}


/* ============================================================
   My Prompt Editor
   ============================================================ */

.dialog-large {
    width: 560px;
    max-width: 92vw;
}

.myprompt-description {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.myprompt-textarea {
    min-height: 220px;
    line-height: 1.6;
}

.myprompt-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}


/* ============================================================
   Session Divider
   ============================================================ */

.session-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.session-divider .build-time {
    font-size: 0.65rem;
    opacity: 0.7;
    text-transform: none;
    letter-spacing: normal;
}

.session-divider::before,
.session-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}


