/**
 * AdminLTE 3 + Bootstrap 5 Compatibility CSS
 * 
 * This file provides compatibility fixes to make AdminLTE 3.2 work with Bootstrap 5
 * Add this file after Bootstrap 5 CSS and before AdminLTE CSS
 */

/* Fix for Bootstrap 5 removed jQuery dependency - AdminLTE still uses jQuery */
/* Most AdminLTE JS functionality should still work */

/* Fix for Bootstrap 5 form-control changes */
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Fix for AdminLTE sidebar with Bootstrap 5 */
.main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    min-height: 100%;
    z-index: 810;
    transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
}

/* Fix for navbar with Bootstrap 5 */
.main-header .navbar-nav .nav-link {
    padding: 0.5rem 1rem;
}

/* Fix for dropdown menu positioning */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    min-width: 10rem;
    padding: 0.5rem 0;
    margin: 0.125rem 0 0;
    font-size: 1rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
}

/* Fix for card components */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.25rem;
}

.card-header {
    padding: 0.75rem 1.25rem;
    margin-bottom: 0;
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}

/* Fix for small-box components (AdminLTE specific) */
.small-box {
    border-radius: 0.25rem;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.125), 0 1px 3px rgba(0, 0, 0, 0.2);
    display: block;
    margin-bottom: 20px;
    position: relative;
}

/* Fix for input-group with Bootstrap 5 */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: center;
    white-space: nowrap;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
}

.input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Fix for badge components */
.badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

/* Fix for button groups */
.btn-group,
.btn-group-vertical {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

/* Fix for navbar brand */
.navbar-brand {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    margin-right: 1rem;
    font-size: 1.25rem;
    text-decoration: none;
    white-space: nowrap;
}

/* Fix for sidebar navigation */
.nav-sidebar .nav-link {
    display: block;
    padding: 0.5rem 1rem;
}

.nav-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Fix for content wrapper */
.content-wrapper {
    background-color: #f4f6f9;
    margin-left: 250px;
    min-height: 100vh;
    transition: margin-left 0.3s ease-in-out;
}

/* Fix for sidebar collapsed state */
.sidebar-mini .content-wrapper {
    margin-left: 4.6rem;
}

/* Fix for responsive behavior */
@media (max-width: 767.98px) {
    .content-wrapper {
        margin-left: 0;
    }
    
    .main-sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar-open .main-sidebar {
        transform: translateX(0);
    }
}

/* Fix for AdminLTE specific utilities */
.elevation-1 {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24) !important;
}

.elevation-2 {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23) !important;
}

.elevation-3 {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23) !important;
}

.elevation-4 {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22) !important;
}

.elevation-5 {
    box-shadow: 0 19px 38px rgba(0, 0, 0, 0.30), 0 15px 12px rgba(0, 0, 0, 0.22) !important;
}

/* Fix for font-weight utilities */
.font-weight-light {
    font-weight: 300 !important;
}

.font-weight-normal {
    font-weight: 400 !important;
}

.font-weight-bold {
    font-weight: 700 !important;
}

/* Additional AdminLTE compatibility fixes */
.brand-text {
    font-weight: 300;
}

.main-header {
    border-bottom: 1px solid #dee2e6;
    z-index: 1034;
}

.main-header .navbar-nav .nav-link {
    height: 2.5rem;
}

/* Fix for sidebar search */
.sidebar .form-control-sidebar {
    border-radius: 0;
    border-width: 0 0 1px;
}

.sidebar .form-control-sidebar:focus {
    border-color: #80bdff;
    box-shadow: none;
}

/* Fix for user menu dropdown */
.user-menu .dropdown-menu {
    width: 280px;
    padding: 0;
    margin-top: 0;
    top: 100%;
    right: 0;
    left: auto;
}

.user-header {
    background-color: #343a40;
    padding: 10px;
    text-align: center;
}

.user-header img {
    z-index: 5;
    height: 90px;
    width: 90px;
    border: 3px solid;
    border-color: transparent;
    border-color: rgba(255, 255, 255, 0.2);
}

.user-header p {
    z-index: 5;
    color: #fff;
    color: rgba(255, 255, 255, 0.8);
    font-size: 17px;
    margin-top: 10px;
}

.user-header .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

.user-footer {
    background-color: #f8f9fa;
    padding: 10px;
}

.user-footer::before {
    content: "";
    display: table;
}

.user-footer::after {
    content: "";
    display: table;
    clear: both;
}

.user-footer .btn-default {
    color: #6c757d;
}

/* Fix for sidebar navigation treeview */
.nav-treeview {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    padding-left: 5px;
}

.nav-treeview > .nav-item > .nav-link {
    padding-left: 2rem;
}

.menu-open > .nav-treeview {
    display: block;
}

/* Fix for sidebar icons */
.nav-icon {
    margin-right: 0.5rem;
    text-align: center;
    width: 1.6rem;
}

/* Additional Bootstrap 5 compatibility */
/* Ensure AdminLTE components work with Bootstrap 5's updated classes */

/* Fix for text utilities that changed in BS5 */
.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

@media (min-width: 576px) {
    .text-sm-left {
        text-align: left !important;
    }
    .text-sm-right {
        text-align: right !important;
    }
}

@media (min-width: 768px) {
    .text-md-left {
        text-align: left !important;
    }
    .text-md-right {
        text-align: right !important;
    }
}

@media (min-width: 992px) {
    .text-lg-left {
        text-align: left !important;
    }
    .text-lg-right {
        text-align: right !important;
    }
}

@media (min-width: 1200px) {
    .text-xl-left {
        text-align: left !important;
    }
    .text-xl-right {
        text-align: right !important;
    }
}

/* Fix for float utilities that changed in BS5 */
.float-left {
    float: left !important;
}

.float-right {
    float: right !important;
}

@media (min-width: 576px) {
    .float-sm-left {
        float: left !important;
    }
    .float-sm-right {
        float: right !important;
    }
}

@media (min-width: 768px) {
    .float-md-left {
        float: left !important;
    }
    .float-md-right {
        float: right !important;
    }
}

@media (min-width: 992px) {
    .float-lg-left {
        float: left !important;
    }
    .float-lg-right {
        float: right !important;
    }
}

@media (min-width: 1200px) {
    .float-xl-left {
        float: left !important;
    }
    .float-xl-right {
        float: right !important;
    }
}

/* Fix for margin/padding utilities - keep ml-*, mr-*, pl-*, pr-* working */
.ml-auto {
    margin-left: auto !important;
}

.mr-auto {
    margin-right: auto !important;
}

.ml-0 {
    margin-left: 0 !important;
}

.mr-0 {
    margin-right: 0 !important;
}

.ml-1 {
    margin-left: 0.25rem !important;
}

.mr-1 {
    margin-right: 0.25rem !important;
}

.ml-2 {
    margin-left: 0.5rem !important;
}

.mr-2 {
    margin-right: 0.5rem !important;
}

.ml-3 {
    margin-left: 1rem !important;
}

.mr-3 {
    margin-right: 1rem !important;
}

.pl-0 {
    padding-left: 0 !important;
}

.pr-0 {
    padding-right: 0 !important;
}

.pl-1 {
    padding-left: 0.25rem !important;
}

.pr-1 {
    padding-right: 0.25rem !important;
}

.pl-2 {
    padding-left: 0.5rem !important;
}

.pr-2 {
    padding-right: 0.5rem !important;
}

.pl-3 {
    padding-left: 1rem !important;
}

.pr-3 {
    padding-right: 1rem !important;
}

/* Fix for dropdown-menu-right (changed to dropdown-menu-end in BS5) */
.dropdown-menu-right {
    right: 0;
    left: auto;
}

/* Ensure AdminLTE modals work with Bootstrap 5 */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}

.modal-backdrop.fade {
    opacity: 0;
}

.modal-backdrop.show {
    opacity: 0.5;
}

/* Fix for AdminLTE specific form styling */
.form-group {
    margin-bottom: 1rem;
}

.form-control-sm {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
}

/* Fix for AdminLTE tables */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    vertical-align: top;
    border-color: #dee2e6;
}

.table > :not(caption) > * > * {
    padding: 0.5rem 0.5rem;
    background-color: var(--bs-table-bg);
    border-bottom-width: 1px;
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
}

.table-striped > tbody > tr:nth-of-type(odd) > td,
.table-striped > tbody > tr:nth-of-type(odd) > th {
    --bs-table-accent-bg: rgba(0, 0, 0, 0.05);
    color: var(--bs-table-color);
}

/* Additional fixes as needed during testing */
