/* =====================================================
   PowerUp - Premium Design System (Slate & Indigo)
   ===================================================== */

:root {
    /* 🎨 Color Palette: Slate (Dark Blue-Greys) */
    --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;
    --slate-900: #0f172a;
    --slate-950: #020617;

    /* 🎨 Pastel Brand Color: Indigo (Softer) */
    --primary: #818cf8;
    /* Pastel Indigo */
    --primary-hover: #6366f1;

    /* 🎨 Pastel Semantics (Softer, less saturated) */
    --success: #4ade80;
    /* Pastel Green */
    --info: #60a5fa;
    /* Pastel Blue */
    --warning: #fbbf24;
    /* Pastel Amber */
    --danger: #f87171;
    /* Pastel Red */

    /* 🎨 Backgrounds & Borders */
    --bs-body-bg: #0f172a;
    /* Deep Slate 900 */
    --bs-body-color: #e2e8f0;
    /* Softer text than pure white */

    --sidebar-bg: #1e293b;
    /* Slate 800 */
    --header-bg: rgba(15, 23, 42, 0.85);
    /* Darker, matching body but transparent */

    /* Making cards slightly distinct from body but not too harsh */
    --card-bg: rgba(30, 41, 59, 0.6);
    /* Slate 800 with transparency */
    --card-border: rgba(148, 163, 184, 0.1);
    /* Very subtle border */
    --border-color: rgba(148, 163, 184, 0.15);
    /* General borders */

    /* 📐 Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Legacy references */
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
}

/* =====================================================
   Layout Core
   ===================================================== */
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* =====================================================
   Sidebar (Polished)
   ===================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Scrollable Nav Area */
.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--slate-600) transparent;
}

.nav-section {
    margin-bottom: 32px;
}

.nav-section-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-500);
    padding: 0 16px;
    margin-bottom: 10px;
}

/* Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--slate-300);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    transition: var(--transition);
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: var(--slate-700);
    color: #fff;
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(129, 140, 248, 0.1));
    color: var(--primary);
    box-shadow: none;
    border: 1px solid rgba(129, 140, 248, 0.2);
}

.nav-icon {
    font-size: 20px;
    opacity: 0.7;
    transition: var(--transition);
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    opacity: 1;
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    margin: 16px 12px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.sidebar-footer:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(129, 140, 248, 0.3);
    transform: translateY(-2px);
}

/* User Profile in Sidebar */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    /* Text truncation fix */
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--slate-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.user-role {
    font-size: 11px;
    color: var(--primary);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: block;
}

.user-avatar {
    transition: var(--transition);
    border-color: var(--primary) !important;
}

.sidebar-footer:hover .user-avatar {
    transform: scale(1.1);
}

/* =====================================================
   Main Content Area
   ===================================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

/* Glassmorphism Header */
.content-header {
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin: 0;
    letter-spacing: -0.5px;
}

.content-body {
    flex: 1;
    padding: 32px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* =====================================================
   Component Overrides (Bootstrap 5)
   ===================================================== */
/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.card-body {
    padding: 24px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: var(--transition);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -2px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--slate-700);
    border: 1px solid var(--border-color);
    color: var(--slate-300);
}

.btn-success {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border: none;
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #f87171, #ef4444);
    border: none;
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: none;
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    border: none;
    color: #fff;
}

/* Forms */
.form-control,
.form-select {
    background-color: var(--slate-900);
    border-color: var(--slate-600);
    color: var(--slate-100);
    border-radius: 10px;
    padding: 10px 14px;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--slate-950);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15);
    /* Pastel Indigo Glow */
}

/* Fix webkit autofill background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--slate-900) inset !important;
    -webkit-text-fill-color: var(--slate-100) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* DataTables Overrides - Crucial for Dark Mode */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background-color: var(--slate-900) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--slate-100) !important;
    border-radius: 8px;
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary) !important;
    outline: none;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--slate-300) !important;
    border-radius: 6px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--slate-700) !important;
    border-color: var(--slate-600) !important;
    color: white !important;
}

/* Custom Checkbox/Radio */
.form-check-input {
    background-color: var(--slate-900);
    border-color: var(--slate-500);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--slate-300);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
}

.table> :not(caption)>*>* {
    padding: 16px;
    border-bottom-width: 1px;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--slate-400);
    border-bottom: 2px solid var(--border-color);
}

/* Badges */
.badge {
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 500;
}

/* =====================================================
   Utilities & Mobile
   ===================================================== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--slate-100);
    font-size: 24px;
    cursor: pointer;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle {
        display: block;
        margin-right: 16px;
    }

    .content-header {
        padding: 0 20px;
    }

    .content-body {
        padding: 20px;
    }
}

/* Stats Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
}

.stat-icon.primary {
    color: var(--primary);
    background: rgba(129, 140, 248, 0.1);
}

.stat-icon.success {
    color: var(--success);
    background: rgba(74, 222, 128, 0.1);
}

.stat-icon.warning {
    color: var(--warning);
    background: rgba(251, 191, 36, 0.1);
}

.stat-icon.info {
    color: var(--info);
    background: rgba(96, 165, 250, 0.1);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--slate-400);
    margin-top: 2px;
}

/* Plugin Overrides (Select2, Datepicker) */
.select2-container--default .select2-selection--single {
    background-color: var(--slate-900) !important;
    border-color: var(--slate-600) !important;
    height: auto !important;
    padding: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--slate-100) !important;
}

.select2-dropdown {
    background-color: var(--slate-800) !important;
    border-color: var(--slate-600) !important;
}

.select2-results__option[aria-selected=true] {
    background-color: var(--slate-700) !important;
}

/* Date Input Fix */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
    cursor: pointer;
}

/* =====================================================
   Auth/Login Pages
   ===================================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 24px;
    overflow: hidden;
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    height: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    color: var(--slate-400);
    font-size: 14px;
}

/* Auth Input Groups */
.auth-input-group {
    position: relative;
    margin-bottom: 20px;
}

.auth-input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--slate-300);
    font-size: 13px;
    font-weight: 500;
}

.auth-input-wrapper {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
    font-size: 20px;
    pointer-events: none;
    transition: var(--transition);
    z-index: 10;
}

.auth-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--slate-700);
    border-radius: 12px;
    padding: 14px 16px 14px 48px;
    /* Space for icon */
    color: #fff;
    font-size: 15px;
    transition: var(--transition);
}

.auth-input:focus {
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15);
    outline: none;
}

.auth-input:focus~.auth-input-icon {
    color: var(--primary);
}

/* Password Toggle */
.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 20px;
    transition: var(--transition);
}

.password-toggle:hover {
    color: #fff;
}

/* Tabs Override for Login */
.auth-tabs .nav-link {
    background: transparent;
    border: 1px solid var(--slate-700);
    color: var(--slate-400);
    margin: 0 4px;
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
    justify-content: center;
}

.auth-tabs .nav-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.auth-tabs .nav-link:hover:not(.active) {
    background: var(--slate-800);
    border-color: var(--slate-600);
}

/* Footer links */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    border-top: 1px solid var(--slate-800);
    padding-top: 24px;
}

.auth-footer p {
    color: var(--slate-500);
    font-size: 13px;
    margin-bottom: 8px;
}

.auth-footer a {
    color: var(--slate-400);
    text-decoration: none;
    transition: var(--transition);
    font-size: 13px;
}

.auth-footer a:hover {
    color: var(--primary);
}