:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --secondary: #00b894;
    --danger: #e17055;
    --warning: #fdcb6e;
    --info: #0984e3;
    --success: #00b894;
    --dark: #2d3436;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --sidebar-bg: #1a1a2e;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f4f6f9;
    color: var(--gray-800);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden !important;
}

/* ===== SIDEBAR OVERLAY (MOBILE) ===== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 4px;
}

.brand-name {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    color: #fff;
}

.brand-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    padding: 15px 10px;
    flex: 1;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin: 16px 12px 6px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    min-height: 44px;
}

.sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--primary);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--gray-800);
}

.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover, .sidebar-toggle-btn:focus {
    background: var(--gray-100);
    color: var(--primary);
    border-color: var(--primary);
    outline: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-date {
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* ===== CONTENT & CARDS ===== */
.content {
    padding: 24px;
    flex: 1;
}

.card {
    border-radius: 12px;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    background: #fff;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 20px;
    border-radius: 12px 12px 0 0 !important;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* ===== BUTTONS & FORMS ===== */
.btn {
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.btn-success:hover {
    background: #00a381;
    border-color: #00a381;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-info {
    background: var(--info);
    border-color: var(--info);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: var(--gray-800);
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    font-size: 13px;
    padding: 8px 12px;
    min-height: 40px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(108,92,231,0.15);
}

select.form-select {
    min-height: 40px;
}

textarea.form-control {
    min-height: 80px;
}

/* ===== TABLES ===== */
.table, table.dataTable {
    font-size: 13px;
    margin-bottom: 0;
    background-color: #ffffff !important;
    color: #212529 !important;
}

.table thead th, table.dataTable thead th {
    background: #f8f9fa !important;
    color: #495057 !important;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #dee2e6 !important;
    white-space: nowrap;
}

.table tbody tr, table.dataTable tbody tr {
    background-color: #ffffff !important;
    color: #212529 !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > *,
table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd {
    background-color: #fdfdfd !important;
    color: #212529 !important;
    box-shadow: none !important;
}

.table-hover > tbody > tr:hover,
table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover {
    background-color: #f1f3f5 !important;
    color: #212529 !important;
}

.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 20px;
}

.badge-purple {
    background: #6c5ce7;
    color: #fff;
}

.alert {
    border-radius: 10px;
    border: none;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

.pagination .page-link {
    color: var(--primary);
}

.btn-group .btn {
    padding: 4px 10px;
    font-size: 12px;
}

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

/* AdminLTE fallback styles */
.main-sidebar {
    background: var(--sidebar-bg) !important;
}

.brand-link {
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    padding: 15px !important;
}

.brand-text {
    font-weight: 600 !important;
}

.nav-sidebar .nav-link {
    color: rgba(255,255,255,0.6) !important;
    border-radius: 8px;
    margin: 2px 8px;
    padding: 10px 12px !important;
    transition: all 0.2s;
}

.nav-sidebar .nav-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.08);
}

.nav-sidebar .nav-link.active {
    color: #fff !important;
    background: var(--primary) !important;
}

.nav-sidebar .nav-icon {
    font-size: 16px;
}

.main-footer {
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 15px;
    color: var(--gray-600);
    font-size: 13px;
    margin-left: 0;
}

.content-header {
    padding: 15px 20px 0;
}

.content-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
}

/* ===== RESPONSIVE MEDIA QUERIES ===== */
@media (max-width: 991.98px) {
    .main-sidebar, .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        z-index: 1045 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .main-sidebar.active, 
    .sidebar.active, 
    body.sidebar-open .main-sidebar, 
    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3) !important;
    }

    .content-wrapper, .main-footer, .main-header {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(3px);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .sidebar-overlay.active, body.sidebar-open .sidebar-overlay {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar h1 {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }

    .content {
        padding: 16px 12px;
    }

    /* Modal adjustments on tablet/mobile */
    .modal-dialog {
        margin: 10px auto;
        max-width: 95%;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 12px;
    }

    .topbar h1 {
        max-width: 140px;
        font-size: 1rem;
    }

    .sidebar-toggle-btn {
        width: 38px;
        height: 38px;
    }

    .btn-group .btn {
        width: auto;
        margin-bottom: 0;
    }

    .card-body {
        padding: 14px 12px;
    }

    .card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }

    .table-responsive {
        border: 0;
        margin-bottom: 0;
        -webkit-overflow-scrolling: touch;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
        float: none !important;
        margin-bottom: 10px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
}
