/* ===== Font Family ===== */
:root {
    --font-family-en: 'Inter', sans-serif;
    --font-family-km: 'Khmer OS', 'Inter', sans-serif;
}

body {
    font-family: var(--font-family-en);
}

:lang(km) body,
:lang(km) .sidebar,
:lang(km) .navbar,
:lang(km) .card,
:lang(km) .modal,
:lang(km) .btn,
:lang(km) input,
:lang(km) select,
:lang(km) textarea,
:lang(km) label,
:lang(km) th,
:lang(km) td,
:lang(km) .form-label,
:lang(km) .form-control,
:lang(km) .form-select,
:lang(km) .breadcrumb,
:lang(km) .dropdown-item,
:lang(km) .badge {
    font-family: var(--font-family-km) !important;
}

/* ===== Sidebar ===== */
.sidebar {
    min-width: 260px;
    max-width: 260px;
    min-height: 100vh;
    background: #1f2937;
    transition: all 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    min-width: 70px;
    max-width: 70px;
}

.sidebar.collapsed .sidebar-text {
    display: none;
}

.sidebar.collapsed .sidebar-heading {
    text-align: center;
}

.sidebar.collapsed .sidebar-header a {
    justify-content: center;
}

.sidebar.collapsed .nav-link {
    text-align: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0 !important;
    font-size: 1.2rem;
}

.sidebar .nav-link {
    border-radius: 8px;
    margin-bottom: 2px;
    padding: 10px 15px;
    transition: all 0.2s ease;
    color: #fff !important;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}

.sidebar .nav-link.active {
    background-color: #5c7cfa;
    color: #fff !important;
    font-weight: 600;
}

.sidebar-heading {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

/* ===== Page Content Offset ===== */
#page-content-wrapper {
    margin-left: 260px;
    transition: margin-left 0.3s ease;
    width: calc(100% - 260px);
}

.sidebar-collapsed #page-content-wrapper {
    margin-left: 70px;
    width: calc(100% - 70px);
}

/* ===== Dashboard Stat Cards ===== */
.stat-card {
    border-left: 4px solid;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
}

.stat-card.users { border-left-color: #0d6efd; }
.stat-card.active-users { border-left-color: #198754; }
.stat-card.roles { border-left-color: #ffc107; }
.stat-card.permissions { border-left-color: #dc3545; }

/* ===== Cards ===== */
.card {
    border-radius: 8px;
}

.card-header {
    border-radius: 8px 8px 0 0 !important;
}

/* ===== DataTables Fixes ===== */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

/* ===== Dark Mode Custom Overrides ===== */
[data-bs-theme="dark"] .sidebar {
    background-color: #2b2f4a !important;
}

[data-bs-theme="dark"] .stat-card {
    background-color: #2b3035;
}

[data-bs-theme="dark"] table.dataTable tbody tr {
    background-color: transparent;
}

[data-bs-theme="dark"] table.dataTable.table-striped tbody tr.odd {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ===== Modal ===== */
.modal-body .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ===== Badge Styles ===== */
.badge {
    font-weight: 500;
}

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    #page-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-collapsed #page-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

@media (min-width: 769px) {
    .sidebar-overlay {
        display: none !important;
    }
}
