:root {
    --bs-font-sans-serif: "Poppins", sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
}

html {
    scroll-behavior: smooth !important;
}

body,
button,
input,
optgroup,
select,
textarea,
.form-control,
.form-select,
.btn,
.table,
.card,
.modal,
.sidebar-wrapper,
#sidebar,
#main,
.page-heading,
h1,
h2,
h3,
h4,
h5,
h6,
p,
label,
.select2-container,
.select2-container .select2-selection,
.select2-results__option,
.dataTables_wrapper,
.login-page {
    font-family: "Poppins", sans-serif;
}

.select2 {
    width: 100% !important;
}

.select2-container {
    max-width: 100% !important;
    width: 100% !important;
}

body {
    overflow-x: hidden !important;
}

img,
table,
input,
select,
textarea,
.btn {
    max-width: 100%;
}

.btn {
    align-items: center;
    border-radius: 0.45rem;
    display: inline-flex;
    gap: 0.35rem;
    justify-content: center;
}

.btn>i,
.btn>.bi,
.btn>.fas,
.btn>.far,
.btn>.fab {
    align-items: center;
    display: inline-flex;
    line-height: 1;
    vertical-align: middle;
}

.btn [class^="bi-"]::before,
.btn [class*=" bi-"]::before {
    display: block;
    line-height: 1;
}

.input-group-text .form-check {
    margin-bottom: 0;
    min-height: auto;
    padding-left: 0;
}

.input-group-text .form-check-input {
    float: none;
    margin: 0;
}

.input-group-text .form-check-label {
    display: none;
}

.card-title,
.card-text,
.page-heading h3,
.page-heading p {
    overflow-wrap: anywhere;
}

.table-responsive {
    border-radius: 0.65rem;
}

.table-responsive>.table {
    margin-bottom: 0;
    min-width: 720px;
}

.table th,
.table td {
    vertical-align: middle;
    white-space: nowrap;
}

.table td {
    max-width: 280px;
    white-space: normal;
}

.modal-footer {
    gap: 0.5rem;
}

.theme-toggle {
    flex-shrink: 0;
    white-space: nowrap;
}

.theme-toggle .form-switch {
    margin-bottom: 0;
    min-height: auto;
    min-width: 2.5rem;
    padding-left: 0;
}

.theme-toggle .form-switch .form-check-input {
    appearance: none;
    background-color: #d8dee9;
    background-image: none !important;
    border: 0;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(90, 103, 128, 0.22);
    height: 1.25rem;
    margin-left: 0;
    position: relative;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    width: 2.5rem;
}

.theme-toggle .form-switch .form-check-input::before {
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    content: "";
    height: 0.95rem;
    left: 0.15rem;
    position: absolute;
    top: 0.15rem;
    transition: transform 0.2s ease;
    width: 0.95rem;
}

.theme-toggle .form-switch .form-check-input:checked {
    background-color: #435ebe;
    box-shadow: none;
}

.theme-toggle .form-switch .form-check-input:checked::before {
    transform: translateX(1.25rem);
}

.theme-toggle .form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.15rem rgba(67, 94, 190, 0.25);
}

/* * Bottom navigation */
#bottom-bar {
    width: 100%;
    background: #fff;
    position: fixed;
    bottom: 0;
    left: 0;
    display: none;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    transition: 0.3s;
    z-index: 1030;
}

.bottom-bar-element {
    flex: 1;
    text-align: center;
    padding: 10px 5px;
    color: #607080;
    text-decoration: none;
    transition: 0.3s;
    font-size: 12px;
}

.bottom-bar-element i {
    display: block;
    font-size: 24px;
    margin-bottom: 2px;
}

.bottom-bar-element-active {
    color: #3950a2;
}

.bottom-bar-element:hover {
    color: #78909c;
}

/* * Light mode */
html[data-bs-theme="light"] #bottom-bar {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

html[data-bs-theme="light"] .bottom-bar-element {
    color: #607080;
}

html[data-bs-theme="light"] .bottom-bar-element-active {
    color: #3950a2;
}

/* * Dark mode */
html[data-bs-theme="dark"] #bottom-bar {
    background: #1e1e2d;
    border-top: 1px solid #2a2a2a;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
}

html[data-bs-theme="dark"] .bottom-bar-element {
    color: #9e9e9e;
}

html[data-bs-theme="dark"] .bottom-bar-element-active {
    color: #ffffff;
}

/* * Mobile layout */
@media screen and (max-width: 768px) {
    #bottom-bar {
        display: flex;
    }

    #main {
        padding: 1rem 0.75rem 0.75rem;
    }

    body {
        padding-bottom: 70px;
    }

    header.mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .page-heading {
        margin-bottom: 1rem;
    }

    .row {
        --bs-gutter-y: 0.75rem;
    }

    .card {
        border-radius: 0.9rem;
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .page-heading h3 {
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .page-heading p,
    .card-text {
        line-height: 1.5;
    }

    .card-body>.d-flex.justify-content-between.align-items-center.mb-3,
    .card-body>.d-flex.justify-content-between.align-items-start.mb-3,
    form>.d-flex.justify-content-between.align-items-center.mb-3,
    form>.d-flex.justify-content-between.align-items-start.mb-3 {
        align-items: stretch !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    .card-body>.d-flex.justify-content-between.align-items-center.mb-3>.btn,
    .card-body>.d-flex.justify-content-between.align-items-center.mb-3>a.btn,
    .card-body>.d-flex.justify-content-between.align-items-start.mb-3>.btn,
    .card-body>.d-flex.justify-content-between.align-items-start.mb-3>a.btn,
    form>.d-flex.justify-content-between.align-items-center.mb-3>.btn,
    form>.d-flex.justify-content-between.align-items-center.mb-3>a.btn,
    form>.d-flex.justify-content-between.align-items-start.mb-3>.btn,
    form>.d-flex.justify-content-between.align-items-start.mb-3>a.btn {
        width: 100%;
    }

    .card-body>.d-flex.justify-content-between.align-items-start.mb-3>.text-end {
        text-align: start !important;
    }

    .table-responsive {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive>.btn,
    .card-body>a.btn,
    form>button[type="submit"].btn,
    form>a.btn {
        width: 100%;
    }

    form>a.btn+button.btn,
    form>button.btn+button.btn,
    form>.btn+.btn {
        margin-top: 0.5rem;
    }

    .table-responsive>.table {
        min-width: 780px;
    }

    .table th,
    .table td {
        font-size: 0.875rem;
        padding: 0.65rem;
    }

    .table td .d-flex.gap-1,
    .table td .d-flex.gap-2 {
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .table td .btn-sm {
        padding: 0.35rem 0.55rem;
    }

    .input-group {
        min-width: 0;
    }

    .input-group>.form-control,
    .input-group>.form-select {
        min-width: 0;
    }

    .row>[class*="col-"]>.btn,
    .row>[class*="col-"]>a.btn {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 0.35rem;
    }

    .table-responsive+.d-flex.justify-content-end,
    .table-responsive .d-flex.justify-content-end {
        justify-content: center !important;
    }

    .footer {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        text-align: center;
    }

    .footer .float-start,
    .footer .float-end {
        float: none !important;
    }

    .modal-dialog {
        margin: 0.75rem;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .modal-footer .btn,
    .modal-footer form,
    .modal-footer form .btn {
        width: 100%;
    }
}

@media screen and (max-width: 575.98px) {
    #main {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .card-body {
        padding: 0.9rem;
    }

    .btn {
        white-space: normal;
    }

    .row {
        --bs-gutter-x: 0.75rem;
    }

    .input-group .btn,
    .input-group .input-group-text {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .input-group .input-group-text {
        white-space: nowrap;
    }

    .d-flex.gap-2:not(.theme-toggle):not(.btn-icon-group),
    .d-flex.gap-1:not(.btn-icon-group) {
        flex-wrap: wrap;
    }

    .card-body>.d-flex.gap-2>.btn,
    .card-body>.d-flex.gap-2>a.btn {
        flex: 1 1 100%;
    }
}

/* * Desktop layout */
@media screen and (min-width: 769px) {
    #bottom-bar {
        display: none;
    }
}

/* * Chrome, Safari, and Edge */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* * Firefox */
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* * Select2 dark mode uses Bootstrap data-bs-theme="dark". */
html[data-bs-theme="dark"] .select2-container--default .select2-selection--single {
    background-color: #1e1e2d !important;
    border: 1px solid #555 !important;
    height: 38px;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #ffffff !important;
    line-height: 36px;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #b5b5c3 !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #ffffff transparent transparent transparent !important;
}

html[data-bs-theme="dark"] .select2-dropdown {
    background-color: #1e1e2d !important;
    border: 1px solid #555 !important;
}

html[data-bs-theme="dark"] .select2-search--dropdown .select2-search__field {
    background-color: #2a2a3c !important;
    color: #ffffff !important;
    border: 1px solid #555 !important;
}

html[data-bs-theme="dark"] .select2-results__option {
    background-color: #1e1e2d !important;
    color: #ffffff !important;
}

html[data-bs-theme="dark"] .select2-results__option--highlighted {
    background-color: #3699ff !important;
    color: #ffffff !important;
}

html[data-bs-theme="dark"] .select2-results__option[aria-selected="true"] {
    background-color: #3950a2 !important;
    color: #ffffff !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: #1e1e2d !important;
    border: 1px solid #555 !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #3699ff !important;
    border: none !important;
    color: #ffffff !important;
}

html[data-bs-theme="dark"] .select2-selection__choice__remove {
    color: #ffffff !important;
}

html[data-bs-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--single,
html[data-bs-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #3699ff !important;
    box-shadow: 0 0 0 0.2rem rgba(54, 153, 255, 0.25);
}
