/* Variables */
:root {
    --primary-color: #28a745; /* Updated to green */
    --secondary-color: #6c757d; /* Secondary grey color */
    --success-color: #28a745; /* Success green */
    --background-light: #f8f9fa; /* Light background */
    --text-color: #212529; /* Dark text */
    --card-background: #ffffff; /* Card background */
    --overlay-color: rgba(255, 255, 255, 0.7); /* Loader overlay color */
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-light);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

/* Loader Styles */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
}

.loader.d-none {
    display: none;
}

/* Form Select Styles */
.form-select {
    border-radius: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: 0.5rem;
    transition: background-color 0.3s, border-color 0.3s;
}

.btn-primary:hover {
    background-color: #218838; /* Darker green on hover */
    border-color: #1e7e34;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 99;
    border-radius: 50%;
    padding: 0.5rem 0.6rem;
    transition: opacity 0.3s ease;
}

/* Dark Mode Styles */
.dark-mode {
    background-color: #121212;
    color: #ffffff;
}

.dark-mode .loader {
    background-color: rgba(0, 0, 0, 0.7);
}

.dark-mode .btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.dark-mode .btn-primary:hover,
.dark-mode .btn-primary:focus {
    background-color: #218838;
    border-color: #1e7e34;
    color: #ffffff;
}

.dark-mode .form-select {
    background-color: #2c2c2c;
    color: #ffffff;
    border-color: #444444;
}

.dark-mode .form-select:focus {
    background-color: #3a3a3a;
    color: #ffffff;
    border-color: #5a5a5a;
}

.dark-mode .invalid-feedback {
    color: #ff6b6b;
}

/* Flexbox Layout for Select2 and Button Alignment */
.input-group {
    display: flex;
    align-items: center;
}

.form-select, .select2-container {
    flex: 1;
}

.select2-container--default .select2-selection--single {
    height: 100% !important;
    display: flex;
    align-items: center;
    padding-left: 12px;
    padding-right: 36px; /* Space for arrow */
    border-radius: 4px;
    border: 1px solid #ced4da; /* Matches the form select border */
    box-sizing: border-box;
    user-select: none;
    background-color: #fff;
}

.select2-selection__rendered {
    line-height: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select2-selection__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 8px;
}

.btn {
    flex: 0 0 auto;
    height: auto; /* Ensures the button height adjusts dynamically */
    white-space: nowrap;
    /*padding: 0 15px;*/ /* Adjust padding for button */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 4px;
    line-height: 1.5; /* Added to ensure proper height alignment */
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

    .btn-primary:hover {
        background-color: #218838;
        border-color: #1e7e34;
    }


.select2-selection--single {
    height: 100%;
    display: flex;
    align-items: center;
}

/* Responsive Typography */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .card-body {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    p.lead {
        font-size: 1rem;
    }

    .btn-primary {
        padding: 0.75rem;
        font-size: 1rem;
    }

    .input-group {
        flex-wrap: nowrap;
    }

        .input-group .form-control,
        .input-group .btn {
            flex: 1 1 auto;
            height: 100%; /* Ensures the button matches the select height */
        }
}

/* Pagination Styles */
.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.pagination .page-link {
    color: var(--primary-color);
    transition: background-color 0.3s, color 0.3s;
}

.pagination .page-item.disabled .page-link {
    color: #9E9E9E;
    pointer-events: none;
    background-color: #fff;
    border-color: #dee2e6;
}

.pagination .page-link:hover:not(.disabled) {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.custom-select-width {
    width: auto;
}

@media (max-width: 576px) {
    .pagination {
        justify-content: center;
    }

    .custom-select-width {
        width: 100%;
    }
}

/* Optional: Additional Styles for Enhanced Appearance */
.pagination .page-link {
    border-radius: 0.25rem;
}

.pagination .page-item .page-link {
    padding: 0.5rem 0.75rem;
}

.pagination .page-item:first-child .page-link {
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

.pagination .page-item:last-child .page-link {
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

.d-flex.align-items-center .form-select {
    min-width: 100px;
}

/* Select2 Styles */
.select2-container {
    box-sizing: border-box;
    display: block !important;
    margin: 0;
    position: relative;
    vertical-align: middle;
    width: auto !important; /* Ensure Select2 fits the content */
}

.select2-selection--single {
    height: 100% !important;
    padding-left: 12px;
    padding-right: 40px; /* Space for the arrow */
}

.select2-selection__clear {
    top: 50%;
    transform: translateY(-50%);
}

.select2-selection__arrow {
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
}

.select2-container .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: 40px;
    user-select: none;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color 0.2s ease-in-out;
    padding-right: 36px; /* Spacing for arrow */
}

.select2-container .select2-selection--single:hover {
    border-color: #28a745;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    display: block;
    padding-left: 12px;
    padding-right: 36px; /* Spacing for arrow */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 46px;
    color: #495057;
}

.select2-container .select2-selection--single .select2-selection__clear {
    background-color: transparent;
    border: none;
    font-size: 1em;
    cursor: pointer;
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    padding: 0;
}

.select2-container .select2-selection--single .select2-selection__arrow {
    height: 40px;
    position: absolute;
    top: 0;
    right: 12px;
    width: 20px;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.select2-container .select2-selection--single .select2-selection__arrow b {
    border-color: #6c757d transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
}

.select2-container--default .select2-selection--single {
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6c757d;
}

.select2-container--default .select2-selection--multiple {
    background-color: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: text;
    padding: 5px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0 10px;
    margin-right: 5px;
    margin-top: 5px;
    color: #495057;
    line-height: 28px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #6c757d;
    margin-right: 8px;
    cursor: pointer;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #dc3545;
}

.select2-dropdown {
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: block;
    position: absolute;
    z-index: 1051;
    width: 100%;
    padding: 8px 0;
}

.select2-results__option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.select2-results__option--highlighted.select2-results__option--selectable {
    background-color: #28a745;
    color: white;
}

.select2-search--dropdown .select2-search__field {
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ced4da;
    border-radius: 4px;
    margin-bottom: 10px;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #28a745;
}

.select2-results__group {
    padding: 10px 15px;
    color: #495057;
    font-weight: 600;
}

.select2-hidden-accessible {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    height: 1px !important;
    margin: -1px;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important;
}
