/* ====== CSS Reset & Variables ====== */
:root {
    --bg-main: #0B0E14;          /* TrueNAS style deep space background */
    --bg-panel: #1A1E27;         /* Panel background */
    --bg-sidebar: #131720;       /* Sidebar background */
    --bg-hover: #262D3D;         /* Hover state */
    --text-primary: #E2E8F0;     /* Primary text */
    --text-muted: #94A3B8;       /* Muted text */
    --accent-color: #0284C7;     /* TrueNAS style blue accent */
    --accent-hover: #0369A1;
    --border-color: #2D3748;
    
    /* Status Colors */
    --status-online: #10B981;    /* Emerald green */
    --status-offline: #EF4444;   /* Red */
    --status-warning: #F59E0B;   /* Amber */
    
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body.dark-theme {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ====== Layout ====== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ====== Sidebar ====== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 28px;
    color: var(--accent-color);
    margin-right: 12px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    list-style: none;
    padding: 20px 12px;
}

.nav-links li {
    margin-bottom: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
}

.nav-links li.active a,
.nav-links a:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-links li.active a {
    background-color: rgba(2, 132, 199, 0.15); /* Accent tint */
    border-left: 3px solid var(--accent-color);
}

.nav-links a i {
    font-size: 20px;
    margin-right: 14px;
}

/* ====== Main Content ====== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* ====== Header ====== */
.top-nav {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.status-indicator {
    display: flex;
    align-items: center;
    background-color: var(--bg-hover);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.dot.pulse {
    background-color: var(--status-warning);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: pulse-orange 2s infinite;
}

.dot.connected {
    background-color: var(--status-online);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}

.dot.disconnected {
    background-color: var(--status-offline);
}

.time-display {
    color: var(--text-muted);
    font-size: 14px;
    font-family: monospace;
}

/* ====== Dashboard Grid ====== */
.dashboard-content {
    padding: 30px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--bg-panel);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-speed) ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-right: 20px;
    background-color: rgba(2, 132, 199, 0.1);
    color: var(--accent-color);
}

.stat-success .stat-icon {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--status-online);
}

.stat-error .stat-icon {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--status-offline);
}

.stat-details h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-details p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ====== Panels & Tables ====== */
.panel {
    background-color: var(--bg-panel);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px 8px 36px;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    transition: all var(--transition-speed);
}

.search-box input:focus {
    border-color: var(--accent-color);
    background-color: #1E2532;
}

.btn-icon {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all var(--transition-speed);
}

.btn-icon:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, 
.data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr {
    transition: background-color var(--transition-speed);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.data-table td {
    font-size: 14px;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge.online {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--status-online);
}

.badge.offline {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--status-offline);
}

.badge.warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.badge.neutral {
    background-color: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

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

.loading-state i {
    font-size: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

/* ====== Animations ====== */
@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-orange {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ====== Responsive ====== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    .logo-text, .link-name {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        padding: 0;
    }
    .nav-links a {
        justify-content: center;
        padding: 16px;
    }
    .nav-links a i {
        margin-right: 0;
        font-size: 24px;
    }
    .main-content {
        margin-left: 80px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-speed);
    }
    .main-content {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .panel-actions {
        width: 100%;
        justify-content: space-between;
    }
}
