/* ==========================================================================
   JUJU Command Center - Premium Dark Glassmorphism Design System
   ========================================================================== */

:root {
    --bg-primary: #07090e;
    --bg-secondary: #0d121f;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.25);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;

    --primary-indigo: #6366f1;
    --primary-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #06b6d4 100%);
    --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px -5px rgba(99, 102, 241, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
.app-header {
    height: 72px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(13, 18, 31, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-orb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon {
    font-size: 1.4rem;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
}

.system-status-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
}

.status-online .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
}

/* Dashboard Grid Layout */
.dashboard-grid {
    flex: 1;
    padding: 1.5rem 2rem;
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: auto 1fr;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Stats Ribbon */
.stats-ribbon {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-glow);
}

.stat-icon-wrapper {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-icon-wrapper.purple { background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.3); }
.stat-icon-wrapper.cyan { background: rgba(6, 182, 212, 0.15); border: 1px solid rgba(6, 182, 212, 0.3); }
.stat-icon-wrapper.emerald { background: rgba(16, 185, 129, 0.15); border: 1px solid rgba(16, 185, 129, 0.3); }
.stat-icon-wrapper.amber { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.3); }

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Card Container */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-title-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h2, .panel-header h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
}

.panel-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

.panel-badge-green {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* Specialist Sub-Agent Chips */
.subagent-selector-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.agent-chip {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.agent-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.agent-chip.active {
    background: var(--primary-indigo);
    border-color: var(--primary-indigo);
    color: #fff;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

/* Console Panel & Chat Viewport */
.console-panel {
    min-height: 600px;
    height: calc(100vh - 240px);
}

.chat-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.message-bubble {
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius-md);
    max-width: 88%;
    line-height: 1.55;
    font-size: 0.92rem;
    word-break: break-word;
    animation: fadeIn 0.25s ease-out;
}

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

.message-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    opacity: 0.8;
}

.message-meta-footer {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* Chat Input Controls */
.chat-input-container {
    padding: 1rem 1.5rem;
    background: rgba(13, 18, 31, 0.95);
    border-top: 1px solid var(--border-color);
}

.input-controls-ribbon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
}

.brain-override-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    outline: none;
}

/* Toggle Switch */
.toggle-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-control input { display: none; }

.toggle-slider {
    width: 34px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    position: relative;
    transition: 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: 0.2s;
}

.toggle-control input:checked + .toggle-slider {
    background: var(--accent-emerald);
}

.toggle-control input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Input Form */
.input-form {
    display: flex;
    gap: 0.75rem;
}

.chat-textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.chat-textarea:focus {
    border-color: var(--primary-indigo);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.btn-send {
    padding: 0 1.4rem;
    background: var(--gradient-brand);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.btn-send:hover {
    transform: scale(1.02);
    opacity: 0.95;
}

/* Side Column Cards */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.indexer-body, .learning-body {
    padding: 1.2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.text-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
}

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

.indexer-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-primary, .btn-secondary, .btn-outline, .btn-accent {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.btn-primary { background: var(--primary-indigo); color: #fff; flex: 1; }
.btn-primary:hover { background: #4f46e5; }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

.btn-secondary { background: rgba(255, 255, 255, 0.08); color: #fff; }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }

.btn-accent { background: linear-gradient(135deg, #10b981, #059669); color: #fff; width: 100%; }
.btn-accent:hover { opacity: 0.95; }

.log-console {
    background: #05070a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    color: #a5b4fc;
}

.learning-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.learning-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.learning-status-box {
    font-size: 0.8rem;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: none;
}

/* Footer */
.app-footer {
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-subtle);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Responsive */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .stats-ribbon {
        grid-template-columns: repeat(2, 1fr);
    }
}
