:root {
    /* Dark Theme Variables (Default) */
    --bg-color: #0b0f19;
    --card-bg: rgba(20, 27, 45, 0.6);
    --card-border: rgba(255, 255, 255, 0.05);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --success: #10b981;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;
}

body.theme-light {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.05);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.3);
}

body.theme-amoled {
    --bg-color: #000000;
    --card-bg: #09090b;
    --card-border: #27272a;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --accent: #3b82f6;
    --accent-glow: transparent;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

/* Glassmorphism background effect */
body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 50% 50%, var(--accent-glow) 0%, transparent 50%);
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

body.theme-amoled .top-nav, 
body.theme-amoled .server-card,
body.theme-amoled .metric-box {
    backdrop-filter: none;
    box-shadow: none;
}
body.theme-amoled::before {
    display: none;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 1px;
}

.pulse-dot {
    width: 12px; height: 12px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.controls button, .controls a {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 14px;
    margin-left: 10px;
}
.controls button:hover, .controls a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Container */
.dashboard-container {
    padding: 40px;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
}

.loading {
    text-align: center;
    font-size: 24px;
    color: var(--text-muted);
    margin-top: 100px;
}

/* Grid Layout (Default) */
.layout-grid .dashboard-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

/* List Layout */
.layout-list .dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.layout-list .server-card {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 30px;
    padding: 15px 24px;
}
.layout-list .server-header {
    margin-bottom: 0;
    min-width: 200px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.layout-list .metrics-grid {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 0;
    flex: 1;
}
.layout-list .metric-box {
    padding: 10px 15px;
    min-width: 130px;
    flex: 1;
}
.layout-list .services-title {
    display: block;
    width: 100%;
    margin-top: 0;
    margin-bottom: 5px;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}
.layout-list .services-list {
    width: 100%;
    max-width: none;
    margin-top: -15px;
}

/* Minimal Layout */
.layout-minimal .dashboard-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}
.layout-minimal .metrics-grid {
    grid-template-columns: 1fr 1fr;
}
.layout-minimal .services-list {
    display: none;
}

/* Server Card */
.server-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.server-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.server-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.status-online { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid var(--success); }
.status-offline { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); }

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.metric-box {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 18px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
body.theme-light .metric-box { background: rgba(0,0,0,0.03); }

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 700;
}

.progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}
body.theme-light .progress-bg { background: rgba(0,0,0,0.1); }

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

.metric-sub-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 8px;
    line-height: 1.4;
}

.net-row {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.net-icon.rx { color: #10b981; font-weight: bold; }
.net-icon.tx { color: #3b82f6; font-weight: bold; }

.server-title-wrapper {
    display: flex;
    flex-direction: column;
}
.server-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.text-warning { color: var(--warning); }

/* Services */
.services-title {
    margin-top: 25px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}
.services-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.service-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 6px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
    transition: all 0.2s ease;
}
body.theme-light .service-pill {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.08);
}
.service-pill:hover {
    background: rgba(0,0,0,0.35);
    transform: translateY(-1px);
}
.service-pill.active {
    border-left: 3px solid var(--success);
}
.service-pill.active::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}
.service-pill.inactive {
    border-left: 3px solid var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.service-pill.inactive::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
    animation: alertPulse 1.5s infinite;
}

/* Alarming Animation */
@keyframes alertPulse {
    0% { box-shadow: 0 0 0 0 var(--danger-glow); border-color: var(--danger); }
    50% { box-shadow: 0 0 20px 5px var(--danger-glow); border-color: var(--danger); }
    100% { box-shadow: 0 0 0 0 var(--danger-glow); border-color: var(--danger); }
}

.alert-critical {
    animation: alertPulse 1s infinite;
    background: rgba(239, 68, 68, 0.15) !important;
    color: var(--danger);
}
.server-card.alert-critical {
    border-color: var(--danger);
}
