/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2233;
    --bg-card-hover: #1e2a3f;
    --border: #2a3a52;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --glow-blue: rgba(59, 130, 246, 0.15);
    --glow-green: rgba(16, 185, 129, 0.15);
    --glow-red: rgba(239, 68, 68, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent-red);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: blink 2s infinite;
}

.status-badge.error .status-dot {
    background: var(--accent-red);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.hostname {
    font-size: 13px;
    color: var(--accent-cyan);
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(6, 182, 212, 0.1);
    border-radius: 6px;
}

.uptime, .timestamp {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== INFO BAR ===== */
.info-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
    overflow-x: auto;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.info-item i {
    color: var(--accent-blue);
    width: 16px;
    text-align: center;
}

/* ===== DASHBOARD GRID ===== */
.dashboard {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

/* ===== CARD ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.card-wide {
    grid-column: 1 / -1;
}

.card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), transparent);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-header h2 i {
    font-size: 16px;
}

.card-cpu .card-header h2 i { color: var(--accent-blue); }
.card-ram .card-header h2 i { color: var(--accent-purple); }
.card-disk .card-header h2 i { color: var(--accent-orange); }
.card-network .card-header h2 i { color: var(--accent-cyan); }
.card-load .card-header h2 i { color: var(--accent-yellow); }
.card-swap .card-header h2 i { color: var(--accent-pink); }
.card-speedtest .card-header h2 i { color: var(--accent-green); }
.card-processes .card-header h2 i { color: var(--accent-red); }

.card-value {
    font-size: 22px;
    font-weight: 700;
}

.card-cpu .card-value { color: var(--accent-blue); }
.card-ram .card-value { color: var(--accent-purple); }
.card-disk .card-value { color: var(--accent-orange); }
.card-network .card-value { color: var(--accent-cyan); }
.card-swap .card-value { color: var(--accent-pink); }

.card-body {
    padding: 20px;
}

.card-chart {
    padding: 0 16px 16px;
    height: 140px;
}

.card-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ===== GAUGE ===== */
.gauge-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 16px;
}

.gauge-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-percent {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.gauge-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== DETAIL ROWS ===== */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-row:last-child { border-bottom: none; }

.detail-row span:first-child { color: var(--text-secondary); }
.detail-row span:last-child { color: var(--text-primary); font-weight: 500; }

/* ===== CORE BARS ===== */
.core-bars {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    margin-top: 12px;
}

.core-bar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.core-bar-item .bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.core-bar-item .bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent-blue);
    transition: width 0.5s ease;
}

/* ===== DISK PARTITIONS ===== */
.disk-partitions {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.disk-part {
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.disk-part-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.disk-part-mount {
    font-weight: 600;
    color: var(--accent-orange);
}

.disk-part-device {
    color: var(--text-muted);
    font-size: 11px;
}

.disk-part-percent {
    font-weight: 700;
    font-size: 15px;
}

.disk-part-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.disk-part-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.disk-part-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== NETWORK ===== */
.network-interfaces {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.net-iface {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.net-iface-name {
    font-weight: 600;
    color: var(--accent-cyan);
}

.net-iface-ip {
    color: var(--text-secondary);
}

.net-iface-traffic {
    font-size: 11px;
    color: var(--text-muted);
}

.net-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.net-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}

.net-stat i {
    font-size: 20px;
}

.net-stat.download i { color: var(--accent-green); }
.net-stat.upload i { color: var(--accent-blue); }

.net-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.net-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== LOAD AVERAGE ===== */
.load-averages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.load-item {
    text-align: center;
    padding: 14px 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.load-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-yellow);
}

.load-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.running-procs {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 8px 0;
    color: var(--text-secondary);
}

#runningProcs { color: var(--text-primary); font-weight: 600; }

/* ===== SWAP ===== */
.swap-bar-container {
    padding: 8px 0;
}

.progress-bar-bg {
    height: 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple));
    transition: width 0.5s ease;
}

/* ===== SPEED TEST ===== */
.btn-speedtest {
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-speedtest:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-speedtest:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.speed-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    text-align: center;
}

.speed-result {
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.speed-result i {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

.speed-result:nth-child(1) i { color: var(--accent-yellow); }
.speed-result:nth-child(2) i { color: var(--accent-green); }
.speed-result:nth-child(3) i { color: var(--accent-blue); }

.speed-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.speed-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.speed-progress {
    margin-top: 16px;
    text-align: center;
}

.speed-progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.speed-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
    transition: width 0.3s ease;
    width: 0%;
}

.speed-progress-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== PROCESS TABLE ===== */
.process-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.process-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.process-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.process-table tr:hover td {
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-primary);
}

.process-table .cpu-high { color: var(--accent-red); font-weight: 600; }
.process-table .cpu-mid { color: var(--accent-yellow); font-weight: 500; }
.process-table .cpu-low { color: var(--accent-green); }

.loading-text {
    text-align: center;
    color: var(--text-muted);
    padding: 20px !important;
}

/* ===== FOOTER ===== */
.footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 24px;
}

/* ===== COLOR HELPERS ===== */
.color-green { color: var(--accent-green) !important; }
.color-yellow { color: var(--accent-yellow) !important; }
.color-orange { color: var(--accent-orange) !important; }
.color-red { color: var(--accent-red) !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
        padding: 12px;
    }
    .header {
        flex-direction: column;
        text-align: center;
    }
    .header-right {
        justify-content: center;
    }
    .info-bar {
        justify-content: center;
    }
    .speed-results {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .load-averages {
        grid-template-columns: repeat(3, 1fr);
    }
    .net-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header h1 { font-size: 16px; }
    .card-value { font-size: 18px; }
    .gauge-container { width: 130px; height: 130px; }
    .gauge-percent { font-size: 22px; }
    .process-table { font-size: 11px; }
    .process-table th, .process-table td { padding: 6px 8px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }
