/*
 * Bootstrap 3 Compatibility Styles for Bootstrap 4.6.2
 * 
 * Purpose:
 * This file provides compatibility fixes for the Bootstrap 3.3.5 to 4.6.2 upgrade.
 * It addresses layout and styling differences caused by Bootstrap 4's shift from 
 * float-based to flexbox-based grid system.
 * 
 * Issues Fixed:
 * - Dropdown padding, hover behavior, and caret display
 * - Footer alignment (centering)
 * - Button alignment in forms (float-based layout restoration)
 * - Sign-in page background height
 * - Session expiration modal display and centering
 * - HR element spacing
 * 
 * Usage:
 * Load this file AFTER bootstrap.min.css in all pages using Bootstrap.
 * The CSS uses !important declarations to override Bootstrap 4 defaults.
 * 
 * Maintenance:
 * When adding new fixes, reference Bootstrap 3.3.5 behavior from:
 * /bootstrap/css/bootstrap-3.3.5-backup.min.css
 */

/* ========================================
   DROPDOWN CLASSES
   ======================================== */

/* Restore Bootstrap 3 dropdown padding and spacing */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    float: left;
    min-width: 160px;
    padding: 5px 0;
    margin: 2px 0 0;
    font-size: 14px;
    text-align: left;
    list-style: none;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
}

.dropdown-menu > li > a {
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: 400;
    line-height: 1.42857143;
    color: #333;
    white-space: nowrap;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
    color: #262626;
    text-decoration: none;
    background-color: #f5f5f5;
}

.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
    color: #fff;
    text-decoration: none;
    background-color: #337ab7;
    outline: 0;
}

/* Restore Bootstrap 3 divider */
.dropdown-menu .divider {
    height: 1px;
    margin: 9px 0;
    overflow: hidden;
    background-color: #e5e5e5;
}

/* Show dropdown menu when parent has .open class */
.open > .dropdown-menu {
    display: block;
}

/* Multi-level dropdown support (removed in Bootstrap 4) */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .dropdown-menu {
    top: 0;
    left: auto;
    right: 100%;
    margin-top: -6px;
    margin-left: -1px;
    border-radius: 0 6px 6px 6px;
}

.dropdown-submenu:hover > .dropdown-menu {
    display: block;
}

.dropdown-submenu > a:after {
    display: block;
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover > a:after {
    border-left-color: #fff;
}

/* Restore Bootstrap 3 caret */
.caret {
    display: inline-block !important;
    width: 0;
    height: 0;
    margin-left: 2px;
    vertical-align: middle;
    border-top: 4px dashed;
    border-top: 4px solid \9;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

/* Hide Bootstrap 4's auto-generated caret (::after pseudo-element)
   since we're using explicit <b class="caret"> elements */
.dropdown-toggle::after {
    display: none !important;
}

/* ========================================
   FOOTER FIX
   ======================================== */
/* Removed footer-bottom-links centering as it conflicts with custom-search-form */
/* Apply centering only to sign-in-background pages (index.html) */
.sign-in-background #footer-bottom-links {
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    display: block !important;
}

.sign-in-background #footer-bottom-links ul {
    display: inline-block !important;
}

.footer {
    padding: 2px 0 63px 0 !important;
}

/* ========================================
   BUTTON ALIGNMENT FIX
   ======================================== */

/* Restore Bootstrap 3 float-based layout for rows containing button-set */
.row:has(.button-set),
.container .row:has(.button-set) {
    display: block !important;
    margin-right: -15px !important;
    margin-left: -15px !important;
}

/* Restore Bootstrap 3 float-based column behavior for rows with button-set */
.row:has(.button-set) > [class*="col-"],
.container .row:has(.button-set) > [class*="col-"] {
    float: left !important;
    position: relative;
    min-height: 1px;
    padding-left: 15px;
    padding-right: 15px;
}

/* Clearfix for floated columns */
.row:has(.button-set)::after,
.container .row:has(.button-set)::after {
    content: "";
    display: table;
    clear: both;
}

.button-set,
.button-set.pull-right {
    float: right !important;
    display: inline-block !important;
}

.button-set .btn {
    display: inline-block !important;
    vertical-align: middle;
}

.button-set .btn-space {
    margin-right: 20px !important;
}

/* ========================================
   SIGN-IN PAGE FIX
   ======================================== */

/* Scope height: 100% to sign-in page only */
.sign-in-background,
.sign-in-background html,
.sign-in-background body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.sign-in-background {
    width: 100%;
    position: relative;
}

.sign-in-background > .container {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.sign-in-background .container > .row:first-child {
    margin-top: 0 !important;
}


/* ========================================
   SESSION MODAL FIX
   ======================================== */

/* Session expiration and error page modal */
body > .modal-content.session-type,
.modal-content.session-type {
    width: 40% !important;
    max-width: none !important;
    min-width: 400px !important;
    margin: 60px auto 0 auto !important;
    text-align: center;
    padding-bottom: 30px;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,.5);
    display: block;
}

.modal-content.session-type .row {
    margin-left: -15px !important;
    margin-right: -15px !important;
    display: block !important;
}

.modal-content.session-type .row > [class*="col-"] {
    float: left !important;
    position: relative;
    min-height: 1px;
    padding-left: 15px;
    padding-right: 15px;
}

.modal-content.session-type .row::after {
    content: "";
    display: table;
    clear: both;
}
.modal-content.session-type .sign-in-product {
    font-size: 2.0em;
    text-align: center;
    font-weight: 400;
}

.modal-content.session-type label[style*="color: red"],
.modal-content.session-type label[style*="color:red"] {
    color: red !important;
    font-size: 0.85em;
    padding-bottom: 40px;
    text-align: center;
    display: block;
}

.modal-content.session-type .container-fluid {
    width: 100%;
    padding: 0;
}

.modal-content.session-type .btn-submit {
    width: 100% !important;
    max-width: 100px;
    margin: 0 auto;
    display: block;
    color: #eeeeee !important;
    background-color: #e57110 !important;
    border-color: #e57110 !important;
}

.modal-content.session-type .btn-submit:hover {
    color: #eeeeee !important;
    background-color: #bf5d0d !important;
    border-color: #bf5d0d !important;
}


/* ========================================
   HR ELEMENT FIX
   ======================================== */

hr {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
}

.reportsection_hr {
    clear: both;
}

/* Restore Bootstrap 3 clearfix for containers
   Bootstrap 3 had ::before and ::after pseudo-elements for clearing floats */
.container::before,
.container::after {
    display: table !important;
    content: " " !important;
}

.container::after {
    clear: both !important;
}

/* Restore Bootstrap 3 clearfix for ALL rows
   Bootstrap 3 had ::before and ::after on every row for proper float containment */
.row {
    margin-right: -15px !important;
    margin-left: -15px !important;
}

.row::before,
.row::after {
    display: table !important;
    content: " " !important;
}

.row::after {
    clear: both !important;
}

@media (min-width: 768px) {
    .col-md-3 {
        max-width: 100%;
        float: left;
    }
}


/* ========================================
   HIDDEN CLASS FIX
   ======================================== */

/* Restore Bootstrap 3 .hidden class
   Bootstrap 3: .hidden {display:none!important}
   Bootstrap 4: Class removed - use .d-none instead */
.hidden {
    display: none !important;
}

/* ========================================
   CRITERIA FORM LAYOUT FIX
   ======================================== */

/* Restore Bootstrap 3 float-based grid system for all criteria forms
   Bootstrap 3: All columns float left with specific widths
   Bootstrap 4: Uses flexbox which breaks the layout */

/* Make criteria forms use block layout, not flexbox */
.criteria-form,
form.criteria-form {
    display: block !important;
}

/* Restore exact Bootstrap 3 column widths */
.criteria-form .col-md-5,
.criteria-form .col-sm-5 {
    width: 41.66666667% !important;
}

.criteria-form .col-md-6,
.criteria-form .col-sm-6 {
    width: 50% !important;
}

/* Button containers - auto width to sit side by side with minimal spacing */
.criteria-form div.form-group.col-md-6:not(.btn-enter-more-div):not([class*="btn-enter-more"]) {
    width: auto !important;
    float: left !important;
    padding-right: 10px !important;
}

.criteria-form .btn-enter-more-div,
.criteria-form div[class*="btn-enter-more"].form-group {
    width: auto !important;
    float: left !important;
    padding-left: 0 !important;
    position: relative !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
}

/* From/To field divs - float left to sit side by side */
.criteria-form .from-field-div[class*="col-"],
.criteria-form .to-field-div[class*="col-"],
.criteria-popular-pick-row .from-field-div[class*="col-"],
.criteria-popular-pick-row .to-field-div[class*="col-"] {
    float: left !important;
    position: relative !important;
    min-height: 1px !important;
    padding-right: 15px !important;
    padding-left: 15px !important;
    display: block !important;
    margin-bottom: 15px !important;
}

/* Clear floats after criteria form */
.criteria-form::after {
    content: "" !important;
    display: table !important;
    clear: both !important;
}

/* ========================================
   BUTTON TEXT WRAPPING FIX
   ======================================== */

/* Prevent button text from wrapping to multiple lines
   Bootstrap 4 allows text wrapping by default, Bootstrap 3 didn't
   Scope to legacy forms that depend on Bootstrap 3-style single-line buttons */
.btn {
    white-space: nowrap !important;
}

/* ===============================================   
   EXPORT PACKAGES GRID FIX
   ======================================== */

/* Fix package items to display in 4 columns with wrapping
   Bootstrap 3: col-md-3 items wrap automatically after 4 items (4x25%=100%)
   Bootstrap 4: Flexbox prevents proper wrapping */

.package-items-div {
    display: block !important;
    margin-left: 5px !important;
}

.package-items-div > [class*="col-"] {
    float: left !important;
    position: relative !important;
    min-height: 1px !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    width: 25% !important;
}

/* ===============================================
   MULTI-SELECT SIZE FIX
   ===============================================
   Bootstrap 4 doesn't properly render multi-select
   boxes with size attribute. Force auto height to
   show the specified number of items.
   =============================================== */

select[multiple],
select[size] {
    height: auto !important;
}

/* Override rq_style_reskin.css which sets .modal-content { width: 89% } */
.modal-content {
    width: 100% !important;
}

/* ===============================================
   PANEL CLASSES (Bootstrap 3 Restoration)
   ===============================================
   Restore Bootstrap 3 panel classes.
   Bootstrap 4 removed panels in favor of cards.
   =============================================== */

.panel {
    margin-bottom: 20px;
    background-color: #fff;
    border: 1px solid transparent;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.panel-body {
    padding: 15px;
}

.panel-heading {
    padding: 10px 15px;
    border-bottom: 1px solid transparent;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
}

.panel-heading > .dropdown .dropdown-toggle {
    color: inherit;
}

.panel-title {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 16px;
    color: inherit;
}

.panel-title > a,
.panel-title > small,
.panel-title > .small,
.panel-title > small > a,
.panel-title > .small > a {
    color: inherit;
}

.panel-footer {
    padding: 10px 15px;
    background-color: #f5f5f5;
    border-top: 1px solid #ddd;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
}

/* Panel variants */
.panel-default {
    border-color: #ddd;
}

.panel-default > .panel-heading {
    color: #333;
    background-color: #f5f5f5;
    border-color: #ddd;
}

.panel-default > .panel-heading + .panel-collapse > .panel-body {
    border-top-color: #ddd;
}

.panel-default > .panel-footer + .panel-collapse > .panel-body {
    border-bottom-color: #ddd;
}

.panel-primary {
    border-color: #337ab7;
}

.panel-primary > .panel-heading {
    color: #fff;
    background-color: #337ab7;
    border-color: #337ab7;
}

.panel-primary > .panel-heading + .panel-collapse > .panel-body {
    border-top-color: #337ab7;
}

/* Panel groups */
.panel-group {
    margin-bottom: 20px;
}

.panel-group .panel {
    margin-bottom: 0;
    border-radius: 4px;
}

.panel-group .panel + .panel {
    margin-top: 5px;
}

.panel-group .panel-heading {
    border-bottom: 0;
}

.panel-group .panel-heading + .panel-collapse > .panel-body,
.panel-group .panel-heading + .panel-collapse > .list-group {
    border-top: 1px solid #ddd;
}

.panel-group .panel-footer {
    border-top: 0;
}

.panel-group .panel-footer + .panel-collapse > .panel-body {
    border-bottom: 1px solid #ddd;
}

/* Panel collapse */
.panel > .panel-heading + .panel-collapse > .panel-body,
.panel > .panel-heading + .panel-collapse > .list-group {
    border-top: 1px solid #ddd;
}

.panel > .panel-footer + .panel-collapse > .panel-body {
    border-bottom: 1px solid #ddd;
}


.mfa .ui-dialog-titlebar-close {
    margin-top: 0;
    margin-right: 20px;
    /* Fix for jQuery UI close button conflict with Bootstrap */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 25px !important;
    height: 25px !important;
    padding: 0 !important;
    top: 50% !important;
}

/* Restore the Close 'X' icon */
.mfa .ui-dialog-titlebar-close::after {
    content: "\00d7"; /* X */
    font-size: 22px;
    font-weight: bolder;
    color: black;
    line-height: 20px;
    display: block;
    text-align: center;
}

/* ========================================
   ANCHOR COLOR FIX
   ======================================== */
/* 
   Override Bootstrap 4 rule that makes anchors without href/class 
   inherit color/decoration. Restore Bootstrap 3 link appearance.
*/
a:not([href]):not([class]) {
    color: #337ab7;
    text-decoration: none;
    cursor: pointer;
}

a:not([href]):not([class]):hover {
    color: #23527c;
    text-decoration: underline;
}

/* ========================================
   GLYPHICON RESTORATION
   ======================================== */
/* 
   Restore Bootstrap 3 glyphicons (removed in Bootstrap 4)
   Using Font Awesome Unicode equivalents for compatibility
*/

.glyphicon {
    position: relative;
    top: 1px;
    display: inline-block;
    font-style: normal;
    font-weight: 400;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.glyphicon-ok::before {
    content: "\2713"; /* ✓ Unicode checkmark */
    color: #4CAF50;
    font-size: 18px;
    font-weight: bold;
}

.glyphicon-remove::before {
    content: "\2717"; /* ✗ Unicode X mark */
    color: #f44336;
    font-size: 18px;
    font-weight: bold;
}

.downloaded-ok {
    color: #4CAF50 !important;
}

.downloaded-error {
    color: #f44336 !important;
}

/* ========================================
   MODAL HEADER FIX (Multi-Subject Search)
   ======================================== */
/* 
   Fix modal header alignment in Bootstrap 4 for multi-subject search modal ONLY
   Bootstrap 4 modal-header uses flex which prevents centering
   Target only modals containing #multisubjects-loading-section to avoid affecting other modals
*/

.modal-header:has(#multisubjects-loading-section),
#modal-info-page .modal-header,
#searchProgress-page .modal-header {
    display: block !important;
    text-align: center !important;
}

/* Ensure card_title centers properly inside multi-subject search modal */
.modal-header:has(#multisubjects-loading-section) .card_title,
#modal-info-page .modal-header .card_title,
#searchProgress-page .modal-header .card_title,
#multisubjects-properties-found-header,
#modal-report-summary .modal-header {
    text-align: center !important;
    display: block !important;
    width: 100% !important;
}

.subject-list-header .col-md-3 {
    width: 161.67px;
    flex: 0 0 161.67px;
    max-width: 161.67px;
}

.subject-list-header .col-md-9 {
    max-width: max-content;
    display: flex;
    flex: 1 1 auto;
    width: auto;
}

/* Remove left padding from columns within subject-list-row
   to ensure buttons (VIEW, VIEW ALL REPORTS) align properly
   with the right edge  */
.subject-list-row .col-md-3 {
    padding-left: 0;
}

.subject-list-row .col-md-2 {
    padding-left: 0;
}

/* ========================================
   REPORT STYLING FIX
   ======================================== */

b, strong {
    font-weight: 700 !important;
}
