/* ═══════════════════════════════════════════════════════════════
   Server Monitor Dashboard — Styles
   Dark theme with glassmorphism, modern gauges & animations
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 102, 241, 0.15);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #6366f1;
    --accent-cyan: #22d3ee;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #a78bfa;

    --cpu-color: #6366f1;
    --mem-color: #22d3ee;
    --gpu-color: #10b981;
    --gpu-mem-color: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.08);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

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

/* ── Header ────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 2rem;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: var(--radius-md);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition-normal);
}

.status-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: pulse-dot 2s infinite;
}

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

.last-updated {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ── Server Grid ───────────────────────────────────────────────── */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.5rem;
}

/* ── Server Card ───────────────────────────────────────────────── */
.server-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.server-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-cyan), transparent);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

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

.server-card:hover::before {
    opacity: 1;
}

.server-card.online {
    border-color: rgba(16, 185, 129, 0.12);
}

.server-card.offline {
    opacity: 0.65;
}

/* ── Card Header ───────────────────────────────────────────────── */
.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-hostname {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.card-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-dot-sm {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.card-status.online .status-dot-sm {
    animation: pulse-dot 2s infinite;
}

/* ── System Info Tags ──────────────────────────────────────────── */
.system-info {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.sys-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

/* ── Gauges ─────────────────────────────────────────────────────── */
.gauges-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.gauge-ring {
    position: relative;
    width: 100px;
    height: 100px;
}

.gauge-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.04);
    stroke-width: 8;
}

.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.cpu-fill { stroke: var(--cpu-color); filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4)); }
.mem-fill { stroke: var(--mem-color); filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.4)); }
.gpu-fill { stroke: var(--gpu-color); filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4)); }

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gauge-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Detail Stats ──────────────────────────────────────────────── */
.detail-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-section {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem;
}

.stat-section-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-section-title svg {
    opacity: 0.6;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

/* ── Core Bars ─────────────────────────────────────────────────── */
.core-bars {
    display: flex;
    gap: 3px;
    margin-top: 0.5rem;
    height: 20px;
    align-items: flex-end;
}

.core-bar {
    flex: 1;
    border-radius: 2px;
    background: rgba(99, 102, 241, 0.15);
    position: relative;
    overflow: hidden;
    min-width: 4px;
    max-width: 12px;
    height: 100%;
}

.core-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--cpu-color);
    border-radius: 2px;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── GPU Detail Rows ───────────────────────────────────────────── */
.gpu-card {
    padding: 0.4rem 0;
}

.gpu-card + .gpu-card {
    border-top: 1px solid var(--border-color);
    margin-top: 0.4rem;
    padding-top: 0.6rem;
}

.gpu-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-green);
    margin-bottom: 0.3rem;
}

.gpu-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.2rem 0;
}

.gpu-bar-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    min-width: 40px;
}

.gpu-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.gpu-bar-inner {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.gpu-bar-inner.usage { background: var(--gpu-color); }
.gpu-bar-inner.memory { background: var(--gpu-mem-color); }

.gpu-bar-value {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

.gpu-temp {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--accent-amber);
}

/* ── Disk Bars ─────────────────────────────────────────────────── */
.disk-row {
    margin-bottom: 0.4rem;
}

.disk-mount {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.disk-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.disk-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.disk-bar-inner {
    height: 100%;
    border-radius: 3px;
    background: var(--accent-purple);
    transition: width 0.6s ease;
}

.disk-bar-value {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

/* ── Mini Chart ────────────────────────────────────────────────── */
.mini-chart-container {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.7rem;
    margin-top: 0.5rem;
}

/* ── Footer ────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

/* ── Utility ───────────────────────────────────────────────────── */
.text-green { color: var(--accent-green); }
.text-amber { color: var(--accent-amber); }
.text-red   { color: var(--accent-red); }

/* ── Animations ────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.server-card {
    animation: fadeIn 0.5s ease both;
}

.server-card:nth-child(2) { animation-delay: 0.1s; }
.server-card:nth-child(3) { animation-delay: 0.2s; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .server-grid {
        grid-template-columns: 1fr;
    }
    .main-content {
        padding: 1rem;
    }
    .header {
        flex-direction: column;
        gap: 0.8rem;
        align-items: flex-start;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 500px) {
    .detail-stats {
        grid-template-columns: 1fr;
    }
    .gauges-row {
        gap: 0.25rem;
    }
    .gauge-ring {
        width: 80px;
        height: 80px;
    }
    .gauge-value {
        font-size: 1rem;
    }
}
