/* ═══════════════════════════════════════════════════════
   Nexus AI — Dashboard CSS
   Dark sci-fi terminal aesthetic, built on style.css variables
   ═══════════════════════════════════════════════════════ */

/* ─── Brain Mode Buttons ─── */
.brain-btn {
    font-family: var(--font-title);
    font-size: 11px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity .2s, border-color .2s;
}
.brain-btn:hover { opacity: 0.8; border-color: var(--accent); }

/* ─── App shell ─── */
#dash-app {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: -webkit-fill-available; /* iOS Safari fix */
    overflow: hidden;
}
@media (max-width: 900px) {
    #dash-app {
        height: auto;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ─── Header ─── */
#dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 54px;
    background: linear-gradient(180deg, rgba(0,20,50,0.97) 0%, rgba(5,15,35,0.93) 100%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}
#dash-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 8%; width: 84%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* Brand */
.dash-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.dash-logo {
    width: 32px; height: 32px;
    filter: drop-shadow(0 0 6px var(--accent-glow));
    animation: logoPulse 4s ease-in-out infinite;
}
@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 6px var(--accent-glow)); }
    50%       { filter: drop-shadow(0 0 14px var(--accent)); }
}
.brand-labels { display: flex; flex-direction: column; gap: 1px; }
.brand-name {
    font-family: var(--font-title);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--text-primary);
    text-shadow: 0 0 12px var(--accent-glow);
}
.brand-sub {
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Tab nav */
#dash-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
}
.tab-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-family: var(--font-title);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: all 0.2s;
    margin-right: 8px;
}
.tab-link:hover {
    color: var(--accent);
    border-color: var(--border);
    background: var(--accent-dim);
}
.tab-btn {
    padding: 6px 18px;
    font-family: var(--font-title);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}
.tab-btn:hover {
    color: var(--accent);
    border-color: var(--border);
}
.tab-btn.active {
    color: var(--accent);
    border-color: var(--border-bright);
    background: var(--accent-dim);
    box-shadow: 0 0 10px var(--accent-dim);
}

/* Header right */
.dash-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.dash-clock {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 3px;
    text-shadow: 0 0 10px var(--accent-glow);
}
.dash-online {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-family: var(--font-title);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--accent);
    background: var(--accent-dim);
}

/* ─── Tab content ─── */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}
.tab-content.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════
   主控台 Tab — 3-column grid
   ═══════════════════════════════════════ */
.main-grid {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 10px;
    padding: 10px;
    height: 100%;
    overflow: hidden;
}

/* Shared panel style */
.grid-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.grid-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
}

/* Section inside panel */
.gp-section {
    padding: 14px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.08);
}
.gp-section:last-child { border-bottom: none; }

.gp-title {
    font-family: var(--font-title);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.8;
}

/* Stat rows */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,150,255,0.05);
}
.stat-row:last-child { border-bottom: none; }
.sr-label {
    font-family: var(--font-title);
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.sr-val {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}
.sr-val.accent { color: var(--accent); font-size: 11px; letter-spacing: 1px; }

/* Channel rows */
.channel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.ch-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.ch-dot.online  { background: var(--accent2); box-shadow: 0 0 6px var(--accent2); }
.ch-dot.offline { background: var(--error); }
.ch-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
}
.ch-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 2px;
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.ch-badge.online  { color: var(--accent2); border-color: var(--accent2); background: rgba(0,255,170,0.08); }
.ch-badge.offline { color: var(--error);   border-color: var(--error); }

/* Token pool */
.tp-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.tp-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(0,20,50,0.8);
    border: 1px solid var(--border);
    border-radius: 1px;
    overflow: hidden;
}
.tp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00aaff, #00ddff);
    box-shadow: 0 0 6px rgba(0,200,255,0.4);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.tp-bar-fill.warning { background: linear-gradient(90deg, #ff8800, #ffaa33); }
.tp-bar-fill.danger  { background: linear-gradient(90deg, #ff2244, #ff4466); }
.tp-pct {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
}
.tp-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    padding: 2px 0;
}
.tp-val {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* ─── Center: Nexus Core Visual ─── */
.grid-center {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.nexus-core {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 320px;
    height: 320px;
}

.nc-svg {
    width: 300px;
    height: 300px;
    overflow: visible;
}

/* Hexagon rotation animations */
.nc-hex-cw  { animation: rotateCW  20s linear infinite; transform-origin: 0 0; }
.nc-hex-ccw { animation: rotateCCW 13s linear infinite; transform-origin: 0 0; }

/* Orbiting dots */
.nc-orb1 { animation: rotateCW  4.5s linear infinite; transform-origin: 0 0; }
.nc-orb2 { animation: rotateCCW 6.0s linear infinite; transform-origin: 0 0; }
.nc-orb3 { animation: rotateCW  9.0s linear infinite; transform-origin: 0 0; }

/* Center pulse */
.nc-pulse { animation: ncPulse 2.5s ease-in-out infinite; }

@keyframes rotateCW  { from { transform: rotate(0deg);    } to { transform: rotate(360deg);  } }
@keyframes rotateCCW { from { transform: rotate(0deg);    } to { transform: rotate(-360deg); } }
@keyframes ncPulse   { 0%, 100% { opacity: 0.06; } 50% { opacity: 0.22; } }

/* Status text below core */
.nc-status-wrap {
    position: absolute;
    bottom: 8px;
    text-align: center;
    pointer-events: none;
}
.nc-status-main {
    font-family: var(--font-title);
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--accent);
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--accent-glow);
}
.nc-status-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-top: 2px;
}

/* ─── Daily Brief ─── */
.brief-date {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--gold);
    margin-bottom: 10px;
}

.brief-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brief-placeholder {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    padding: 16px 0;
}

.brief-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid rgba(0, 150, 255, 0.1);
    border-radius: 3px;
    background: rgba(0, 20, 50, 0.3);
    transition: border-color 0.2s;
}
.brief-item:hover { border-color: var(--border-bright); }
.brief-item.done {
    opacity: 0.5;
    text-decoration: line-through;
}
.bi-time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    min-width: 38px;
}
.bi-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
}
.bi-done {
    font-size: 11px;
    color: var(--accent2);
}

/* Quick access */
.qa-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}
.qa-btn {
    padding: 7px 6px;
    font-family: var(--font-title);
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-secondary);
    background: rgba(0, 20, 50, 0.5);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.qa-btn:hover {
    color: var(--accent);
    border-color: var(--border-bright);
    background: var(--accent-dim);
    box-shadow: 0 0 8px var(--accent-dim);
}

/* ═══════════════════════════════════════
   對話 (Chat) Tab
   ═══════════════════════════════════════ */
.chat-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.chat-side {
    width: 210px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(5, 12, 30, 0.65);
    border-right: 1px solid var(--border);
}
.chat-side-right {
    border-right: none;
    border-left: 1px solid var(--border);
}
.chat-side-inner {
    padding: 14px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.chat-side-inner .gp-title { margin-bottom: 10px; }

.chat-think-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#d-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#d-input-area {
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
    background: rgba(4, 10, 26, 0.92);
    flex-shrink: 0;
}
/* dashboard input frame inherits .input-frame from style.css */

/* Responsive: tablet */
@media (max-width: 900px) {
    .chat-layout { flex-direction: column; }
    .chat-side {
        width: 100%;
        height: 110px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .chat-side-right {
        height: 90px;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .chat-side-inner { flex-direction: row; flex-wrap: wrap; gap: 12px; padding: 8px 12px; }
    .chat-side-inner .gp-title { display: none; }
    .chat-think-log { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: 8px; }
}

/* Responsive: phone */
@media (max-width: 600px) {
    .chat-side-left { height: 80px; }
    .chat-side-right { display: none; }
    #d-messages { padding: 10px 12px; }
    #d-input-area { padding: 8px 10px 10px; }
}

/* ═══════════════════════════════════════
   技能演化 Tab
   ═══════════════════════════════════════ */
.skills-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Left: sidebar */
.skills-sidebar {
    width: 220px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 12px;
    border-right: 1px solid var(--border);
    background: rgba(5, 12, 30, 0.6);
}

.sb-loading {
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

.sb-category {
    margin-bottom: 16px;
}
.sb-cat-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-title);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 5px 8px;
    border-left: 2px solid;
    background: rgba(0, 20, 50, 0.4);
    margin-bottom: 4px;
}
.sb-cat-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10px;
    opacity: 0.6;
}
.sb-skills { padding-left: 4px; }
.sb-skill-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.15s;
}
.sb-skill-item:hover {
    color: var(--text-primary);
    background: rgba(0, 150, 255, 0.08);
}
.sb-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Graph area */
.skills-graph-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}
#skill-graph {
    width: 100%;
    height: 100%;
    display: block;
}

/* Tooltip */
.skill-tooltip {
    position: absolute;
    max-width: 200px;
    background: rgba(8, 18, 40, 0.95);
    border: 1px solid var(--border-bright);
    border-radius: 4px;
    padding: 10px 14px;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 16px var(--accent-dim);
    z-index: 10;
}
.skill-tooltip.hidden { display: none !important; }
.stt-name {
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.stt-category {
    font-size: 10px;
    font-family: var(--font-title);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 6px;
    opacity: 0.8;
}
.stt-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ═══════════════════════════════════════
   Responsive — Tablet & Mobile
   ═══════════════════════════════════════ */

/* ── Large tablet (≤ 1100px): shrink side panels ── */
@media (max-width: 1100px) {
    .main-grid { grid-template-columns: 200px 1fr 200px; }
}

/* ── Tablet (≤ 900px): center on top, left+right below side by side ── */
@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        overflow-y: auto;
    }
    /* Core spans full width, pinned first */
    .grid-center {
        grid-column: 1 / -1;
        order: -1;
        min-height: 260px;
    }
    #panel-left, #panel-right {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: auto;
        max-height: 340px;
    }
    .gp-section {
        flex: 1;
        min-width: 140px;
        border-bottom: none;
        border-right: 1px solid rgba(0,150,255,0.08);
    }
    .gp-section:last-child { border-right: none; }
    .nexus-core { width: 240px; height: 240px; }
    .nc-svg    { width: 240px; height: 240px; }
    .nc-status-wrap { bottom: 0; }

    /* Skills tab: sidebar as horizontal scroll strip */
    .skills-layout { flex-direction: column; }
    .skills-sidebar {
        width: 100%;
        max-height: 160px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 12px;
    }
    .sb-category {
        flex-shrink: 0;
        min-width: 120px;
        margin-bottom: 0;
    }
    .sb-loading { align-self: center; white-space: nowrap; }
    .skills-graph-wrap { min-height: 320px; flex: 1; }
}

/* ── Phone (≤ 600px): single column, condensed header ── */
@media (max-width: 600px) {
    /* Header wraps to 2 rows */
    #dash-header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 4px 12px;
    }
    .dash-brand  { flex: 1; min-width: 0; }
    .brand-sub   { display: none; }
    .brand-name  { font-size: 14px; letter-spacing: 2px; }
    .dash-logo   { width: 26px; height: 26px; }

    /* Tabs move to second row */
    #dash-tabs {
        order: 3;
        width: 100%;
        display: flex;
        justify-content: center;
        padding-bottom: 4px;
        gap: 2px;
    }
    .tab-link   { display: none; }           /* hide "NEURAL LINK" on phone */
    .tab-btn    { padding: 5px 14px; font-size: 10px; }

    /* Right: clock + status beside brand */
    .dash-header-right {
        order: 2;
        gap: 8px;
    }
    .dash-clock { font-size: 15px; letter-spacing: 2px; }
    .dash-online { padding: 2px 7px; font-size: 9px; }

    /* Single column main grid */
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        padding: 6px;
        gap: 6px;
        overflow-y: visible;
        height: auto;
    }
    .grid-center {
        grid-column: 1;
        order: -1;
        min-height: 200px;
    }
    #panel-left, #panel-right {
        max-height: none;
        flex-direction: column;
    }
    .gp-section {
        border-right: none;
        border-bottom: 1px solid rgba(0,150,255,0.08);
    }

    /* Smaller core */
    .nexus-core { width: 190px; height: 190px; }
    .nc-svg     { width: 190px; height: 190px; }
    .nc-status-main { font-size: 11px; letter-spacing: 2px; }
    .nc-status-sub  { font-size: 9px; }

    /* Brief */
    .brief-item { padding: 5px 6px; }
    .bi-time    { font-size: 11px; min-width: 34px; }
    .qa-grid    { grid-template-columns: 1fr 1fr; }
    .qa-btn     { font-size: 9px; padding: 6px 4px; }

    /* Skills tab: full-width stacked */
    .skills-sidebar {
        max-height: 140px;
        padding: 6px;
    }
    .skills-graph-wrap { min-height: 260px; }
    .skill-tooltip { max-width: 160px; padding: 7px 10px; font-size: 10px; }
    .stt-name { font-size: 12px; }
}

/* ── Very small (≤ 380px): tighten further ── */
@media (max-width: 380px) {
    .brand-name { font-size: 12px; }
    .dash-clock { font-size: 13px; letter-spacing: 1px; }
    .nexus-core { width: 160px; height: 160px; }
    .nc-svg     { width: 160px; height: 160px; }
    .tab-btn    { padding: 4px 10px; }
}
