:root {
    --bg-dark: #0f111a;
    --bg-card: rgba(25, 28, 41, 0.7);
    --bg-card-hover: rgba(35, 39, 56, 0.9);
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    /* Subtle background gradient */
    background-image: radial-gradient(circle at top right, rgba(79, 70, 229, 0.15), transparent 400px),
                      radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 400px);
}

/* Typography */
h1, h2, h3 { font-weight: 600; }
a { color: var(--text-main); text-decoration: none; }
.color-success { color: var(--success); }
.color-danger { color: var(--danger); }
.color-warning { color: var(--warning); }
.muted { color: var(--text-muted); font-size: 0.85rem; }

/* Utilities */
.flex-center { display: flex; align-items: center; }
.text-right { text-align: right; }

/* Layout */
.app-container {
    display: flex;
    width: 100%;
}

.sidebar {
    width: 260px;
    background: rgba(15, 17, 26, 0.9);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.user-info:hover { color: var(--text-main); }

.user-role-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}

.user-role-badge.role-admin {
    background: rgba(79, 70, 229, 0.2);
    color: #818cf8;
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.user-role-badge.role-viewer {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.sidebar-logout-btn {
    width: 100%;
    margin-top: 8px;
    justify-content: center;
}

.logo {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
}

nav ul {
    list-style: none;
    padding: 20px 12px;
}

nav li {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

nav li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

nav li.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.main-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Tabs */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon.blue { background: rgba(79, 70, 229, 0.2); color: #818cf8; }
.stat-icon.green { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.stat-icon.red { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.stat-info h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-info p {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Server Grid (Dashboard) */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.server-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    backdrop-filter: blur(12px);
}

.server-card:hover { border-color: rgba(255, 255, 255, 0.15); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.server-name { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.server-uri { color: var(--text-muted); font-size: 0.85rem; font-family: monospace; }

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.status-ok { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.status-fail { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.status-unauth { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.status-unknown { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); border: 1px solid rgba(148, 163, 184, 0.3); }

.card-metrics {
    display: flex;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.metric { display: flex; flex-direction: column; gap: 4px; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;}
.metric-value { font-size: 0.95rem; font-weight: 500; display: flex; align-items: center; gap: 6px;}

.ping-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ping-dot.good { background: var(--success); box-shadow: 0 0 8px var(--success); }
.ping-dot.bad { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.ping-dot.neutral { background: var(--warning); }

/* Data Table Panel */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    overflow: hidden;
}

.panel-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table th {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.2);
}

.data-table tr:hover td { background: rgba(255, 255, 255, 0.03); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.btn-success:hover { background: #059669; }
.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon-only { padding: 8px; border-radius: 6px; }
.btn-danger-outline { background: transparent; border: 1px solid rgba(239, 68, 68, 0.5); color: var(--danger); }
.btn-danger-outline:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); }
.btn-edit { background: transparent; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--text-main); }
.btn-edit:hover { background: rgba(255, 255, 255, 0.1); }

.action-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: #1e2130;
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 4px; border-radius: 4px; }
.close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }

.modal-body { padding: 24px; }

form .form-group { margin-bottom: 20px; }
form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

label {
    display: block;
    margin-bottom: 8px;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    transition: var(--transition);
}

input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); }
input::placeholder { color: rgba(255, 255, 255, 0.3); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.2);
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1e293b;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
