/* Bootstrap 5 Compatibility Layer for WHP */
/* This file fixes critical conflicts between Bootstrap 3 styles and Bootstrap 5 */

/* Fix Bootstrap 5 dropdown toggle */
.dropdown-toggle:after {
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

/* Fix navbar collapse functionality */
.navbar-collapse.collapse:not(.show) {
    display: none;
}

.navbar-collapse.collapse.show {
    display: block;
}

/* Fix form control styling for Bootstrap 5 */
.form-control:focus {
    color: #fff;
    background-color: #2d353d;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Fix modal backdrop and positioning */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

/* Fix button styling conflicts */
.btn {
    --bs-btn-padding-x: 0.75rem;
    --bs-btn-padding-y: 0.375rem;
    --bs-btn-font-family: ;
    --bs-btn-font-size: 1rem;
    --bs-btn-font-weight: 400;
    --bs-btn-line-height: 1.5;
    --bs-btn-color: #fff;
    --bs-btn-bg: transparent;
    --bs-btn-border-width: 1px;
    --bs-btn-border-color: transparent;
    --bs-btn-border-radius: 0.375rem;
    display: inline-block;
    padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);
    font-family: var(--bs-btn-font-family);
    font-size: var(--bs-btn-font-size);
    font-weight: var(--bs-btn-font-weight);
    line-height: var(--bs-btn-line-height);
    color: var(--bs-btn-color);
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);
    border-radius: var(--bs-btn-border-radius);
    background-color: var(--bs-btn-bg);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Fix dropdown menu positioning and styling */
.dropdown-menu {
    --bs-dropdown-zindex: 1000;
    --bs-dropdown-min-width: 10rem;
    --bs-dropdown-padding-x: 0;
    --bs-dropdown-padding-y: 0.5rem;
    --bs-dropdown-spacer: 0.125rem;
    --bs-dropdown-font-size: 1rem;
    --bs-dropdown-color: #fff;
    --bs-dropdown-bg: #323b44;
    --bs-dropdown-border-color: rgba(255, 255, 255, 0.15);
    --bs-dropdown-border-radius: 0.375rem;
    --bs-dropdown-border-width: 1px;
    --bs-dropdown-inner-border-radius: calc(0.375rem - 1px);
    --bs-dropdown-divider-bg: rgba(255, 255, 255, 0.15);
    --bs-dropdown-divider-margin-y: 0.5rem;
    --bs-dropdown-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --bs-dropdown-link-color: #fff;
    --bs-dropdown-link-hover-color: #fff;
    --bs-dropdown-link-hover-bg: #2d353d;
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-active-bg: #0d6efd;
    --bs-dropdown-link-disabled-color: rgba(255, 255, 255, 0.5);
    --bs-dropdown-item-padding-x: 1rem;
    --bs-dropdown-item-padding-y: 0.25rem;
    --bs-dropdown-header-color: rgba(255, 255, 255, 0.75);
    --bs-dropdown-header-padding-x: 1rem;
    --bs-dropdown-header-padding-y: 0.5rem;
    position: absolute;
    z-index: var(--bs-dropdown-zindex);
    display: none;
    min-width: var(--bs-dropdown-min-width);
    padding: var(--bs-dropdown-padding-y) var(--bs-dropdown-padding-x);
    margin: 0;
    font-size: var(--bs-dropdown-font-size);
    color: var(--bs-dropdown-color);
    text-align: left;
    list-style: none;
    background-color: var(--bs-dropdown-bg);
    background-clip: padding-box;
    border: var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);
    border-radius: var(--bs-dropdown-border-radius);
    box-shadow: var(--bs-dropdown-box-shadow);
}

.dropdown-menu[data-bs-popper] {
    top: 100%;
    left: 0;
    margin-top: var(--bs-dropdown-spacer);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);
    clear: both;
    font-weight: 400;
    color: var(--bs-dropdown-link-color);
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: var(--bs-dropdown-link-hover-color);
    background-color: var(--bs-dropdown-link-hover-bg);
}

/* Fix user dropdown positioning and z-index issues */
.navbar-right {
    position: relative;
    z-index: 10000 !important;
}

.navbar-right .dropdown {
    position: relative;
    z-index: 10000 !important;
}

.navbar-right .dropdown-menu {
    position: absolute !important;
    right: 0;
    left: auto;
    top: 100% !important;
    z-index: 10000 !important;
    display: none;
}

.navbar-right .dropdown-menu.show {
    display: block !important;
    z-index: 10000 !important;
}

.dropdown-menu.profile {
    z-index: 10000 !important;
    background-color: #2d353d;
    border: 1px solid rgba(255, 255, 255, 0.15);
    min-width: 200px;
}

.dropdown-menu.profile li a {
    color: #fff !important;
    padding: 12px 20px;
    display: block;
    text-decoration: none;
}

.dropdown-menu.profile li a:hover,
.dropdown-menu.profile li a:focus {
    background-color: #323b44;
    color: #fff !important;
}

/* Fix user icon in navbar */
.navbar-nav > li > a {
    color: #fff !important;
    font-size: 18px;
    padding: 15px;
}

/* Fix button visibility and styling */
.btn {
    display: inline-block !important;
    padding: 0.375rem 0.75rem;
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn:hover,
.btn:focus {
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    color: #fff;
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    color: #fff;
    background-color: #5c636a;
    border-color: #565e64;
}

.btn-success {
    color: #fff;
    background-color: #198754;
    border-color: #198754;
}

.btn-success:hover {
    color: #fff;
    background-color: #157347;
    border-color: #146c43;
}

.btn-danger {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}

.btn-danger:hover {
    color: #fff;
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.btn-warning {
    color: #000;
    background-color: #ffc107;
    border-color: #ffc107;
}

.btn-warning:hover {
    color: #000;
    background-color: #ffca2c;
    border-color: #ffc720;
}

.btn-info {
    color: #000;
    background-color: #0dcaf0;
    border-color: #0dcaf0;
}

.btn-info:hover {
    color: #000;
    background-color: #31d2f2;
    border-color: #25cff2;
}

.btn-light {
    color: #000;
    background-color: #f8f9fa;
    border-color: #f8f9fa;
}

.btn-light:hover {
    color: #000;
    background-color: #f9fafb;
    border-color: #f9fafb;
}

.btn-dark {
    color: #fff;
    background-color: #212529;
    border-color: #212529;
}

.btn-dark:hover {
    color: #fff;
    background-color: #1c1f23;
    border-color: #1a1e21;
}

/* Fix navbar toggler for mobile */
.navbar-toggler, .navbar-toggle {
    padding: 0.25rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    transition: box-shadow 0.15s ease-in-out;
    color: #fff;
}

.navbar-toggler:focus, .navbar-toggle:focus {
    text-decoration: none;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.2);
}

.navbar-toggler:hover, .navbar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-image: var(--bs-navbar-toggler-icon-bg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
}

/* Fix Bootstrap 3 navbar-toggle icon bars */
.navbar-toggle .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 1px;
    background-color: #fff;
}

.navbar-toggle .icon-bar + .icon-bar {
    margin-top: 4px;
}

/* Fix hamburger menu button styling */
.navbar-minimalize {
    display: inline-block !important;
    visibility: visible !important;
    margin-right: 15px;
    color: #5e5e5e !important;
    font-size: 21px;
    padding: 13px 15px;
    line-height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.navbar-minimalize:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #5e5e5e !important;
}

.navbar-minimalize .fa-bars {
    color: #5e5e5e !important;
    display: inline-block !important;
    visibility: visible !important;
}

/* Fix collapse animation */
.collapsing {
    position: relative;
    height: 0;
    overflow: hidden;
    transition: height 0.35s ease;
}

/* Fix input group styling */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control,
.input-group > .form-select {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background-color: #2d353d;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.375rem;
}

/* Fix alert styling */
.alert {
    --bs-alert-bg: transparent;
    --bs-alert-padding-x: 1rem;
    --bs-alert-padding-y: 1rem;
    --bs-alert-margin-bottom: 1rem;
    --bs-alert-color: inherit;
    --bs-alert-border-color: transparent;
    --bs-alert-border: 1px solid var(--bs-alert-border-color);
    --bs-alert-border-radius: 0.375rem;
    position: relative;
    padding: var(--bs-alert-padding-y) var(--bs-alert-padding-x);
    margin-bottom: var(--bs-alert-margin-bottom);
    color: var(--bs-alert-color);
    background-color: var(--bs-alert-bg);
    border: var(--bs-alert-border);
    border-radius: var(--bs-alert-border-radius);
}

/* Fix close button styling */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: #fff;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.375rem;
    opacity: 0.5;
}

.btn-close:hover {
    color: #fff;
    text-decoration: none;
    opacity: 0.75;
}

/* Fix card styling to work with existing panel classes */
.panel.card {
    background-color: #323b44;
    border: 1px solid rgba(255, 255, 255, 0.125);
    border-radius: 0.375rem;
}

.panel-heading.card-header {
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    color: #fff;
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
}

.panel-body.card-body {
    flex: 1 1 auto;
    padding: 1rem 1rem;
    color: #fff;
}

/* Fix offcanvas for mobile navigation */
.offcanvas {
    position: fixed;
    bottom: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    color: #fff;
    visibility: hidden;
    background-color: #323b44;
    background-clip: padding-box;
    outline: 0;
    transition: transform 0.3s ease-in-out;
}

/* Ensure tooltips and popovers work */
.tooltip {
    position: absolute;
    z-index: 1080;
    display: block;
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-style: normal;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-decoration: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    word-break: normal;
    white-space: normal;
    word-spacing: normal;
    line-break: auto;
    font-size: 0.875rem;
    word-wrap: break-word;
    opacity: 0;
}

.tooltip.show {
    opacity: 0.9;
}

/* Fix navbar brand positioning */
.navbar-brand {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    margin-right: 1rem;
    font-size: 1.25rem;
    color: #5e5e5e;
    text-decoration: none;
    white-space: nowrap;
}

/* Ensure password modal works properly */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}

.modal-backdrop.fade {
    opacity: 0;
}

.modal-backdrop.show {
    opacity: 0.5;
}

/* Fix sidebar navigation styling and spacing */
.sidebar-collapse {
    background: #fff;
    height: 100%;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
}

#side-menu {
    background: #fff;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
}

#side-menu li {
    list-style: none;
    margin: 0;
    padding: 0;
    border-bottom: none !important;
    background: transparent !important;
}

#side-menu li a {
    display: block !important;
    padding: 15px 20px !important;
    color: #6a6c6f !important;
    text-decoration: none !important;
    line-height: 15px !important;
    transition: all 0.3s ease;
    background: transparent !important;
    border: none !important;
}

#side-menu li a:hover,
#side-menu li:hover a {
    color: #067b9f !important;
    background: transparent !important;
    text-decoration: none !important;
}

#side-menu li.active a {
    color: #067b9f !important;
    background: transparent !important;
    text-decoration: none !important;
}

#side-menu li a i {
    margin-right: 10px;
    width: 16px;
    text-align: center;
}

/* Remove any scrollbars from sidebar */
#menu {
    overflow-x: hidden !important;
    overflow-y: hidden !important;
}

.navbar-aside {
    overflow: hidden !important;
}

/* Fix navbar brand and toggle button layout */
.navbar-brand {
    color: #5e5e5e !important;
    font-weight: 600;
    display: block !important;
    visibility: visible !important;
    font-size: 18px !important;
    text-decoration: none !important;
}

.left-part {
    background: #fff;
    width: 215px;
    height: 62px;
    float: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

/* Fix navbar header positioning */
.navbar-header {
    display: flex;
    align-items: center;
    height: 62px;
}

.navbar-header .navbar-brand {
    margin: 0;
    padding: 0;
    height: auto;
    line-height: normal;
}

/* Fix navbar layout and positioning */
#header {
    background-color: #323b44;
    z-index: 9000;
    position: fixed;
    width: 100%;
    height: 62px;
}

#navbar {
    background-color: #323b44;
    border: none;
    margin-right: 0;
}

/* Fix sidebar z-index to be below user dropdown */
.navbar-aside,
#menu {
    z-index: 1000;
}

/* Ensure main content has proper margins */
#wrapper {
    margin-left: 215px;
    background: #2d353d;
    min-height: calc(100vh - 62px);
    padding-top: 62px;
}

body.hide-sidebar #wrapper {
    margin-left: 0;
}

body.hide-sidebar #menu {
    margin-left: -200px;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    body.page-small #wrapper {
        margin-left: 0;
    }
    
    body.page-small.show-sidebar #wrapper {
        margin-left: 214px;
    }
    
    body.page-small #menu {
        margin-left: -192px;
    }
    
    body.page-small.show-sidebar #menu {
        margin-left: 0;
    }
}

/* Fix splash screen hiding */
.splash {
    position: fixed;
    z-index: 9999;
    background: white;
    color: gray;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    transition: opacity 0.3s ease-out;
}

.splash.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Ensure splash screen can be hidden */
.splash.hidden {
    display: none !important;
} 

/* Utility Classes for Readable Text on Any Background */
.text-dark {
    color: #212529 !important;
}
.text-light {
    color: #f8f9fa !important;
}

/* Remove global white text from headings/labels, use inherit */
h1, h2, h3, h4, h5, h6, .form-label {
    color: inherit;
}

/* Dropdowns, modals, panels: enforce correct text color for background */
.dropdown-menu, .modal-content, .panel.card, .panel-body.card-body, .offcanvas, .navbar-brand {
    color: #fff;
}
.dropdown-menu.bg-light, .modal-content.bg-light, .panel.card.bg-light, .panel-body.card-body.bg-light, .offcanvas.bg-light, .navbar-brand.bg-light {
    color: #212529 !important;
}

/* Headings inside dropdowns, modals, panels: inherit color */
.dropdown-menu h1, .dropdown-menu h2, .dropdown-menu h3, .dropdown-menu h4, .dropdown-menu h5, .dropdown-menu h6,
.modal-content h1, .modal-content h2, .modal-content h3, .modal-content h4, .modal-content h5, .modal-content h6,
.panel.card h1, .panel.card h2, .panel.card h3, .panel.card h4, .panel.card h5, .panel.card h6 {
    color: inherit;
} 