@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #060614;
    --bg-secondary: #0d0d2b;
    --bg-card: rgba(15, 15, 45, 0.8);
    --bg-display: rgba(10, 10, 30, 0.95);
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --accent-blue: #00ccff;
    --accent-purple: #8855ff;
    --accent-gradient: linear-gradient(135deg, #00ccff, #8855ff);
    --glow-blue: 0 0 20px rgba(0, 204, 255, 0.3);
    --radius: 16px;
}

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

html,
body {
    width: 100%;
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ─── Main Layout ───────────────────────────────── */
#app-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* ─── LEFT PANEL: Avatar + Chat ─────────────────── */
#left-panel {
    width: 38%;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0, 204, 255, 0.06);
}

/* ── Avatar Area (upper part of left) ── */
#avatar-area {
    flex: 1;
    position: relative;
    min-height: 0;
}

#avatar-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#avatar-label {
    position: absolute;
    top: 12px;
    left: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
}

#avatar-name {
    font-size: 1.15rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

#status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 6px #00ff88;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

#avatar-switcher {
    position: absolute;
    top: 12px;
    right: 14px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.avatar-pill {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-pill.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--glow-blue);
}

/* ── Chat Area (lower part of left) ── */
#chat-area {
    height: 180px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    background: rgba(6, 6, 20, 0.95);
    border-top: 1px solid rgba(0, 204, 255, 0.08);
}

#chat-overlay {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: none;
}

#chat-overlay::-webkit-scrollbar {
    display: none;
}

.msg {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 95%;
    font-size: 0.85rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.msg.user {
    align-self: flex-end;
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.msg.ai {
    align-self: flex-start;
    background: rgba(20, 20, 50, 0.9);
    border: 1px solid rgba(0, 204, 255, 0.1);
    border-bottom-left-radius: 4px;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Input Row ── */
#input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.ctrl-btn-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ctrl-btn-sm:hover {
    background: rgba(255, 255, 255, 0.12);
}

.active-mic {
    background: var(--accent-gradient) !important;
    box-shadow: var(--glow-blue);
}

.active-mic.recording {
    background: linear-gradient(135deg, #ff4444, #ff6666) !important;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    animation: pulseRecord 1s infinite;
}

@keyframes pulseRecord {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

#text-input {
    flex: 1;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(0, 204, 255, 0.15);
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    min-width: 0;
}

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

#text-input:focus {
    border-color: var(--accent-blue);
    box-shadow: var(--glow-blue);
}

#btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Thinking ── */
#thinking {
    display: none;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#thinking.active {
    display: flex;
    align-items: center;
    gap: 6px;
}

.thinking-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: dot 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot {

    0%,
    80%,
    100% {
        transform: scale(0.4);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ─── RIGHT: Display Monitor ───────────────────── */
#display-panel {
    width: 62%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-display);
}

#display-header {
    height: 42px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(0, 204, 255, 0.06);
    background: rgba(0, 0, 0, 0.3);
}

#display-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

#display-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ── Welcome/Drop Zone Passive ── */
#drop-zone-passive {
    text-align: center;
    opacity: 0.4;
}

#drop-zone-passive.hidden {
    display: none;
}

#drop-zone-passive .welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

#drop-zone-passive p {
    font-size: 1rem;
    margin-bottom: 6px;
}

#drop-zone-passive small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Drop overlay ── */
#drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 204, 255, 0.08);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

#drop-zone.hidden {
    display: none;
}

.drop-zone-content {
    text-align: center;
    padding: 40px;
    border: 2px dashed var(--accent-blue);
    border-radius: 24px;
}

.drop-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* ── Monitor display items ── */
.monitor-item {
    width: 100%;
    max-width: 100%;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.monitor-item img {
    width: 100%;
    border-radius: var(--radius);
}

.monitor-item iframe {
    width: 100%;
    height: 400px;
    border: none;
    border-radius: var(--radius);
}

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
    #app-layout {
        flex-direction: column;
    }

    #left-panel {
        width: 100%;
        height: 55%;
    }

    #display-panel {
        width: 100%;
        height: 45%;
    }

    #chat-area {
        height: 120px;
        min-height: 100px;
    }
}
/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN STYLES
   ═══════════════════════════════════════════════════════════════ */

#auth-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#auth-screen.hidden { display: none; }

#auth-container {
    width: 100%;
    max-width: 380px;
    padding: 40px 30px;
    text-align: center;
}

#auth-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.auth-avatar-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#auth-form h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#auth-form input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

#auth-form input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 204, 255, 0.1);
}

#auth-form input::placeholder { color: var(--text-secondary); }

#auth-submit {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

#auth-submit:hover { opacity: 0.9; }
#auth-submit:active { transform: scale(0.98); }
#auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

#auth-error {
    color: #ff6b6b;
    font-size: 0.85rem;
    min-height: 20px;
}

#auth-toggle {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.85rem;
    transition: opacity 0.2s;
}

#auth-toggle:hover { opacity: 0.8; }

.auth-guest-btn {
    margin-top: 20px;
    padding: 10px 24px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-guest-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

/* User badge in avatar switcher */
.user-badge {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
}

#btn-auth {
    font-size: 0.85rem;
    padding: 4px 8px;
}

/* Vision button active state */
.active-vision {
    background: var(--accent-gradient) !important;
    box-shadow: var(--glow-blue);
}

/* ═══ CONVERSATION HISTORY SIDEBAR ═══ */
#history-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px;
    background: rgba(10,10,26,0.98); border-right: 1px solid rgba(255,255,255,0.1);
    z-index: 1000; display: flex; flex-direction: column;
    backdrop-filter: blur(20px); transition: transform 0.3s ease;
}
#history-sidebar.hidden { display: none; }
#history-header {
    display: flex; align-items: center; padding: 16px; gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
#history-header h3 { flex: 1; color: #fff; font-size: 1rem; margin: 0; }
#history-header button {
    background: rgba(255,255,255,0.08); border: none; color: #aaa;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 1rem;
}
#history-header button:hover { background: rgba(255,255,255,0.15); color: #fff; }
#history-list { flex: 1; overflow-y: auto; padding: 8px; }
.history-item {
    padding: 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
    transition: background 0.2s;
}
.history-item:hover { background: rgba(255,255,255,0.06); }
.history-item.active { background: rgba(0,255,255,0.08); border-left: 2px solid #00ffff; }
.history-item-title {
    color: #ddd; font-size: 0.85rem; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.history-item-meta { color: #666; font-size: 0.7rem; margin-top: 4px; }
.history-item-avatar { display: inline-block; font-size: 0.65rem; color: #888;
    background: rgba(255,255,255,0.05); padding: 1px 6px; border-radius: 4px; }
.history-empty {
    color: #555; text-align: center; padding: 40px 20px; font-size: 0.85rem;
}

/* ═══ STREAMING INDICATOR ═══ */
.msg.assistant.streaming { border-left: 2px solid #00ffff; }
.msg.assistant.streaming::after {
    content: '▋'; animation: blink 0.8s infinite; color: #00ffff;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
