/* 
   THE ALPHA COUNCIL v4 - Premium Dark UI 
   Modern, Responsive, and Performance-Oriented 
*/

/* --- Modern Design System --- */
:root {
    /* Color Palette — HSL based for consistency */
    --accent-h: 235;
    --accent-s: 85%;
    --accent-l: 65%;

    --accent: hsl(var(--accent-h), var(--accent-s), var(--accent-l));
    --accent-glow: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.4);

    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.3);
    --info: #0ea5e9;

    /* Neutrals */
    --bg-deep: #05070a;
    --bg-main: #0a0e14;
    --bg-card: rgba(20, 26, 38, 0.7);
    --bg-glass: rgba(15, 23, 42, 0.65);

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    /* Layout & Effects */
    --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;

    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 15px var(--accent-glow);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Base Styles ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    /* Mesh Gradient Background */
    background-image:
        radial-gradient(at 0% 0%, hsla(var(--accent-h), 50%, 20%, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, hsla(160, 50%, 20%, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, hsla(280, 50%, 20%, 0.1) 0px, transparent 50%);
}

/* ─── Layout Components ─── */
.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 5%;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.brand-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px hsla(var(--accent-h), 80%, 60%, 0.5));
}

.brand-text {
    font-size: 1.4rem;
    font-weight: 850;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--accent);
    background: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.1);
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 5%;
}

/* ─── Dashboard Components ─── */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--warning);
    position: relative;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 15px var(--success-glow);
}

.status-dot.online::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    bottom: -4px;
    left: -4px;
    border: 2px solid var(--success);
    border-radius: 50%;
    opacity: 0;
    animation: ping 2s infinite;
}

@keyframes ping {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Engine Control Switch */
.engine-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border);
    margin-left: auto;
    margin-right: 1.5rem;
}

.control-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-deep);
    border: 1px solid var(--border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: hsla(160, 50%, 50%, 0.2);
    border-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(24px);
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--success);
}

/* Wallet Cards */
.wallet-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-5px);
    box-shadow: var(--shadow-soft);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.05),
            transparent);
    transition: 0.5s;
}

.glass-card:hover::before {
    left: 100%;
}

.card-primary {
    border-color: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.3);
    background: linear-gradient(135deg, hsla(var(--accent-h), 50%, 20%, 0.2), var(--bg-card));
}

.card-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.card-value {
    font-size: 2rem;
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--text-primary);
    letter-spacing: -0.04em;
}

.card-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Agent Grid */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.agent-card:hover {
    border-color: var(--accent);
    transform: scale(1.02);
}

.agent-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.agent-card:hover .agent-icon {
    transform: translateY(-5px) scale(1.1);
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.agent-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.agent-vote {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    font-weight: 800;
    font-family: var(--font-mono);
    font-size: 1rem;
    border: 1px solid var(--border);
}

.vote-buy {
    color: var(--success);
    border-color: hsla(160, 50%, 50%, 0.2);
    background: hsla(160, 50%, 50%, 0.1);
}

.vote-sell {
    color: var(--danger);
    border-color: hsla(0, 50%, 50%, 0.2);
    background: hsla(0, 50%, 50%, 0.1);
}

.vote-neutral {
    color: var(--warning);
    border-color: hsla(45, 50%, 50%, 0.2);
    background: hsla(45, 50%, 50%, 0.1);
}

/* Maestro Panel */
.maestro-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: relative;
    overflow: hidden;
}

.maestro-core {
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    gap: 3rem;
}

.maestro-reasoning-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 1rem;
    z-index: 2;
    /* appear above the watermark */
}

.reasoning-header {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.reasoning-content {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    /* For line breaks from Gemini output */
}

.maestro-panel::after {
    content: 'MAESTRO';
    position: absolute;
    right: -20px;
    bottom: -10px;
    font-size: 8rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.02);
    pointer-events: none;
}

.maestro-direction {
    font-size: 3.5rem;
    font-weight: 950;
    letter-spacing: -0.06em;
    text-align: center;
}

.maestro-direction.buy {
    color: var(--success);
    filter: drop-shadow(0 0 15px var(--success-glow));
}

.maestro-direction.sell {
    color: var(--danger);
    filter: drop-shadow(0 0 15px var(--danger-glow));
}

.maestro-direction.hold {
    color: var(--warning);
    filter: drop-shadow(0 0 15px var(--warning-glow));
}

/* Pulse Ticker Styles */
.pulse-box {
    border-right: 1px solid var(--border);
    padding-right: 2rem;
    position: relative;
    min-width: 150px;
}

.pulse-value {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.pulse-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.6rem;
    font-weight: 900;
    color: var(--success);
    background: hsla(160, 50%, 50%, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.1em;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
        text-shadow: 0 0 8px var(--success-glow);
    }

    100% {
        opacity: 0.5;
    }
}

.maestro-stats {
    display: flex;
    justify-content: space-around;
    gap: 1.5rem;
}

.stat-box {
    text-align: left;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: auto;
    box-shadow: var(--shadow-soft);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-mono);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ─── Responsive Utilities ─── */
@media (max-width: 1024px) {
    .maestro-core {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .maestro-panel {
        padding: 2rem;
    }

    .maestro-direction {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .main-nav {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .brand-text {
        font-size: 1.2rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .wallet-cards {
        grid-template-columns: 1fr;
    }

    .agent-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .maestro-stats {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .agent-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Custom Styles ─── */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 800;
}

.badge-success {
    background: hsla(160, 50%, 50%, 0.15);
    color: var(--success);
}

.badge-danger {
    background: hsla(0, 50%, 50%, 0.15);
    color: var(--danger);
    box-shadow: 0 0 10px var(--danger-glow);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    min-width: 300px;
    box-shadow: var(--shadow-soft);
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ─── Konsey Kokpiti (Hybrid Brain) ─── */
.ai-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.ai-module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.ai-module-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), 0 0 15px var(--accent-glow);
}

.module-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.llm-indicator {
    margin-left: auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.llm-dot-gray {
    background-color: #555;
    box-shadow: 0 0 5px #555;
}

.llm-dot-green {
    background-color: #2ed573;
    box-shadow: 0 0 10px #2ed573, 0 0 20px #2ed573;
    animation: llmPulseGreen 2s infinite;
}

.llm-dot-red {
    background-color: #ff4757;
    box-shadow: 0 0 10px #ff4757, 0 0 20px #ff4757;
    animation: llmPulseRed 1.5s infinite;
}

.llm-dot-orange {
    background-color: #ffa502;
    box-shadow: 0 0 8px #ffa502;
    animation: llmPulseOrange 2s infinite;
}

@keyframes llmPulseGreen {

    0%,
    100% {
        box-shadow: 0 0 6px #2ed573;
    }

    50% {
        box-shadow: 0 0 14px #2ed573, 0 0 28px #2ed573;
    }
}

@keyframes llmPulseRed {

    0%,
    100% {
        box-shadow: 0 0 6px #ff4757;
    }

    50% {
        box-shadow: 0 0 14px #ff4757, 0 0 28px #ff4757;
    }
}

@keyframes llmPulseOrange {

    0%,
    100% {
        box-shadow: 0 0 4px #ffa502;
    }

    50% {
        box-shadow: 0 0 10px #ffa502, 0 0 20px #ffa502;
    }
}

.module-icon {
    font-size: 1.5rem;
}

.module-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.module-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    min-height: 40px;
}

/* Neon Switch override */
.neon-switch .slider {
    border-color: var(--border);
}

.neon-switch input:checked+.slider {
    background-color: hsla(280, 80%, 50%, 0.2);
    border-color: #a855f7;
}

.neon-switch input:checked+.slider:before {
    background-color: #a855f7;
    box-shadow: 0 0 15px #a855f7;
}

.resource-monitor {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    display: flex;
    gap: 2rem;
    align-items: center;
}

.res-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.res-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 130px;
}

.res-bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-deep);
    border-radius: 4px;
    overflow: hidden;
}

.res-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.fill-cpu {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.fill-ram {
    background: linear-gradient(90deg, #8b5cf6, #a855f7);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

.res-value {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    font-weight: 700;
    min-width: 40px;
}

/* --- Performance Hub Styles --- */
.performance-hub {
    padding: 20px 0;
}

.header-section {
    margin-bottom: 30px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.perf-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 440px;
}

#accuracyRadar {
    max-width: 100%;
    max-height: 380px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
    border-radius: 10px;
}

.progress-bar span {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tuner-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.tstat {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tlabel {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.tvalue {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'JetBrains Mono';
}

.tvalue.highlight {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}

.validation-box {
    padding: 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-top: 10px;
    border-left: 4px solid #ccc;
    background: rgba(255, 255, 255, 0.02);
}

.validation-box.stable {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.validation-box.overfit {
    border-color: var(--neon-red);
    color: var(--neon-red);
}

@media (max-width: 1200px) {
    .perf-row {
        grid-template-columns: 1fr;
    }
}