:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #eef2ff;
    --border-color: #dfe3ea;
    --text-muted: #6b7280;
    --radius: 10px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 74px;
    --topbar-height: 62px;
}

body {
    background-color: #f6f7fb;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: #1f2937;
    overflow-x: hidden;
}

/* ================= SIDEBAR ================= */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark) 0%, #2b2570 100%);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}

    .app-sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

    .sidebar-brand i {
        font-size: 1.4rem;
        flex-shrink: 0;
    }

.app-sidebar.collapsed .brand-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    padding: 14px 12px 6px;
    white-space: nowrap;
}

.app-sidebar.collapsed .nav-section-label {
    text-align: center;
    padding: 14px 0 6px;
}

    .app-sidebar.collapsed .nav-section-label span {
        display: none;
    }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    transition: background 0.15s, color 0.15s;
}

    .sidebar-link i {
        font-size: 1.15rem;
        width: 22px;
        text-align: center;
        flex-shrink: 0;
    }

    .sidebar-link:hover {
        background: rgba(255,255,255,0.08);
        color: #fff;
    }

    .sidebar-link.active {
        background: rgba(255,255,255,0.14);
        color: #fff;
    }

        .sidebar-link.active::before {
            content: "";
            position: absolute;
            left: -12px;
            top: 6px;
            bottom: 6px;
            width: 3px;
            background: #fff;
            border-radius: 0 3px 3px 0;
        }

.app-sidebar.collapsed .link-text {
    display: none;
}

.app-sidebar.collapsed .sidebar-link {
    justify-content: center;
}

    .app-sidebar.collapsed .sidebar-link:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 10px;
        background: #111827;
        color: #fff;
        padding: 5px 10px;
        border-radius: 6px;
        font-size: 0.78rem;
        white-space: nowrap;
        z-index: 1050;
    }

.sidebar-collapse-btn {
    border: none;
    background: rgba(255,255,255,0.08);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    position: absolute;
    top: 26px;
    right: -15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.25s;
}

    .sidebar-collapse-btn:hover {
        background: var(--primary);
    }

.app-sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* ================= MAIN AREA ================= */
.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

    .app-main.expanded {
        margin-left: var(--sidebar-collapsed);
    }

.app-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title {
    margin: 0;
    font-weight: 600;
    color: #111827;
}

.sidebar-toggle-mobile {
    display: none;
    border: none;
    background: none;
    font-size: 1.4rem;
    color: #374151;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #374151;
}

    .topbar-user i {
        font-size: 1.5rem;
        color: var(--primary);
    }

.app-content {
    padding: 24px;
    flex: 1;
}

.app-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 14px 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1025;
}

@media (max-width: 992px) {
    .app-sidebar {
        left: calc(-1 * var(--sidebar-width));
    }

        .app-sidebar.show {
            left: 0;
        }

    .app-main, .app-main.expanded {
        margin-left: 0;
    }

    .sidebar-toggle-mobile {
        display: block;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ================= CARDS / PAGE PANELS ================= */
.page-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}

.page-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

    .page-card-header h4 {
        margin: 0;
        font-weight: 600;
        color: #111827;
    }

/* ================= FORM CONTROLS ================= */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 9px 12px;
    font-size: 0.92rem;
    transition: border-color .15s, box-shadow .15s;
}

    .form-control:focus, .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.15);
    }

    .form-control::placeholder {
        color: #9ca3af;
    }

/* File input - stylish */
.custom-file-input {
    border: 1.5px dashed var(--border-color);
    border-radius: 8px;
    padding: 14px;
    background: var(--primary-light);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    position: relative;
}

    .custom-file-input:hover {
        border-color: var(--primary);
        background: #e6e8ff;
    }

    .custom-file-input input[type="file"] {
        position: absolute;
        inset: 0;
        opacity: 0;
        cursor: pointer;
    }

    .custom-file-input .file-label {
        color: var(--primary-dark);
        font-weight: 500;
        font-size: 0.88rem;
    }

    .custom-file-input i {
        font-size: 1.4rem;
        color: var(--primary);
        display: block;
        margin-bottom: 4px;
    }

.file-preview-name {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ================= SELECT2 ================= */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: 8px !important;
    border: 1px solid var(--border-color) !important;
    min-height: 40px !important;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.15) !important;
}

.select2-container--bootstrap-5 .select2-selection__rendered {
    line-height: 28px !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary) !important;
}

/* ================= BUTTONS ================= */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    font-weight: 500;
    padding: 8px 18px;
}

    .btn-primary:hover {
        background-color: var(--primary-dark);
        border-color: var(--primary-dark);
    }

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
}

    .btn-outline-primary:hover {
        background-color: var(--primary);
        border-color: var(--primary);
    }

/* ================= TABLE / DATATABLES ================= */
.table {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
}

    .table thead th {
        background-color: var(--primary-light);
        color: var(--primary-dark);
        font-weight: 600;
        font-size: 0.85rem;
        border-bottom: none;
        white-space: nowrap;
    }

    .table tbody tr:hover {
        background-color: #f9fafc;
    }

    .table td, .table th {
        vertical-align: middle;
        padding: 10px 14px;
        font-size: 0.88rem;
    }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 6px 10px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    margin: 0 2px;
    border: 1px solid var(--border-color) !important;
}

    .dataTables_wrapper .dataTables_paginate .paginate_button.current {
        background: var(--primary) !important;
        color: #fff !important;
        border-color: var(--primary) !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
        background: var(--primary-light) !important;
        color: var(--primary-dark) !important;
    }

/* ================= MISC ================= */
.footer {
    background: #fff;
    font-size: 0.85rem;
}

.required-star {
    color: #dc2626;
    margin-left: 2px;
}
