/**
 * Aether Modular Voice Copilot & Affective HUD Styling
 * High-density responsive theme matching FreeComputingManagement standards.
 */

:root {
    --bg-base: #080b11;
    --bg-surface: #0f1420;
    --bg-surface-hover: #161e30;
    --border-subtle: #1e293b;
    --border-bright: #334155;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --text-high: #f8fafc;
    --text-med: #94a3b8;
    --text-dim: #64748b;
}

body {
    background-color: var(--bg-base);
    color: var(--text-high);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.aether-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    width: 100%;
    overflow: hidden;
}

/* Header */
.aether-header {
    background: rgba(15, 20, 32, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: radial-gradient(circle, var(--accent-cyan), var(--accent-indigo));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-high);
    margin: 0;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 600;
}

/* Status Badge */
.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid transparent;
}

.badge-ready {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-processing {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-indigo);
    border-color: rgba(99, 102, 241, 0.3);
}

.badge-speaking {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border-color: rgba(6, 182, 212, 0.3);
    animation: pulse 1.5s infinite;
}

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

/* Main 3-Column Zero-Waste Layout */
.aether-main {
    flex: 1;
    display: grid;
    grid-template-columns: 290px 420px 1fr;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    height: calc(100vh - 58px);
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
}

/* Column 1 (Left): Affective Neural Orb & Somatic State */
.orb-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.85rem;
    position: relative;
    overflow-y: auto;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
    scrollbar-width: thin;
}

/* Column 2 (Center): Consciousness & Memory Stream */
.consciousness-column {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    padding: 0.9rem 0.85rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    scrollbar-width: thin;
    gap: 0.65rem;
}

.consciousness-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-high);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding-bottom: 0.45rem;
}

.canvas-wrapper {
    width: 240px;
    height: 240px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#aetherOrbCanvas {
    width: 100%;
    height: 100%;
}

.interim-caption {
    min-height: 38px;
    font-size: 0.85rem;
    color: var(--accent-emerald);
    text-align: center;
    margin-top: 0.75rem;
    font-weight: 500;
    font-style: italic;
}

/* Rolling Memory Ingestion Ticker */
.memory-notification-ticker {
    width: 100%;
    margin-top: 0.75rem;
    background: rgba(15, 23, 42, 0.90);
    border: 1px solid rgba(6, 182, 212, 0.4);
    border-radius: 0.65rem;
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.76rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(6, 182, 212, 0.15);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.memory-notification-ticker.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ticker-icon {
    font-size: 1.15rem;
    color: var(--accent-cyan);
    animation: pulse 2s infinite;
}

.ticker-body {
    flex: 1;
    min-width: 0;
}

.ticker-line1 {
    font-weight: 700;
    color: var(--text-high);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ticker-line2 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    margin-top: 3px;
    flex-wrap: wrap;
}

.chip-tag {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.chip-mass { background: rgba(99, 102, 241, 0.2); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.4); }
.chip-alarm { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.chip-sooth { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.chip-pride { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }

.memory-chat-pill {
    margin-top: 0.65rem;
    padding: 0.35rem 0.65rem;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 0.5rem;
    font-size: 0.74rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Inside Out Dominant Emotions Console */
.dominant-emotions-card {
    width: 100%;
    margin-top: 0.65rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border-subtle);
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    box-sizing: border-box;
}

.dominant-emotions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-high);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.voice-mod-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.voice-mod-badge.active {
    opacity: 1;
    animation: pulse 1.0s infinite;
}

.dominant-emotions-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.emotion-bar-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.emotion-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.70rem;
    font-weight: 600;
    color: var(--text-med);
}

.emotion-track {
    width: 100%;
    height: 5px;
    background: rgba(30, 41, 59, 0.7);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.emotion-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, filter 0.2s ease;
}

.dominant-emotions-card.speaking .emotion-fill {
    filter: brightness(1.25);
    box-shadow: 0 0 8px currentColor;
}

/* Consciousness & Working Memory Drawer */
.consciousness-card {
    width: 100%;
    margin-top: 0.65rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-subtle);
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.consciousness-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-high);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.consciousness-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wm-count-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.consciousness-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.7rem;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease;
}

.consciousness-toggle-btn:hover {
    color: var(--text-high);
}

.consciousness-card.collapsed .consciousness-drawer-body {
    display: none;
}

.consciousness-card.collapsed .consciousness-toggle-btn {
    transform: rotate(180deg);
}

.consciousness-drawer-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.wm-section, .subvocal-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.wm-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-med);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.silent-gate-pill {
    font-size: 0.62rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.wm-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 140px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.wm-empty-state {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 0.3rem 0;
}

.wm-item {
    background: rgba(8, 11, 17, 0.7);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 0.45rem;
    padding: 0.45rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: border-color 0.2s ease;
}

.wm-item:hover {
    border-color: rgba(6, 182, 212, 0.45);
}

.wm-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-high);
}

.wm-item-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.wm-item-mass {
    font-size: 0.65rem;
    color: var(--accent-indigo);
    font-family: 'JetBrains Mono', monospace;
}

.wm-activation-track {
    width: 100%;
    height: 4px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 2px;
}

.wm-activation-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.wm-item-lesson {
    font-size: 0.66rem;
    color: var(--text-dim);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subvocal-stream-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 110px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.subvocal-entry {
    background: rgba(8, 11, 17, 0.5);
    border-left: 2px solid var(--accent-emerald);
    border-radius: 0 0.35rem 0.35rem 0;
    padding: 0.3rem 0.5rem;
    font-size: 0.70rem;
    line-height: 1.35;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.subvocal-time {
    font-size: 0.62rem;
    color: var(--accent-cyan);
    font-family: 'JetBrains Mono', monospace;
}

.subvocal-text {
    font-style: italic;
}

.telemetry-box {
    width: 100%;
    margin-top: auto;
    background: rgba(8, 11, 17, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-med);
}

.telemetry-item {
    margin-bottom: 0.25rem;
}

/* Right Chat Area */
.chat-panel {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Message Rows */
.message-row {
    display: flex;
    gap: 0.75rem;
    max-width: 88%;
}

.message-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-row.agent {
    align-self: flex-start;
}

.avatar-chat {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #172033;
    border: 1px solid var(--border-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.avatar-chat.user {
    background: #1e3a8a;
    color: #fff;
    border-color: #3b82f6;
}

.message-content {
    background: #172033;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 0.85rem 1.15rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message-content em {
    color: #38bdf8;
    font-style: italic;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.28);
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.88em;
    letter-spacing: 0.02em;
    display: inline-block;
    margin: 0 2px;
}

.message-row.user .message-content {
    background: #1d4ed8;
    color: #fff;
    border-color: #2563eb;
}

/* Reflex Filler Box */
.reflex-filler-box {
    font-size: 0.8rem;
    color: var(--text-med);
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reflex-badge {
    background: rgba(6, 182, 212, 0.2);
    color: var(--accent-cyan);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.tool-badge-pill {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
}

.tool-badge-success {
    font-size: 0.75rem;
    color: var(--accent-emerald);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.salient-memories-tag {
    font-size: 0.72rem;
    color: var(--accent-indigo);
    margin-top: 0.6rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-subtle);
}

.salient-memories-tag span {
    background: rgba(99, 102, 241, 0.15);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    margin-right: 0.35rem;
}

/* Quick Chips */
.quick-chips-row {
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.prompt-chip {
    background: rgba(15, 20, 32, 0.8);
    border: 1px solid var(--border-bright);
    color: var(--text-med);
    font-size: 0.75rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.prompt-chip:hover {
    color: #fff;
    border-color: var(--accent-cyan);
    background: var(--bg-surface-hover);
}

/* Controls Bar */
.controls-bar {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(15, 20, 32, 0.9);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-mic {
    background: #172033;
    border: 1px solid var(--border-bright);
    color: var(--text-med);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-mic-active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.text-input-field {
    flex: 1;
    background: #080b11;
    border: 1px solid var(--border-subtle);
    color: var(--text-high);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    outline: none;
}

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

.btn-send {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-send:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Responsive Layout */
@media (max-width: 1200px) {
    .aether-main {
        grid-template-columns: 260px 360px 1fr;
    }
}

@media (max-width: 950px) {
    .aether-main {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    .orb-card, .consciousness-column, .chat-panel {
        height: auto;
        max-height: none;
    }
    .orb-card {
        flex-direction: row;
        gap: 1rem;
    }
    .canvas-wrapper {
        width: 120px;
        height: 120px;
    }
    .telemetry-box {
        display: none;
    }
}
