:root {
    --sidebar-width: 250px;
}
html {
    overflow-y: scroll;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    overflow-x: hidden;
}
#app {
    min-height: 100vh;
}
#main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}
.main-content {
    flex: 1;
    padding: 1.25rem;
}
@media (min-width: 992px) {
    .main-content {
        padding: 1.5rem;
    }
}
/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 1040;
    background: #212529;
    color: #fff;
    transition: width 0.3s ease, transform 0.3s ease;
}
.sidebar-inner {
    height: 100%;
}
#sidebar .nav-link {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
}
#sidebar .nav-link:hover {
    background: rgba(255,255,255,0.1);
}
#sidebar .nav-link.active {
    background: var(--bs-primary) !important;
}
#sidebar .nav-link.text-white-50.active {
    color: #fff !important;
}
/* Overlay for mobile */
#sidebarOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}
#sidebarOverlay.show {
    display: block;
}
/* Collapsed sidebar */
.sidebar-collapsed #sidebar {
    width: 56px;
}
.sidebar-collapsed #main {
    margin-left: 56px;
}
.sidebar-collapsed #sidebar .sidebar-text,
.sidebar-collapsed #sidebar .sidebar-chevron,
.sidebar-collapsed #sidebar .sidebar-user,
.sidebar-collapsed #sidebar .sidebar-brand-full,
.sidebar-collapsed #sidebar .collapse {
    display: none !important;
}
.sidebar-collapsed #sidebar .sidebar-brand-icon {
    display: block !important;
}
.sidebar-collapsed #sidebar .sidebar-header {
    justify-content: center;
    padding: 0.5rem !important;
}
.sidebar-collapsed #sidebar .sidebar-link {
    justify-content: center;
    padding: 0.55rem 0;
}
.sidebar-collapsed #sidebar .sidebar-link span {
    display: flex;
    justify-content: center;
}
.sidebar-collapsed #sidebar .sidebar-icon {
    margin: 0 !important;
    font-size: 1.2rem;
}
.sidebar-collapsed #sidebar .nav-item {
    display: flex;
    justify-content: center;
}
/* Mobile: sidebar hidden by default */
@media (max-width: 991px) {
    #sidebar {
        transform: translateX(-100%);
        width: 280px !important;
    }
    #sidebar.mobile-show {
        transform: translateX(0);
    }
    #main {
        margin-left: 0 !important;
    }
    .main-content {
        padding: 0.75rem;
    }
}
/* Mobile improvements */
@media (max-width: 767px) {
    .main-content {
        padding: 0.5rem !important;
    }
    .card-header {
        padding: 0.5rem 0.75rem;
    }
    .card-body {
        padding: 0.75rem;
    }
    .table td .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    .table td .btn i {
        font-size: 0.85rem;
    }
    .table td {
        white-space: normal !important;
        word-break: break-word;
    }
    .row.g-3 > [class*="col-"] {
        margin-bottom: 0.5rem;
    }
    .row.g-2 > [class*="col-"] {
        margin-bottom: 0.25rem;
    }
    .card-header .d-flex {
        gap: 0.5rem !important;
    }
    .card-header .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
    .navbar .dropdown-menu {
        min-width: 200px;
    }
    .dataTables_wrapper .dataTables_filter input {
        max-width: 160px;
    }
    .select2-container--bootstrap-5 .select2-selection {
        min-height: 32px;
        font-size: 0.85rem;
    }
    .select2-container--bootstrap-5 .select2-selection .select2-selection__rendered {
        line-height: 30px;
    }
    .badge {
        font-size: 0.7rem;
    }
    .avatar {
        width: 32px;
        height: 32px;
    }
    .avatar-lg {
        width: 72px;
        height: 72px;
    }
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* Touch-friendly: min tap target 44px on mobile */
@media (max-width: 575px) {
    .btn:not(.btn-sm) {
        min-height: 44px;
    }
    .form-control, .form-select {
        min-height: 44px;
        font-size: 1rem;
    }
    .table .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
    .nav-link {
        min-height: 44px;
    }
}

/* Responsive table: stacked card view on very small screens */
@media (max-width: 576px) {
    div.dataTables_wrapper div.dataTables_filter {
        text-align: left;
        float: none;
        margin-bottom: 0.5rem;
    }
    div.dataTables_wrapper div.dataTables_filter input {
        max-width: 100%;
        width: 100%;
    }
    div.dataTables_wrapper div.dataTables_length {
        float: none;
        text-align: left;
        margin-bottom: 0.5rem;
    }
    div.dataTables_wrapper div.dataTables_info {
        text-align: left;
        padding-top: 0.5rem;
        font-size: 0.8rem;
    }
    div.dataTables_wrapper div.dataTables_paginate {
        float: none;
        text-align: center;
        padding-top: 0.5rem;
    }
}

@media print {
    .navbar, #sidebar, .btn, .no-print { display: none !important; }
    #main { margin-left: 0 !important; }
}
/* Shared */
.card {
    border-radius: 0.5rem;
}
.card-header {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 0.75rem 1rem;
}
.table > :not(caption) > * > * {
    vertical-align: middle;
}
.btn-sm {
    font-size: 0.8rem;
}
.dataTables_wrapper {
    width: 100%;
}
div.dataTables_wrapper div.dataTables_info {
    padding-top: 0.75rem;
}
div.dataTables_wrapper div.dataTables_paginate {
    padding-top: 0.5rem;
}
.dataTables_wrapper .row:last-child {
    min-height: 50px;
}
.dataTables_wrapper .dataTables_empty {
    display: none;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-lg {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
}
.form-control:focus, .btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}
.pagination {
    margin-bottom: 0;
}
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
}
.badge {
    font-weight: 500;
}
