/* ── NEO EA — Premium Dark Theme ─────────────────────── */

:root {
    --bg-primary: #07080d;
    --bg-secondary: #0f1117;
    --bg-card: #161822;
    --bg-elevated: #1c1f2e;
    --bg-hover: #232738;
    --border: #2a2d3d;
    --border-light: #353849;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #5f6577;
    --accent: #00d4ff;
    --accent-dim: #00a8cc;
    --accent-glow: rgba(0, 212, 255, 0.15);
    --accent-glow-strong: rgba(0, 212, 255, 0.3);
    --green: #34d399;
    --red: #f87171;
    --orange: #fbbf24;
    --purple: #a78bfa;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Header ──────────────────────────────────────────── */

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
.header-center { display: flex; align-items: center; }

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--bg-primary);
}

.logo-text { display: flex; flex-direction: column; }
.logo-name { font-weight: 700; font-size: 16px; letter-spacing: 1px; }
.logo-sub { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.model-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: var(--mono);
    transition: all 0.3s;
}
.model-badge.nano, .model-badge.super {
    background: rgba(52, 211, 153, 0.1);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.2);
}
.model-badge.ultra {
    background: rgba(167, 139, 250, 0.1);
    color: var(--purple);
    border: 1px solid rgba(167, 139, 250, 0.2);
}
.model-badge.thinking {
    background: rgba(251, 191, 36, 0.1);
    color: var(--orange);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.model-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.model-badge.thinking .model-dot {
    animation: pulse-dot 1s infinite;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

/* ── Main Layout ─────────────────────────────────────── */

#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Messages ────────────────────────────────────────── */

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    gap: 16px;
    padding: 40px 20px;
    opacity: 0;
    animation: fadeInUp 0.6s forwards;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 32px;
    color: var(--bg-primary);
    box-shadow: 0 0 40px var(--accent-glow-strong);
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 500px;
    line-height: 1.6;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.chip {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Message Bubbles */
.msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeInUp 0.3s;
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.msg.assistant .msg-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: var(--bg-primary);
}
.msg.user .msg-avatar {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.msg-body {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
}
.msg.assistant .msg-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
}
.msg.user .msg-body {
    background: var(--accent);
    color: var(--bg-primary);
    border-top-right-radius: 4px;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
}
.msg.user .msg-meta { justify-content: flex-end; }

.msg-model {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.msg-model.nano, .msg-model.super { background: rgba(52,211,153,0.1); color: var(--green); }
.msg-model.ultra { background: rgba(167,139,250,0.1); color: var(--purple); }

.msg-tools {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.msg-tool-badge {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(251,191,36,0.1);
    color: var(--orange);
    font-size: 10px;
    font-family: var(--mono);
}

/* Thinking indicator */
.thinking-msg {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    animation: fadeInUp 0.3s;
}
.thinking-dots {
    display: flex;
    gap: 4px;
}
.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce-dot 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

.thinking-label {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Input Area ──────────────────────────────────────── */

#input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

#listening-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    margin-bottom: 12px;
    background: var(--accent-glow);
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 13px;
}

.wave-bars {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}
.wave-bars span {
    width: 3px;
    height: 6px;
    background: var(--accent);
    border-radius: 2px;
    animation: wave 1s infinite;
}
.wave-bars span:nth-child(1) { animation-delay: 0s; }
.wave-bars span:nth-child(2) { animation-delay: 0.15s; }
.wave-bars span:nth-child(3) { animation-delay: 0.3s; }
.wave-bars span:nth-child(4) { animation-delay: 0.45s; }
.wave-bars span:nth-child(5) { animation-delay: 0.6s; }

#transcript-preview {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

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

.mic-button {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    position: relative;
}
.mic-button:hover {
    background: var(--accent-glow-strong);
    transform: scale(1.05);
}
.mic-button.recording {
    background: rgba(248,113,113,0.15);
    border-color: var(--red);
    color: var(--red);
    animation: pulse-ring 1.5s infinite;
}
.mic-button .stop-icon { display: none; }
.mic-button.recording .mic-icon { display: none; }
.mic-button.recording .stop-icon { display: block; }

.text-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}
.text-input-wrapper:focus-within { border-color: var(--accent); }

#text-input {
    flex: 1;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
}
#text-input::placeholder { color: var(--text-muted); }

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.send-button:hover { color: var(--accent); }

.input-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}
.wake-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.wake-badge.listening {
    background: rgba(52, 211, 153, 0.1);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.15);
}
.wake-badge.off {
    background: rgba(95, 101, 119, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.wake-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 1.5s infinite;
}
.wake-badge.off .wake-dot { animation: none; }

.input-hint kbd {
    padding: 2px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 10px;
}

/* ── Sidebar ─────────────────────────────────────────── */

#sidebar {
    width: 300px;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
    transition: all 0.3s;
}
#sidebar.hidden { display: none; }

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#status-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    font-size: 12px;
}
.status-row .svc-name { color: var(--text-secondary); }
.status-row .svc-status { font-family: var(--mono); font-weight: 600; font-size: 11px; }
.status-row .svc-status.ok { color: var(--green); }
.status-row .svc-status.error { color: var(--red); }
.status-row .svc-status.loading { color: var(--text-muted); }

.small-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.small-btn:hover { border-color: var(--accent); color: var(--accent); }

#tasks-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.task-item:hover { background: var(--bg-hover); }
.task-item.done { opacity: 0.4; }
.task-item.done .task-text { text-decoration: line-through; }

.task-check {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: transparent;
    font-size: 10px;
    font-family: var(--font);
    padding: 0;
}
.task-check:hover { border-color: var(--accent); }
.task-item.done .task-check {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.task-text { flex: 1; color: var(--text-secondary); }
.task-due { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }

.add-task-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

#task-input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font);
    outline: none;
}
#task-input:focus { border-color: var(--accent); }

#info-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    font-size: 12px;
    color: var(--text-secondary);
}
.info-row .mono {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Animations ──────────────────────────────────────── */

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

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(248,113,113,0.3); }
    70% { box-shadow: 0 0 0 12px rgba(248,113,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
}

@keyframes bounce-dot {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

@keyframes wave {
    0%, 100% { height: 6px; }
    50% { height: 18px; }
}

@keyframes typewriter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Big Voice Status ─────────────────────────────────── */

.big-status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    margin: 0 24px 8px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.3s;
}
.big-status.idle {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.big-status.wake {
    background: rgba(52, 211, 153, 0.08);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.15);
}
.big-status.listening {
    background: rgba(0, 212, 255, 0.08);
    color: var(--accent);
    border: 1px solid rgba(0, 212, 255, 0.2);
    animation: pulse-bg 1.5s infinite;
}
.big-status.thinking {
    background: rgba(251, 191, 36, 0.08);
    color: var(--orange);
    border: 1px solid rgba(251, 191, 36, 0.15);
}
.big-status.speaking {
    background: rgba(167, 139, 250, 0.08);
    color: var(--purple);
    border: 1px solid rgba(167, 139, 250, 0.15);
    animation: pulse-bg 1s infinite;
}
.big-status.hidden { display: none; }

@keyframes pulse-bg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ── Language Modal ───────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: fadeInUp 0.4s;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 60px var(--accent-glow);
}

.modal-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #a78bfa, #6d28d9);
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 36px;
    color: var(--bg-primary);
    margin-bottom: 20px;
    box-shadow: 0 0 40px var(--accent-glow-strong);
}

.modal-card h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.modal-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.lang-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 32px;
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--font);
    min-width: 140px;
}

.lang-choice-btn:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,212,255,0.15);
}

.lang-flag { font-size: 40px; }
.lang-name { font-size: 16px; font-weight: 600; }

.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
    #header { padding: 0 12px; }
    #messages { padding: 16px; }
    #input-area { padding: 12px 16px 16px; }
    #sidebar { width: 100%; position: absolute; right: 0; top: 56px; bottom: 0; z-index: 10; }
    .msg { max-width: 95%; }
    .welcome-chips { flex-direction: column; align-items: center; }
    .header-center { display: none; }
}

/* ── Audio Playing State ─────────────────────────────── */

.audio-playing .msg-avatar {
    animation: pulse-dot 0.8s infinite;
}
