/* ============================================
   AI Mission Control - Cyberpunk Dashboard
   ============================================ */

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

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #0d1117;
    --bg-panel: rgba(0, 20, 40, 0.85);
    --border-glow: rgba(0, 255, 136, 0.3);
    --text-primary: #e0e0e0;
    --text-green: #00ff88;
    --text-blue: #00aaff;
    --text-cyan: #00ffee;
    --text-yellow: #ffcc00;
    --text-red: #ff4444;
    --text-dim: #446688;
    --accent-green: #00ff88;
    --accent-blue: #0088ff;
    --accent-purple: #8844ff;
    --glow-green: 0 0 20px rgba(0, 255, 136, 0.3), 0 0 40px rgba(0, 255, 136, 0.1);
    --glow-blue: 0 0 20px rgba(0, 170, 255, 0.3), 0 0 40px rgba(0, 170, 255, 0.1);
    --font-mono: "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    --font-cn: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-cn);
    font-size: 13px;
}

/* Scanline effect overlay */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 136, 0.015) 2px,
        rgba(0, 255, 136, 0.015) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* Corner decorations */
.corner-deco {
    position: fixed;
    width: 30px;
    height: 30px;
    z-index: 100;
    pointer-events: none;
}
.corner-deco.top-left {
    top: 8px; left: 8px;
    border-top: 2px solid var(--accent-green);
    border-left: 2px solid var(--accent-green);
}
.corner-deco.top-right {
    top: 8px; right: 8px;
    border-top: 2px solid var(--accent-green);
    border-right: 2px solid var(--accent-green);
}
.corner-deco.bottom-left {
    bottom: 8px; left: 8px;
    border-bottom: 2px solid var(--accent-green);
    border-left: 2px solid var(--accent-green);
}
.corner-deco.bottom-right {
    bottom: 8px; right: 8px;
    border-bottom: 2px solid var(--accent-green);
    border-right: 2px solid var(--accent-green);
}

/* ---- Stats Bar (Top) ---- */
#stats-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 10px 20px;
    z-index: 100;
    background: linear-gradient(180deg, rgba(10,10,26,0.95) 0%, rgba(10,10,26,0) 100%);
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 105px;
    padding: 8px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-glow);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-green), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

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

.stat-icon {
    font-size: 14px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 17px;
    font-weight: bold;
    color: var(--text-green);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    font-family: var(--font-mono);
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.stat-label {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
    font-family: var(--font-cn);
}

/* ---- Glass Panel Base ---- */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-green);
    letter-spacing: 2px;
    font-family: var(--font-cn);
}

.header-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.header-dot.pulse {
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent-green); }
    50% { opacity: 0.4; box-shadow: 0 0 4px var(--accent-green); }
}

.panel-divider {
    height: 1px;
    margin: 0 16px;
    background: linear-gradient(90deg, transparent, var(--border-glow), transparent);
}

/* ---- Left Panel ---- */
#left-panel {
    position: fixed;
    top: 80px;
    left: 16px;
    width: 280px;
    bottom: 90px;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

#system-info, #brain-info {
    padding: 8px 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 255, 136, 0.05);
}

.info-label {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 1px;
    font-family: var(--font-cn);
}

.info-value {
    color: var(--text-cyan);
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-cn);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot.running {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: dotPulse 1.5s ease-in-out infinite;
}

.status-dot.stopped {
    background: var(--text-red);
    box-shadow: 0 0 8px var(--text-red);
}

.status-dot.thinking {
    background: var(--text-blue);
    box-shadow: 0 0 8px var(--text-blue);
    animation: dotPulse 0.8s ease-in-out infinite;
}

.status-dot.offline {
    background: #666;
}

/* Trust levels */
#trust-levels {
    padding: 8px 16px;
}

.trust-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.trust-label {
    width: 32px;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
    font-family: var(--font-cn);
}

.trust-track {
    flex: 1;
    height: 4px;
    background: rgba(0, 255, 136, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.trust-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--text-cyan));
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.4);
}

.trust-val {
    width: 16px;
    font-size: 11px;
    color: var(--text-green);
    text-align: right;
    font-family: var(--font-mono);
}

/* Last thought box */
.thought-box {
    padding: 8px 16px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-primary);
    opacity: 0.85;
    max-height: 80px;
    overflow-y: auto;
    font-family: var(--font-cn);
}

.thought-box::-webkit-scrollbar {
    width: 2px;
}

.thought-box::-webkit-scrollbar-thumb {
    background: var(--border-glow);
}

/* Capabilities list */
.capabilities-container {
    padding: 8px 16px 12px;
}

.capability-group {
    margin-bottom: 8px;
}

.capability-group-label {
    font-size: 10px;
    color: var(--text-blue);
    letter-spacing: 1px;
    margin-bottom: 4px;
    font-family: var(--font-cn);
}

.capability-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.capability-tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 9px;
    color: var(--text-cyan);
    background: rgba(0, 170, 255, 0.08);
    border: 1px solid rgba(0, 170, 255, 0.2);
    border-radius: 10px;
    font-family: var(--font-cn);
    transition: all 0.2s ease;
}

.capability-tag:hover {
    background: rgba(0, 170, 255, 0.15);
    border-color: rgba(0, 170, 255, 0.4);
}

.capability-tag.active {
    color: var(--text-green);
    background: rgba(0, 255, 136, 0.08);
    border-color: rgba(0, 255, 136, 0.3);
}

/* ---- Brain Container (Center) ---- */
#brain-container {
    position: fixed;
    top: 70px;
    left: 300px;
    right: 280px;
    bottom: 80px;
    z-index: 1;
}

#brain-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ---- Right Panel ---- */
#right-panel {
    position: fixed;
    top: 80px;
    right: 16px;
    width: 260px;
    bottom: 90px;
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#activity-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    scroll-behavior: smooth;
}

#activity-log::-webkit-scrollbar {
    width: 3px;
}

#activity-log::-webkit-scrollbar-track {
    background: transparent;
}

#activity-log::-webkit-scrollbar-thumb {
    background: var(--border-glow);
    border-radius: 3px;
}

.activity-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    border-left: 2px solid var(--border-glow);
    font-size: 11px;
    line-height: 1.5;
    opacity: 0;
    transform: translateX(20px);
    animation: slideIn 0.3s ease forwards;
    transition: background 0.2s ease;
    border-radius: 0 4px 4px 0;
    font-family: var(--font-cn);
}

.activity-item:hover {
    background: rgba(0, 255, 136, 0.05);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.activity-time {
    color: var(--text-dim);
    font-size: 10px;
    margin-right: 6px;
    font-family: var(--font-mono);
}

.activity-icon {
    margin-right: 4px;
}

.activity-text {
    color: var(--text-primary);
    font-family: var(--font-cn);
}

/* Activity type colors with left border and text tinting */
.activity-item.type-search {
    border-left-color: var(--text-blue);
}
.activity-item.type-search .activity-text {
    color: #88ccff;
}

.activity-item.type-price {
    border-left-color: var(--text-yellow);
}
.activity-item.type-price .activity-text {
    color: #ffdd66;
}

.activity-item.type-thought {
    border-left-color: var(--accent-purple);
}
.activity-item.type-thought .activity-text {
    color: #bb88ff;
}

.activity-item.type-check {
    border-left-color: var(--accent-green);
}
.activity-item.type-check .activity-text {
    color: #66ffaa;
}

.activity-item.type-evolve {
    border-left-color: var(--text-cyan);
}
.activity-item.type-evolve .activity-text {
    color: #66ffee;
}

.activity-item.type-error {
    border-left-color: var(--text-red);
    background: rgba(255, 68, 68, 0.05);
}
.activity-item.type-error .activity-text {
    color: #ff7777;
}

.activity-item.type-system {
    border-left-color: var(--accent-green);
}
.activity-item.type-system .activity-text {
    color: #88ffbb;
}

.activity-item.type-notify {
    border-left-color: var(--text-yellow);
}
.activity-item.type-notify .activity-text {
    color: #ffdd88;
}

/* Activity detail (expandable) */
.activity-detail {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 3px;
    padding-left: 20px;
    line-height: 1.4;
    display: none;
    font-family: var(--font-cn);
}

.activity-item.expanded .activity-detail {
    display: block;
}

/* ---- Timeline Bar (Bottom) ---- */
#timeline-bar {
    position: fixed;
    bottom: 12px;
    left: 16px;
    right: 16px;
    height: 68px;
    z-index: 100;
    overflow: hidden;
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-green);
    letter-spacing: 2px;
    font-family: var(--font-cn);
}

.timeline-info {
    margin-left: auto;
    color: var(--text-dim);
    font-weight: normal;
    font-size: 10px;
    letter-spacing: 1px;
    font-family: var(--font-cn);
}

#timeline {
    padding: 4px 16px 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

#timeline::-webkit-scrollbar {
    height: 2px;
}

#timeline::-webkit-scrollbar-thumb {
    background: var(--border-glow);
}

#timeline-track {
    position: relative;
    height: 30px;
    min-width: 100%;
    display: flex;
    align-items: center;
}

#timeline-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-glow) 5%, var(--border-glow) 95%, transparent);
    transform: translateY(-50%);
}

#timeline-dots {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    z-index: 1;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.timeline-dot.success {
    border-color: var(--accent-green);
    background: rgba(0, 255, 136, 0.3);
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.3);
}

.timeline-dot.failed {
    border-color: var(--text-red);
    background: rgba(255, 68, 68, 0.3);
    box-shadow: 0 0 6px rgba(255, 68, 68, 0.3);
}

.timeline-dot.partial {
    border-color: var(--text-yellow);
    background: rgba(255, 204, 0, 0.3);
    box-shadow: 0 0 6px rgba(255, 204, 0, 0.3);
}

.timeline-dot.pending {
    border-color: var(--text-dim);
    background: rgba(68, 102, 136, 0.3);
}

.timeline-dot:hover {
    transform: scale(1.5);
    box-shadow: 0 0 12px currentColor;
}

.timeline-dot .tooltip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 10, 20, 0.95);
    border: 1px solid var(--border-glow);
    border-radius: 4px;
    padding: 6px 10px;
    white-space: nowrap;
    font-size: 10px;
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 200;
    font-family: var(--font-cn);
    max-width: 250px;
    white-space: normal;
}

.timeline-dot:hover .tooltip {
    opacity: 1;
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card {
    animation: fadeInUp 0.5s ease forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card:nth-child(5) { animation-delay: 0.5s; }
.stat-card:nth-child(6) { animation-delay: 0.6s; }

/* Value update flash */
.value-updated {
    animation: valueFlash 0.6s ease;
}

@keyframes valueFlash {
    0% { color: #fff; text-shadow: 0 0 20px #fff; transform: scale(1.15); }
    50% { color: #aaffcc; text-shadow: 0 0 15px rgba(0, 255, 136, 0.8); }
    100% { color: var(--text-green); text-shadow: 0 0 10px rgba(0, 255, 136, 0.5); transform: scale(1); }
}

/* Counter animation helper */
.counting-up {
    transition: color 0.3s ease;
}

/* ---- Status badge styles ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: var(--font-cn);
}

.status-badge.running {
    background: rgba(0, 255, 136, 0.15);
    color: var(--text-green);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.status-badge.stopped {
    background: rgba(255, 68, 68, 0.15);
    color: var(--text-red);
    border: 1px solid rgba(255, 68, 68, 0.3);
}

.status-badge.offline {
    background: rgba(102, 102, 102, 0.15);
    color: #888;
    border: 1px solid rgba(102, 102, 102, 0.3);
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    #left-panel { width: 240px; }
    #right-panel { width: 220px; }
    #brain-container { left: 260px; right: 240px; }
}

@media (max-width: 900px) {
    #left-panel { display: none; }
    #right-panel { display: none; }
    #brain-container { left: 16px; right: 16px; }
    #stats-bar { gap: 6px; padding: 10px 10px; }
    .stat-card { min-width: 70px; padding: 6px 10px; }
    .stat-value { font-size: 14px; }
}

@media (max-width: 600px) {
    .stat-card { min-width: 55px; padding: 4px 6px; }
    .stat-icon { display: none; }
    .stat-value { font-size: 12px; }
    .stat-label { font-size: 8px; }
}

/* ---- Custom scrollbar for left panel ---- */
#left-panel::-webkit-scrollbar {
    width: 3px;
}

#left-panel::-webkit-scrollbar-track {
    background: transparent;
}

#left-panel::-webkit-scrollbar-thumb {
    background: var(--border-glow);
    border-radius: 3px;
}

/* ---- Health status colors ---- */
.health-good {
    color: var(--text-green) !important;
}

.health-warn {
    color: var(--text-yellow) !important;
}

.health-bad {
    color: var(--text-red) !important;
}

/* ---- Evolution Panel (AI Thinking) ---- */
.evolution-panel {
    position: fixed;
    bottom: 88px;
    right: 284px;
    width: 320px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 101;
    animation: fadeInUp 0.5s ease forwards;
}

.evolution-panel .panel-header {
    padding: 10px 16px 6px;
}

.evolution-title {
    font-size: 12px;
    letter-spacing: 2px;
}

.evolution-panel::-webkit-scrollbar {
    width: 3px;
}

.evolution-panel::-webkit-scrollbar-thumb {
    background: var(--border-glow);
    border-radius: 3px;
}

.thought-bubble {
    background: rgba(0, 170, 255, 0.08);
    border-left: 3px solid var(--text-blue);
    padding: 10px 12px;
    margin: 8px 12px;
    border-radius: 0 8px 8px 0;
    transition: background 0.3s ease;
}

.thought-bubble:hover {
    background: rgba(0, 170, 255, 0.15);
}

.thought-text {
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-cn);
}

.thought-meta {
    color: var(--text-dim);
    font-size: 10px;
    margin-top: 8px;
    font-family: var(--font-cn);
    letter-spacing: 0.5px;
}

.evolution-events {
    padding: 4px 12px 8px;
}

.evolution-event-item {
    display: flex;
    gap: 6px;
    padding: 3px 0;
    font-size: 10px;
    border-bottom: 1px solid rgba(0, 255, 136, 0.05);
}

.evolution-event-time {
    color: var(--text-dim);
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
}

.evolution-event-text {
    color: var(--text-primary);
    font-family: var(--font-cn);
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Adjust left panel position when evolution panel is visible */
@media (min-width: 1200px) {
    .evolution-panel {
        /* On wide screens, position in the center-bottom area */
        bottom: 88px;
        right: 284px;
        width: 360px;
    }
}

@media (max-width: 1199px) and (min-width: 901px) {
    .evolution-panel {
        right: 246px;
        width: 300px;
    }
}

@media (max-width: 900px) {
    .evolution-panel {
        display: none;
    }
}
