/* ============================================================
   ServerHealthMonitor — Design System
   Dark theme, glassmorphism cards, animated progress bars
   ============================================================ */

/* --- Custom Properties (Tokens) --- */
:root {
    /* Background & Surface */
    --bg-primary: #0b0e14;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-border: rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Severity Colors */
    --color-healthy: #10b981;
    --color-healthy-soft: rgba(16, 185, 129, 0.15);
    --color-healthy-glow: rgba(16, 185, 129, 0.3);

    --color-warning: #f59e0b;
    --color-warning-soft: rgba(245, 158, 11, 0.15);
    --color-warning-glow: rgba(245, 158, 11, 0.3);

    --color-critical: #ef4444;
    --color-critical-soft: rgba(239, 68, 68, 0.15);
    --color-critical-glow: rgba(239, 68, 68, 0.3);

    /* Accent */
    --color-accent: #6366f1;
    --color-accent-soft: rgba(99, 102, 241, 0.15);

    /* Metric Colors */
    --color-cpu: #818cf8;
    --color-cpu-soft: rgba(129, 140, 248, 0.15);
    --color-memory: #c084fc;
    --color-memory-soft: rgba(192, 132, 252, 0.15);
    --color-disk: #34d399;
    --color-disk-soft: rgba(52, 211, 153, 0.15);
    --color-process: #60a5fa;
    --color-process-soft: rgba(96, 165, 250, 0.15);

    /* Layout */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.08);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

/* --- Layout --- */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.app-header {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--bg-glass-border);
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-md);
    color: var(--color-accent);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
}

/* --- Health Banner --- */
.health-banner {
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.75rem;
    border: 1px solid;
    backdrop-filter: blur(12px);
    transition: all var(--transition-base);
}

.health-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.health-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.health-label {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.health-refresh-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Health Banner States */
.health-healthy {
    background: var(--color-healthy-soft);
    border-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 30px var(--color-healthy-glow);
}
.health-healthy .health-label { color: var(--color-healthy); }

.health-warning {
    background: var(--color-warning-soft);
    border-color: rgba(245, 158, 11, 0.25);
    box-shadow: 0 0 30px var(--color-warning-glow);
}
.health-warning .health-label { color: var(--color-warning); }

.health-critical {
    background: var(--color-critical-soft);
    border-color: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 30px var(--color-critical-glow);
    animation: critical-pulse 2s ease-in-out infinite;
}
.health-critical .health-label { color: var(--color-critical); }

/* Health Dot */
.health-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
}

.health-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    animation: dot-pulse 2s ease-in-out infinite;
}

.health-dot-healthy {
    background: var(--color-healthy);
    box-shadow: 0 0 8px var(--color-healthy-glow);
}
.health-dot-healthy::after {
    border: 2px solid var(--color-healthy);
    opacity: 0;
    animation: dot-pulse 2s ease-in-out infinite;
}

.health-dot-warning {
    background: var(--color-warning);
    box-shadow: 0 0 8px var(--color-warning-glow);
}
.health-dot-warning::after {
    border: 2px solid var(--color-warning);
    opacity: 0;
    animation: dot-pulse 1.5s ease-in-out infinite;
}

.health-dot-critical {
    background: var(--color-critical);
    box-shadow: 0 0 8px var(--color-critical-glow);
}
.health-dot-critical::after {
    border: 2px solid var(--color-critical);
    opacity: 0;
    animation: dot-pulse 1s ease-in-out infinite;
}

/* --- Metrics Grid --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

/* --- Metric Card (Glassmorphism) --- */
.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.metric-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* --- Metric Header --- */
.metric-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.cpu-icon { background: var(--color-cpu-soft); color: var(--color-cpu); }
.memory-icon { background: var(--color-memory-soft); color: var(--color-memory); }
.disk-icon { background: var(--color-disk-soft); color: var(--color-disk); }
.process-icon { background: var(--color-process-soft); color: var(--color-process); }
.process-running { background: var(--color-healthy-soft); color: var(--color-healthy); }
.process-stopped { background: var(--color-critical-soft); color: var(--color-critical); }

.metric-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* --- CPU Values --- */
.cpu-values {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.cpu-value-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.cpu-period {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.375rem;
}

.cpu-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.cpu-divider {
    width: 1px;
    height: 48px;
    background: var(--bg-glass-border);
    flex-shrink: 0;
}

/* --- Metric Main Value --- */
.metric-main-value {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.big-number {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.metric-detail {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* --- Value States --- */
.value-warning { color: var(--color-warning) !important; }
.value-critical { color: var(--color-critical) !important; }

/* --- Progress Bar --- */
.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width var(--transition-slow);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

.fill-healthy {
    background: linear-gradient(90deg, var(--color-healthy), #34d399);
    box-shadow: 0 0 12px var(--color-healthy-glow);
}

.fill-warning {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
    box-shadow: 0 0 12px var(--color-warning-glow);
}

.fill-critical {
    background: linear-gradient(90deg, var(--color-critical), #f87171);
    box-shadow: 0 0 12px var(--color-critical-glow);
    animation: critical-bar-pulse 1.5s ease-in-out infinite;
}

/* --- Process Status --- */
.process-status {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 0;
}

.process-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.dot-running {
    background: var(--color-healthy);
    box-shadow: 0 0 12px var(--color-healthy-glow);
    animation: process-pulse 2s ease-in-out infinite;
}

.dot-stopped {
    background: var(--color-critical);
    box-shadow: 0 0 12px var(--color-critical-glow);
}

.process-label {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.label-running { color: var(--color-healthy); }
.label-stopped { color: var(--color-critical); }

/* --- Footer --- */
.app-footer {
    padding: 1.5rem 0;
    border-top: 1px solid var(--bg-glass-border);
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* --- Animations --- */
@keyframes dot-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

@keyframes process-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

@keyframes critical-pulse {
    0%, 100% { box-shadow: 0 0 30px var(--color-critical-glow); }
    50% { box-shadow: 0 0 50px var(--color-critical-glow), 0 0 80px rgba(239, 68, 68, 0.15); }
}

@keyframes critical-bar-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

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

    .health-banner-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .big-number {
        font-size: 1.625rem;
    }

    .cpu-value {
        font-size: 1.125rem;
    }

    .metric-card {
        padding: 1.25rem;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
