/**
 * DROPDOWN FIX - Clean & Simple
 * Ensures dropdowns always appear on top
 * No complex JavaScript needed
 */

/* STEP 1: Remove stacking contexts from containers */
.container-fluid,
.panel,
.panel-wrapper,
.panel-body,
.panel-heading,
.form-body,
.row,
.white-box,
.table-responsive {
    position: static !important;
    z-index: auto !important;
    overflow: visible !important;
    transform: none !important;
}

/* STEP 2: Set parent containers to relative positioning */
.col-md-3,
.col-md-4,
.col-md-6,
.col-sm-6,
.col-lg-3,
.form-group {
    position: relative !important;
    z-index: 1 !important;
}

/* STEP 3: Chosen container base */
.chosen-container {
    position: relative !important;
    width: 100% !important;
    z-index: 1 !important;
}

/* STEP 3.5: Smooth modern styling for dropdown trigger/search bar */
.chosen-container-single .chosen-single {
    height: 44px !important;
    line-height: 42px !important;
    padding: 0 40px 0 16px !important;
    background: white !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease-in-out !important;
    font-size: 14px !important;
    color: #1f2937 !important;
    font-weight: 500 !important;
    text-align: left !important;
    cursor: pointer !important;
}

.chosen-container-single .chosen-single span {
    text-align: center !important;
    display: block !important;
    color: #6b7280 !important;
}

.chosen-container-single .chosen-single:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
}

.chosen-container-active.chosen-with-drop .chosen-single {
    border-color: #00809D !important;
    border-bottom-left-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
    box-shadow: 0 0 0 3px rgba(0, 128, 157, 0.1) !important;
}

/* Dropdown arrow styling - Minimal interference */
.chosen-container-single .chosen-single div b {
    transition: transform 0.2s ease !important;
}

/* Rotate arrow when dropdown is open (optional animation) */
/* Uncomment the rule below to enable arrow rotation:
.chosen-container-active.chosen-with-drop .chosen-single div b {
    transform: rotate(180deg) !important;
}
*/

/* STEP 4: Dropdown menu with HIGHEST z-index */
.chosen-container .chosen-drop {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99999 !important;
    background: white !important;
    border: 2px solid #00809D !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    margin-top: -2px !important;
}

/* STEP 5: When dropdown is open, elevate parent */
.chosen-container-active,
.chosen-container.chosen-with-drop {
    z-index: 100000 !important;
}

.col-md-3:has(.chosen-container-active),
.col-md-4:has(.chosen-container-active),
.col-md-6:has(.chosen-container-active),
.form-group:has(.chosen-container-active) {
    z-index: 100000 !important;
}

/* STEP 6: Results list - SMOOTH SCROLL WITH HIDDEN SCROLLBAR */
.chosen-container .chosen-drop {
    overflow: hidden !important; /* Prevent double scrollbar container */
}

.chosen-container .chosen-results {
    max-height: 240px !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 6px !important;
    
    /* Hide scrollbar but keep scroll functionality */
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE/Edge */
}

/* Hide scrollbar for Chrome, Safari, Opera */
.chosen-container .chosen-results::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.chosen-container .chosen-results li {
    padding: 12px 16px !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    margin: 3px 0 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-size: 14px !important;
    color: #374151 !important;
}

.chosen-container .chosen-results li:hover,
.chosen-container .chosen-results li.highlighted {
    background: #00809D !important;
    color: white !important;
    transform: translateX(2px) !important;
    box-shadow: 0 2px 4px rgba(0, 128, 157, 0.1) !important;
}

/* STEP 7: Search input in dropdown - SMOOTH MODERN STYLE */
.chosen-container .chosen-search {
    padding: 10px !important;
    background: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
}

.chosen-container .chosen-search input[type="text"] {
    width: 100% !important;
    padding: 10px 14px !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    outline: none !important;
    transition: all 0.2s ease-in-out !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    background: white !important;
    color: #1f2937 !important;
    text-align: center !important;
}

.chosen-container .chosen-search input[type="text"]::placeholder {
    color: #9ca3af !important;
    opacity: 0.8 !important;
    text-align: center !important;
}

.chosen-container .chosen-search input[type="text"]:focus {
    border-color: #00809D !important;
    box-shadow: 0 0 0 3px rgba(0, 128, 157, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

.chosen-container .chosen-search input[type="text"]:hover {
    border-color: #cbd5e1 !important;
}

/* STEP 9: Ensure buttons and other elements stay below */
.btn,
.search-customer,
.form-actions button {
    position: relative !important;
    z-index: 1 !important;
}

/* STEP 10: Fix any transform-based animations that create stacking contexts */
.fade-in,
.slide-up,
.info-color-box .white-box,
.panel {
    transform: none !important;
}

.fade-in {
    animation: fadeInSimple 0.3s ease !important;
}

.slide-up {
    animation: slideUpSimple 0.3s ease !important;
}

@keyframes fadeInSimple {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpSimple {
    from { opacity: 0; margin-top: 20px; }
    to { opacity: 1; margin-top: 0; }
}

/* STEP 11: Remove hover transforms that create stacking contexts */
.info-color-box .white-box:hover,
.white-box:hover,
.panel:hover {
    transform: none !important;
}

/* STEP 12: Ensure DataTables doesn't interfere */
.dataTables_wrapper {
    z-index: 1 !important;
    position: relative !important;
}

/* STEP 13: Debug helper - add red border to see dropdown */
/* Uncomment to debug:
.chosen-container .chosen-drop {
    border: 3px solid red !important;
}
*/

