/* ============================================
   Helm — Archon Mobile Shell
   Dark premium theme, mobile-first
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a28;
    --bg-bubble-user: #2a2a3e;
    --bg-bubble-agent: #16162a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --border: #22223a;
    --accent-gene: #4A9EFF;
    --accent-worf: #DC3545;
    --accent-neelix: #FF8C00;
    --accent-current: var(--accent-gene);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-glow: 0 0 20px rgba(74, 158, 255, 0.15);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
}

/* ---- Agent Bar ---- */

#agent-bar {
    display: flex;
    align-items: center;
    padding: calc(var(--safe-top) + 8px) 12px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    gap: 8px;
    z-index: 10;
}

#agent-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

#agent-tabs::-webkit-scrollbar { display: none; }

.agent-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.agent-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.agent-tab.active {
    background: var(--accent-current);
    color: #fff;
    border-color: var(--accent-current);
    box-shadow: 0 0 12px color-mix(in srgb, var(--accent-current) 30%, transparent);
}

.agent-tab .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

#menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all var(--transition);
}

#menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ---- Chat Window ---- */

#chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.5;
    animation: fadeSlideIn 0.25s ease-out;
    word-wrap: break-word;
}

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

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

.message .agent-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-current);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.message .timestamp {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.message .audio-player {
    margin-top: 8px;
}

.message .audio-player audio {
    width: 100%;
    height: 36px;
    border-radius: 8px;
}

/* Typing indicator */
#typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

#typing-indicator.hidden { display: none; }

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* ---- Input Bar ---- */

#input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px calc(var(--safe-bottom) + 10px);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

#voice-btn, #send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

#voice-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

#voice-btn:hover, #voice-btn.recording {
    background: var(--accent-current);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

#voice-btn.recording {
    animation: pulseGlow 1.5s ease-in-out infinite;
}

#send-btn {
    background: var(--accent-current);
    color: #fff;
    opacity: 0.4;
    pointer-events: none;
}

#send-btn:not(:disabled) {
    opacity: 1;
    pointer-events: auto;
}

#send-btn:not(:disabled):hover {
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
}

#input-wrapper {
    flex: 1;
    background: var(--bg-tertiary);
    border-radius: 22px;
    border: 1px solid var(--border);
    padding: 0 16px;
    transition: border-color var(--transition);
}

#input-wrapper:focus-within {
    border-color: var(--accent-current);
}

#text-input {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    padding: 10px 0;
    resize: none;
    max-height: 120px;
    outline: none;
}

#text-input::placeholder {
    color: var(--text-muted);
}

/* ---- Recording Overlay ---- */

#recording-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 100;
}

#recording-overlay.hidden { display: none; }

#recording-pulse {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-current);
    animation: pulseGlow 1.5s ease-in-out infinite;
}

#recording-time {
    font-size: 48px;
    font-weight: 300;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

#recording-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ---- Animations ---- */

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-current) 40%, transparent);
    }
    50% {
        box-shadow: 0 0 0 16px color-mix(in srgb, var(--accent-current) 0%, transparent);
    }
}

/* ---- Utilities ---- */

.hidden { display: none !important; }

/* Scrollbar styling */
#chat-window::-webkit-scrollbar { width: 4px; }
#chat-window::-webkit-scrollbar-track { background: transparent; }
#chat-window::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
