/* ==========================================
   Base Styles
   ========================================== */
body {
    font-family: 'Lato', sans-serif;
    background-color: #f4f6f9;
}

/* ==========================================
   Sidebar Styling
   ========================================== */
.sidebar {
    background-color: #ffffff;
    height: calc(100vh - 72px);
    position: fixed;
    top: 72px;
    left: 0;
    width: 250px;
    padding-top: 10px;
    /* Spacing for the links */
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
}

.sidebar .nav {
    display: flex;
    flex-direction: column;
}

.sidebar .nav-item {
    margin: 4px 12px;
    /* Floating look */
    border: none;
}

.sidebar .nav-link {
    font-size: 14px;
    font-weight: 500;
    color: #5a6a85;
    /* Professional blue-gray */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar .nav-link i {
    font-size: 18px;
    color: #5a6a85;
    transition: color 0.2s ease;
}

.sidebar .nav-link:hover {
    background-color: #f8f9fa;
    color: #d1202d;
}

.sidebar .nav-link:hover i {
    color: #d1202d;
}

.sidebar .nav-link.active {
    background-color: #fce8e6;
    /* Soft red tint */
    color: #d1202d;
    font-weight: 600;
}

.sidebar .nav-link.active i {
    color: #d1202d;
}

/* ==========================================
   Header Styling
   ========================================== */
.header-back {
    background-color: #d1202d;
    padding: 0 24px;
    height: 72px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

#sidebarToggle {
    border-radius: 8px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

#sidebarToggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.5px;
    margin: 0;
    color: #ffffff;
}

.logo-image {
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
}

.btn-logout {
    font-weight: 600;
    font-size: 14px;
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: #ffffff;
    color: #d1202d !important;
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   Main Content & Layout
   ========================================== */
main {
    margin-left: 250px;
    overflow-x: hidden;
    padding-top: 15px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.sidebar-collapsed .sidebar .nav-link {
    padding-left: 14px;
    padding-right: 14px;
    gap: 0;
}

.sidebar-collapsed .sidebar .nav-link.active {
    padding-left: 14px;
    padding-right: 14px;
}

.sidebar-collapsed .sidebar .nav-text {
    opacity: 0;
    visibility: hidden;
    display: none;
}

.sidebar-collapsed main {
    margin-left: 70px;
}

.dashboard-header {
    background: linear-gradient(135deg, #2a2c35 0%, #1e2026 100%);
    border-radius: 12px;
    text-align: left;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   Tables & Media
   ========================================== */
table {
    width: 100%;
}

table td,
table th {
    vertical-align: middle !important;
}

img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    border-radius: 50%;
}

/* ==========================================
   Navigation Tabs
   ========================================== */
.nav-tabs .nav-link {
    border: none;
    color: #64748b;
    border-radius: 8px 8px 0 0;
    position: relative;
    background: transparent;
}

.nav-tabs .nav-link:hover {
    color: #1e293b;
    background-color: #f1f5f9;
}

.nav-tabs .nav-link.active {
    color: #d1202d;
    background: transparent;
    border: none;
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #d1202d;
    border-radius: 3px;
}

/* ==========================================
   Login Container
   ========================================== */
.login-container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container img {
    max-width: 300px;
    margin-bottom: auto;
}

.login-container h2 {
    margin: 20px 0;
    font-weight: bold;
    color: #d1202d;
}

.login-container form {
    margin-top: 20px;
}

.login-container .form-floating label {
    color: #6c757d;
}

.login-container .form-floating input {
    border-radius: 0.25rem;
}

.login-container .btn-login {
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    font-size: 16px;
}

.login-container .forgot-password {
    margin-top: 15px;
    font-size: 0.9rem;
}

.login-container .forgot-password a {
    text-decoration: none;
    color: #6c757d;
}

.login-container .forgot-password a:hover {
    text-decoration: underline;
    color: #d1202d;
}

/* ==========================================
   Footer
   ========================================== */
.footer {
    background-color: #d1202d;
    color: white;
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    font-size: small;
    font-style: italic;
    height: 20px;
}

/* ==========================================
   Miscellaneous
   ========================================== */
.col-12 .form-select {
    width: 250px !important;
}

.card-header,
.modal-header {
    background-color: #D1202D !important;
    color: #FFF !important;
}

/* ==========================================
   Responsive Styles (Media Queries)
   ========================================== */
@media (max-width: 768px) {
    .sidebar {
        z-index: 1040;
        transform: translateX(0);
        width: 250px;
    }

    main {
        margin-left: 70px;
    }

    /* Expanded state overlaying the page on mobile */
    html:not(.sidebar-collapsed) .sidebar {
        width: 250px;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }

    html:not(.sidebar-collapsed) main {
        margin-left: 70px;
    }

    /* Add dim backdrop when sidebar is expanded on mobile */
    html:not(.sidebar-collapsed) main::before {
        content: '';
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        pointer-events: none;
        animation: fadeIn 0.3s ease forwards;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }
}

@media (max-width: 576px) {
    .navbar-brand h3 {
        font-size: 1.2rem;
    }

    .dashboard-header {
        font-size: 1rem;
        padding: 10px;
    }

    img {
        width: 80%;
    }
}

/* ==========================================
   Dark Mode Custom Overrides
   ========================================== */
[data-bs-theme="dark"] body {
    background-color: #121212;
}

[data-bs-theme="dark"] .sidebar {
    background-color: #1e1e1e;
    box-shadow: none;
    border-right: 1px solid var(--bs-border-color);
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: #a0aec0;
}

[data-bs-theme="dark"] .sidebar .nav-link i {
    color: #a0aec0;
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #d1202d;
}

[data-bs-theme="dark"] .sidebar .nav-link:hover i {
    color: #d1202d;
}

[data-bs-theme="dark"] .sidebar .nav-link.active {
    background-color: rgba(209, 32, 45, 0.15);
    color: #d1202d;
}

[data-bs-theme="dark"] .sidebar .nav-link.active i {
    color: #d1202d;
}

[data-bs-theme="dark"] .login-container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card {
    background-color: #1e1e1e;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .card-header {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .card-body {
    background-color: #1e1e1e;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #1e1e1e;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .text-dark {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #a0aec0 !important;
}

[data-bs-theme="dark"] .table-secondary {
    --bs-table-bg: var(--bs-table-bg) !important;
    --bs-table-color: var(--bs-table-color) !important;
    border-color: var(--bs-border-color) !important;
    background-color: var(--bs-table-bg) !important;
    color: var(--bs-table-color) !important;
}

/* Select2 Dark Mode Support */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: #1e1e1e;
    border-color: var(--bs-border-color);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__rendered {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: #1e1e1e;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #d1202d !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
    background-color: var(--bs-dark-border-subtle) !important;
    color: #e2e8f0 !important;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(209, 32, 45, 0.15);
    color: #e2e8f0;
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .form-select {
    background-color: var(--bs-dark-border-subtle) !important;
    border-color: var(--bs-border-color) !important;
    color: #e2e8f0 !important;
}