:root {
    /* Premium Indigo Palette (Tailwind-inspired) */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1; /* Main Brand */
    --primary-600: #4f46e5; /* Hover */
    --primary-700: #4338ca;
    
    /* Neutral Slate for Depth */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b; /* Sidebar BG */
    --slate-900: #0f172a;

    --bg-body: var(--slate-50);
    --bg-card: #ffffff;
    --text-primary: var(--slate-900);
    --text-secondary: var(--slate-500);

    --sidebar-width: 280px;
    --header-height: 70px;
    --card-border: 1px solid rgba(226, 232, 240, 0.8);
    
    /* Modern Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.3);

    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout Structure --- */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Premium Sidebar --- */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--slate-900);
    color: var(--slate-100);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand i {
    -webkit-text-fill-color: initial;
    color: #6366f1;
}

#sidebar ul.components {
    padding: 1.5rem 1rem;
    flex-grow: 1;
}

#sidebar ul li {
    margin-bottom: 0.5rem;
}

#sidebar ul li a {
    position: relative;
    padding: 0.75rem 1rem;
    color: var(--slate-400);
    text-decoration: none;
    display: flex;
    align-items: center;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    overflow: hidden;
}

#sidebar ul li a i {
    font-size: 1.25rem;
    margin-right: 1rem;
    transition: all 0.2s ease;
    width: 24px;
    text-align: center;
}

/* Sidebar Hover & Active States */
#sidebar ul li a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

#sidebar ul li a.active {
    color: white;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
    box-shadow: inset 3px 0 0 0 var(--primary-500);
    border-radius: 4px 12px 12px 4px;
}

#sidebar ul li a.active i {
    color: var(--primary-400);
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* --- Content Area --- */
#content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

/* --- Top Navbar (Glassmorphism) --- */
.top-navbar {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

.nav-search {
    background: var(--slate-100);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.9rem;
    color: var(--slate-700);
    transition: all 0.2s;
    width: 240px;
}

.nav-search:focus {
    background: white;
    box-shadow: 0 0 0 2px var(--primary-200);
    outline: none;
}

/* --- Cards (Modern & Layered) --- */
.stat-card, .table-card, .status-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    overflow: hidden;
}

.stat-card:hover, .table-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-100);
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: var(--primary-50);
    color: var(--primary-600);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.stat-card.purple .card-icon-wrapper { background: #f3e8ff; color: #9333ea; }
.stat-card.green .card-icon-wrapper { background: #dcfce7; color: #16a34a; }
.stat-card.orange .card-icon-wrapper { background: #ffedd5; color: #ea580c; }

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-500);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--slate-900);
    margin-top: 0.25rem;
    letter-spacing: -0.02em;
}

/* --- Tables (Clean & Spacious) --- */
.table-custom {
    width: 100%;
    margin-bottom: 0;
}

.table-custom thead th {
    background: var(--slate-50);
    color: var(--slate-500);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--slate-200);
}

.table-custom tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    color: var(--slate-700);
    border-bottom: 1px solid var(--slate-100);
    font-size: 0.95rem;
}

.table-custom tr:last-child td {
    border-bottom: none;
}

.table-custom tbody tr:hover td {
    background-color: var(--slate-50);
}

/* --- Buttons (Gradients) --- */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border: none;
    color: white;
    font-weight: 500;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transition: all 0.2s;
}

.btn-primary-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
    color: white;
}

.btn-primary-custom:active {
    transform: translateY(0);
}

.btn-white {
    background: white;
    border: 1px solid var(--slate-200);
    color: var(--slate-700);
}

.btn-white:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
}

/* --- Badges --- */
.status-badge {
    padding: 0.35em 0.85em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-running { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-stopped { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.status-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* --- Utility Animations --- */
.fade-in { animation: fadeInUp 0.5s ease-out forwards; opacity: 0; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Mobile --- */
@media (max-width: 768px) {
    #sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
    #sidebar.active { margin-left: 0; }
    .top-navbar { padding: 0 1rem; }
}
/* --- Color Utilities (Required for Icons) --- */
.bg-purple-light { background-color: #f3e8ff; }
.text-purple { color: #9333ea; }

.bg-success-light { background-color: #dcfce7; }
.text-success { color: #16a34a !important; }

.bg-danger-light { background-color: #fee2e2; }
.text-danger { color: #dc2626 !important; }

.bg-blue-light { background-color: #eff6ff; }
.text-blue { color: #2563eb; }

.bg-orange-light { background-color: #ffedd5; }
.text-orange { color: #ea580c; }


/* --- Responsive Enhancements --- */

/* Mobile Sidebar & Overlay */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        height: 100vh;
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    #sidebar.active {
        margin-left: 0;
    }
    
    /* Adjust Content padding */
    .top-navbar {
        padding: 0 1rem;
    }
    
    main {
        padding: 1rem !important; /* Reduce padding on mobile */
    }
    
    /* Stack Stat Cards */
    .stat-card {
        margin-bottom: 1rem;
    }

    /* Adjust Tables */
    .table-custom thead th, 
    .table-custom tbody td {
        white-space: nowrap; /* Prevent wrapping in cells, force scroll */
        padding: 0.75rem 1rem;
    }
    
    /* Stack Buttons in Grids */
    .d-grid.d-md-flex {
        display: grid !important;
        grid-template-columns: 1fr;
    }
    
    .btn-group-mobile-stack {
        flex-direction: column;
        width: 100%;
    }
}

/* Ensure smooth scrolling for tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9; 
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

