/* 
  Redis Mastery Lab - Minimal Dark Dashboard Theme 
  Fonts: Inter (UI), JetBrains Mono (Data/Code)
*/

:root {
    --bg-main: #0B0E14;        /* Deep Charcoal / Near Black */
    --bg-surface: #151821;     /* Slightly lighter for panels */
    --bg-sidebar: #0F1219;
    --border-color: #2A2E39;
    
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    --redis-red: #DC382D;      /* Core brand accent */
    --redis-red-dim: rgba(220, 56, 45, 0.15);
    
    --accent-cyan: #00F0FF;    /* Tech highlight */
    --accent-cyan-dim: rgba(0, 240, 255, 0.1);
    
    --status-live: #10B981;    /* Green */
    --status-dead: #EF4444;    /* Red */
    --status-warn: #F59E0B;    /* Yellow */
    
    --radius-sm: 4px;
    --radius-md: 8px;
    
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; display: flex; align-items: center; gap: 8px; }
h2 svg { width: 18px; height: 18px; color: var(--text-secondary); }

p { font-size: 0.875rem; color: var(--text-secondary); }
code, pre { font-family: var(--font-mono); font-size: 0.8125rem; }

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon .brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(220, 56, 45, 0.5));
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-item svg { width: 16px; height: 16px; opacity: 0.7; }

.nav-item:hover {
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-surface);
    color: var(--accent-cyan);
    border-color: var(--border-color);
}
.nav-item.active svg { color: var(--accent-cyan); opacity: 1; }

.system-status {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}
.dot.live { background-color: var(--status-live); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.dot.dead { background-color: var(--status-dead); }

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at top right, rgba(220,56,45,0.03) 0%, transparent 40%),
                radial-gradient(circle at bottom left, rgba(0,240,255,0.02) 0%, transparent 40%);
}

.topbar {
    height: 70px;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 18, 25, 0.8);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.breadcrumbs {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.session-badge {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-badge code { color: var(--accent-cyan); }

/* Dashboard Grid */
.dashboard-grid {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: min-content;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Panels */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.2s, border-color 0.2s;
}

.panel:hover {
    border-color: rgba(220, 56, 45, 0.3);
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.01);
}

.panel-body {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-response {
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    min-height: 100px;
    max-height: 250px;
    overflow-y: auto;
}

.panel-response pre {
    margin: 0;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Specific Panel Sizing */
.session-panel { grid-column: span 8; }
.rate-limit-panel { grid-column: span 4; }
.queue-panel { grid-column: span 6; }
.pubsub-panel { grid-column: span 6; }
.leaderboard-panel { grid-column: span 12; }

/* Forms & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.row {
    flex-direction: row;
    align-items: center;
}

label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

input, select {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

input:focus, select:focus {
    border-color: var(--accent-cyan);
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Buttons */
.btn {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover { background: var(--bg-surface); border-color: var(--text-muted); }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--redis-red);
    border-color: var(--redis-red);
    color: white;
}
.btn-primary:hover { background: #b82b22; border-color: #b82b22; }

.btn-accent {
    background: var(--accent-cyan-dim);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}
.btn-accent:hover { background: rgba(0,240,255,0.15); }

.btn-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--status-warn);
    color: var(--status-warn);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.2); }

.btn-group { display: flex; gap: 8px; }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
}
.icon-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.icon-btn svg { width: 16px; height: 16px; }

/* Badges & Status */
.badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
}
.ttl-badge { color: var(--status-warn); border-color: rgba(245,158,11,0.3); }

.status-box {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
}
.status-box.allowed { color: var(--status-live); border-color: rgba(16,185,129,0.3); }
.status-box.blocked { color: var(--status-dead); border-color: rgba(239,68,68,0.3); }

/* Leaderboard List */
.list-wrapper { padding: 0; }
.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}
.leaderboard-list li {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list li:hover { background: rgba(255,255,255,0.02); }

.rank {
    width: 30px;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.lb-user { color: var(--accent-cyan); flex-grow: 1; }
.lb-score { color: var(--text-primary); }

.empty-state {
    padding: 2rem !important;
    text-align: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Syntax Highlighting overrides for JSON */
.language-json .key { color: #9CDCFE; } /* Light blue */
.language-json .string { color: #CE9178; } /* Orange/Brown */
.language-json .number { color: #B5CEA8; } /* Light green */
.language-json .boolean { color: #569CD6; } /* Blue keyword */
.language-json .null { color: #569CD6; }

/* Narrative / Living Story Boxes */
.narrative-box {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(0, 240, 255, 0.05); /* Very subtle cyan glow */
    border-left: 3px solid var(--accent-cyan);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.825rem;
    color: var(--accent-cyan);
    font-style: italic;
    line-height: 1.4;
    display: none; /* Hidden by default */
    animation: fadeIn 0.4s ease-out;
}

.narrative-box.visible {
    display: block;
}

.narrative-box .narrative-title {
    display: block;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    opacity: 0.8;
}

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

.typewriter-text {
    overflow: hidden;
    white-space: normal;
    animation: typing 2s steps(40, end);
}

@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

/* Enhancing existing components for a cooler feel */
.panel {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.panel-header h2 svg {
    transition: transform 0.3s ease;
}

.panel:hover .panel-header h2 svg {
    transform: scale(1.1) rotate(5deg);
    color: var(--redis-red);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .session-panel { grid-column: span 12; }
    .rate-limit-panel { grid-column: span 12; }
}

@media (max-width: 900px) {
    .queue-panel, .pubsub-panel { grid-column: span 12; }
    .sidebar { width: 80px; padding: 1rem; }
    .sidebar .brand h1, .sidebar .nav-item span, .sidebar .system-status span { display: none; }
    .nav-item { justify-content: center; padding: 12px 0; }
    .status-indicator { justify-content: center; }
}
