/*
 * Navbar Z-Index Fix
 * Ensures proper stacking order for all elements
 *
 * Z-Index Hierarchy (lowest to highest):
 * 1      - Page content (cards, divs, etc)
 * 1020   - Alerts in page content
 * 1030   - Navbar (fixed)
 * 1040   - Dropdown menus
 * 1045   - Toast notifications & fixed alerts
 * 1050   - Modal backdrop
 * 1055   - Modals
 * 1056   - Modal dialogs
 * 1060   - SweetAlert2
 *
 * Author: Claude Code
 * Updated: November 5, 2025
 */

/* Fix navbar z-index to ensure proper stacking order */
.layout-navbar,
#layout-navbar,
.navbar,
nav.layout-navbar,
header.navbar,
nav#layout-navbar {
    z-index: 1030 !important; /* Bootstrap standard navbar z-index */
    position: relative;
    overflow: visible !important; /* Ensure dropdowns can extend outside navbar */
}

/* Force navbar wrapper to maintain z-index */
.layout-wrapper .layout-navbar {
    z-index: 1030 !important;
}

/* For fixed/sticky navbars */
.navbar-fixed-top,
.fixed-top,
.navbar.fixed-top,
.layout-navbar.navbar-fixed {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030 !important;
}

/* Ensure the navbar container doesn't interfere with modals */
/* Commented out - this was causing extra gap above content
.layout-navbar-fixed .layout-page {
    padding-top: 4.75rem;
}
*/

/* Ensure notifications and dropdowns appear above navbar but below modals */
.notification-dropdown,
.dropdown-menu {
    z-index: 1040 !important;
}

.toast-container,
.toast,
.floating-notification,
.toast-top-right {
    z-index: 1045 !important;
    margin-top: 60px !important; /* Add margin to avoid overlap with navbar */
}

/* Alerts in page content - ensure they don't overlap navbar */
.alert,
.alert-success,
.alert-info,
.alert-warning,
.alert-danger,
.alert-dismissible {
    position: relative !important;
    z-index: 1 !important; /* Way below navbar to prevent any overlap */
}

/* Specifically target Bootstrap alert components */
div.alert,
.row .alert {
    z-index: 1 !important;
    position: relative !important;
}

/* Alerts at top of page (fixed positioning) */
.alert.fixed-top,
.alert.position-fixed {
    z-index: 1045 !important;
    margin-top: 60px !important;
}

/* SweetAlert2 should appear above everything except modals */
.swal2-container {
    z-index: 1060 !important;
}

/* Ensure navbar brand and content stay properly positioned */
.navbar-brand,
.navbar-nav,
.navbar-toggler {
    z-index: auto !important;
    position: relative;
}

/* Fix for modals - they should be above everything */
.modal-backdrop {
    z-index: 1050 !important; /* Bootstrap standard modal backdrop */
}

.modal {
    z-index: 1055 !important; /* Bootstrap standard modal */
}

/* Specific fix for QR attachment modal */
#qrAttachmentsModal,
#timelineModal,
#addTimelineEntryModal {
    z-index: 1055 !important;
}

/* Ensure modal dialogs are properly positioned */
.modal-dialog {
    z-index: 1056 !important;
    position: relative;
}

/* Fix for any navbar elements that might have high z-index */
/* Excluding menu toggle button which needs its own z-index */
.layout-navbar *:not(.layout-menu-toggle):not(.layout-menu-toggle *),
#layout-navbar *:not(.layout-menu-toggle):not(.layout-menu-toggle *),
.navbar *:not(.layout-menu-toggle):not(.layout-menu-toggle *) {
    z-index: auto !important;
}

/* Card and content elements should be below navbar */
.card,
.card-body,
.page-content {
    position: relative;
    z-index: 1 !important;
}

/* CRITICAL: Ensure .content-wrapper NEVER gets z-index */
.content-wrapper {
    z-index: auto !important;
    position: static !important;
}

/* REMOVED .content-wrapper - See /docs/modals_investigation/ROOT_CAUSE_ANALYSIS.md
 *
 * Reason: .content-wrapper is just a container, not a visual element that needs
 * to be positioned below the navbar. Cards and page-content already have z-index: 1.
 *
 * Problem it caused: Created a z-index stacking context that trapped child modals,
 * preventing them from appearing above the modal backdrop (z-index: 1050).
 *
 * Solution: Remove z-index from .content-wrapper to let modals escape to global
 * stacking context where they can use their proper z-index: 1055.
 *
 * Safety: JavaScript fallback (force-modal-to-body.js) remains active as belt+suspenders.
 *
 * Date: 2025-11-07
 * Issue: Modal backdrop blocks entire screen
 * See: /docs/modals_investigation/
 */

/* Add padding to body to account for fixed navbar */
/* Commented out - this was causing extra gap above content
body {
    padding-top: 60px;
}
*/

/* Cache bust: 1750487366 */
/* Cache bust: 1750488394 - Fixed template customizer freeze */
/* Cache bust: 1750490326 - Disabled all theme scripts */
/* Cache bust: 1750594321 - Fixed navbar z-index for modals */
/* Cache bust: 1730838000 - Enhanced z-index hierarchy for alerts and content */
