/*
 * UI FIXES — common interaction bugs in AdminLTE / Bootstrap 4 stack
 * --------------------------------------------------------------------------
 *  1. Bootstrap dropdowns inside `.table-responsive` were clipped because the
 *     wrapper uses `overflow-x: auto`. When a dropdown is open, allow the
 *     wrapper to overflow visibly so row-action menus expand fully.
 *
 *  2. Bump `.dropdown-menu` z-index above sticky table headers, the
 *     back-to-top button and any AdminLTE control sidebar.
 *
 *  3. Ensure floating helpers (back-to-top, fixed control buttons) sit BELOW
 *     open dropdowns / modals so they never block clicks on row actions.
 *
 *  4. Make `.btn-group .dropdown-menu` keep its right-aligned positioning so
 *     it doesn't get pushed off-screen on the rightmost column.
 *
 *  5. Restore inherited text colors inside buttons that text-contrast.css's
 *     `.content-wrapper *` rule would otherwise force to dark grey
 *     (e.g. white text inside `.btn-primary`, dropdown items hover state).
 * -------------------------------------------------------------------------- */

/* 1 + 2: Dropdowns inside scroll containers ------------------------------- */
.table-responsive {
    /* Default behavior keeps overflow-x: auto for horizontal scroll, but we
       need visible overflow when a dropdown is open inside it. */
    overflow: visible !important;
}

/* If a parent really must clip horizontally, opt into the legacy behavior
   by adding `.table-responsive-clip` instead. */
.table-responsive-clip {
    overflow-x: auto !important;
    overflow-y: hidden !important;
}

/* Make the dropdown menu float above almost everything except modals. */
.dropdown-menu {
    z-index: 1080 !important;
}

/* AdminLTE wraps action buttons in `.btn-group`; ensure its menu sits on top
   of sibling rows and any sticky table header. */
.table .btn-group,
.table .dropdown {
    position: static;            /* let the menu use the row as positioning context */
}
.table td .btn-group,
.table td .dropdown {
    position: relative;          /* but per-cell context for normal alignment */
}
.table .dropdown-menu {
    position: absolute;
}

/* Right-align action menus so the last column doesn't push them off-screen. */
.table td:last-child .dropdown-menu,
.table th:last-child .dropdown-menu {
    right: 0 !important;
    left: auto !important;
}

/* 3: Lower z-index on floating helpers ------------------------------------ */
#back-to-top {
    z-index: 1030 !important;    /* below dropdowns (1080) and modals (1050+) */
}

/* AdminLTE 'control sidebar' / floating action buttons follow the same rule */
.control-sidebar-btn,
.floating-action-btn {
    z-index: 1030 !important;
}

/* 4: Hide back-to-top when a modal is open so it doesn't sit over the
      modal backdrop / close button. */
body.modal-open #back-to-top {
    display: none !important;
}

/* 5: Button text-color preservation --------------------------------------- */
/* text-contrast.css applies `.content-wrapper * { color: #1f2937 }`. That
   rule wins over Bootstrap's button color because of specificity. Force
   buttons (and their inner spans/icons) to use their intended color. */
.content-wrapper .btn,
.content-wrapper .btn *,
.content-wrapper .btn i,
.content-wrapper .btn span {
    color: inherit !important;
}

.content-wrapper .btn-primary,
.content-wrapper .btn-secondary,
.content-wrapper .btn-success,
.content-wrapper .btn-danger,
.content-wrapper .btn-info,
.content-wrapper .btn-dark,
.content-wrapper .btn-navy,
.content-wrapper .btn-indigo,
.content-wrapper .btn-purple,
.content-wrapper .btn-fuchsia,
.content-wrapper .btn-pink,
.content-wrapper .btn-maroon,
.content-wrapper .btn-teal,
.content-wrapper .btn-black {
    color: #ffffff !important;
}

.content-wrapper .btn-warning,
.content-wrapper .btn-light,
.content-wrapper .btn-orange,
.content-wrapper .btn-lime,
.content-wrapper .btn-olive,
.content-wrapper .btn-outline-primary,
.content-wrapper .btn-outline-secondary,
.content-wrapper .btn-outline-success,
.content-wrapper .btn-outline-danger,
.content-wrapper .btn-outline-info {
    color: #1f2937 !important;
}

/* Outline buttons should turn white when hovered/active because they fill
   in with their accent color. */
.content-wrapper .btn-outline-primary:hover,
.content-wrapper .btn-outline-primary.active,
.content-wrapper .btn-outline-secondary:hover,
.content-wrapper .btn-outline-secondary.active,
.content-wrapper .btn-outline-success:hover,
.content-wrapper .btn-outline-success.active,
.content-wrapper .btn-outline-danger:hover,
.content-wrapper .btn-outline-danger.active,
.content-wrapper .btn-outline-info:hover,
.content-wrapper .btn-outline-info.active {
    color: #ffffff !important;
}

/* Dropdown items: keep AdminLTE's hover background but allow correct text */
.content-wrapper .dropdown-menu .dropdown-item {
    color: #172B4D !important;
}
.content-wrapper .dropdown-menu .dropdown-item:hover,
.content-wrapper .dropdown-menu .dropdown-item:focus {
    color: #ffffff !important;
    background-color: #2675D7 !important;
}
.content-wrapper .dropdown-menu .dropdown-item.active {
    color: #ffffff !important;
    background-color: #0052CC !important;
}

/* Make sure clickable action buttons aren't accidentally covered by an
   absolutely-positioned ::before/::after overlay that some themes ship. */
.content-wrapper .btn,
.content-wrapper .dropdown-toggle {
    position: relative;
    z-index: 1;
}

/* Fix: sticky table headers occasionally floated above open dropdowns. */
.table thead.sticky-top th,
.table thead th.sticky-top {
    z-index: 2;
}
