/* REX Dashboard Styles */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --accent: #e94560;
    --accent-secondary: #00d9ff;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --success: #00c853;
    --warning: #ffc107;
    --error: #ff5252;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: var(--success);
}

.status-indicator.disconnected {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
}

.chart-container h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 500;
}

/* Latency Breakdown */
.latency-breakdown {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.latency-breakdown h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 500;
}

.latency-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.latency-item {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    align-items: center;
    gap: 15px;
}

.latency-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.latency-bar-container {
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.latency-bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.latency-bar.vad {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.latency-bar.whisper {
    background: linear-gradient(90deg, #f093fb, #f5576c);
}

.latency-bar.execute {
    background: linear-gradient(90deg, #4facfe, #00f2fe);
}

.latency-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    text-align: right;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* System Resources */
.resources-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.resources-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 500;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .resource-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.resource-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.resource-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.resource-bar-container {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.resource-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 0;
}

.resource-bar.cpu-bar {
    background: linear-gradient(90deg, #00d9ff, #0099cc);
}

.resource-bar.memory-bar {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.resource-bar.gpu-bar {
    background: linear-gradient(90deg, #f5576c, #e94560);
}

.resource-bar.vram-bar {
    background: linear-gradient(90deg, #ffd93d, #ff9500);
}

.resource-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: 'Monaco', 'Consolas', monospace;
}

.gpu-info {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Recent Activity Table */
.recent-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
}

.recent-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 500;
}

.recent-table {
    width: 100%;
    border-collapse: collapse;
}

.recent-table th,
.recent-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.recent-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 500;
}

.recent-table td {
    font-size: 0.9rem;
}

.recent-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.recent-table .matched {
    color: var(--success);
}

.recent-table .unmatched {
    color: var(--text-secondary);
    font-style: italic;
}

.recent-table .command-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
}

.recent-table .latency-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--accent-secondary);
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px !important;
}

/* Responsive */
@media (max-width: 768px) {
    .charts-row {
        grid-template-columns: 1fr;
    }

    .latency-item {
        grid-template-columns: 60px 1fr 60px;
    }

    .stat-value {
        font-size: 2rem;
    }
}
