/* ==========================================================================
   Base CSS - Main layout and common styles
   ========================================================================== */

/* ==========================================================================
   1. Layout Structure
   ========================================================================== */

/* Main wrapper */
#wrapper {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* Content wrapper */
#content-wrapper {
    background-color: #f8f9fc;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Main content area */
#content {
    flex: 1 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Page content wrapper */
.page-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100%;
}

/* Container spacing */
#content .container,
#content .container-fluid {
    padding-top: 1rem;
    padding-bottom: 2rem;
    flex: 1 0 auto;
}

/* ==========================================================================
   2. Topbar
   ========================================================================== */

.topbar {
    height: 4.375rem;
    z-index: 2;
    position: relative;
    background-color: #fff;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

/* Topbar brand */
.topbar .navbar-brand-wrapper img {
    transform: scale(0.8);
    transform-origin: left center;
}

/* Topbar toggle button */
.topbar #sidebarToggleTop {
    height: 3rem;
    width: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar #sidebarToggleTop .bi-list {
    font-size: 32px !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
}

.topbar #sidebarToggleTop:hover {
    background-color: #eaecf4;
}

.topbar #sidebarToggleTop:active {
    background-color: #dddfeb;
}

/* Topbar search */
.topbar .navbar-search {
    width: 25rem;
}

.topbar .navbar-search input {
    font-size: 0.85rem;
    height: auto;
}

/* Topbar divider */
.topbar .topbar-divider {
    width: 0;
    border-right: 1px solid #e3e6f0;
    height: calc(4.375rem - 2rem);
    margin: auto 1rem;
}

/* Topbar navigation */
.topbar .nav-item .nav-link {
    height: 4.375rem;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
}

.topbar .nav-item .nav-link:focus,
.topbar .nav-item:focus {
    outline: none;
}

/* Topbar dropdown */
.topbar .dropdown {
    position: static;
}

.topbar .dropdown .dropdown-menu {
    width: calc(100% - 1.5rem);
    right: 0.75rem;
}

/* Dropdown list styling */
.topbar .dropdown-list {
    padding: 0;
    border: none;
    overflow: hidden;
}

.topbar .dropdown-list .dropdown-header {
    background-color: #4e73df;
    border: 1px solid #4e73df;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #fff;
}

.topbar .dropdown-list .dropdown-item {
    white-space: normal;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-left: 1px solid #e3e6f0;
    border-right: 1px solid #e3e6f0;
    border-bottom: 1px solid #e3e6f0;
    line-height: 1.3rem;
}

.topbar .dropdown-list .dropdown-item:active {
    background-color: #eaecf4;
    color: #3a3b45;
}

/* User avatar */
.avatar-placeholder {
    font-weight: 600;
}

/* ==========================================================================
   3. Footer
   ========================================================================== */

.footer {
    padding: 2rem 0;
    flex-shrink: 0;
    margin-top: auto;
    background-color: #fff;
    border-top: 1px solid #e3e6f0;
    width: 100%;
}

.footer .copyright {
    line-height: 1;
    font-size: 0.8rem;
}

.footer .support-info {
    font-size: 0.8rem;
}

.footer .support-info a {
    color: #4e73df;
    transition: color 0.2s ease;
}

.footer .support-info a:hover {
    color: #2e59d9;
    text-decoration: underline !important;
}

/* ==========================================================================
   4. Components
   ========================================================================== */

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    text-align: center;
    color: #fff;
    background: rgba(90, 92, 105, 0.5);
    line-height: 2.75rem;
    border-radius: 0.35rem;
    z-index: 100;
    transition: background 0.3s ease;
}

.scroll-to-top:focus,
.scroll-to-top:hover {
    color: white;
    background: #5a5c69;
}

.scroll-to-top i {
    font-weight: 800;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
}

/* ==========================================================================
   5. Utilities
   ========================================================================== */

/* Background gradients */
.bg-gradient-primary {
    background-color: #4e73df;
    background-image: linear-gradient(180deg, #4e73df 10%, #224abe 100%);
    background-size: cover;
}

.bg-gradient-secondary {
    background-color: #858796;
    background-image: linear-gradient(180deg, #858796 10%, #60616f 100%);
    background-size: cover;
}

/* Text colors */
.text-gray-600 {
    color: #858796;
}

/* Animations */
@keyframes growIn {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animated--grow-in {
    animation-name: growIn;
    animation-duration: 200ms;
    animation-timing-function: transform cubic-bezier(.18,1.25,.4,1), opacity cubic-bezier(0,1,.4,1);
}

/* ==========================================================================
   0006_controlpoint_migrate_to_core_location.py. Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    /* Remove overflow constraints on mobile for sticky to work */
    #wrapper {
        overflow: visible !important;
    }

    #content-wrapper {
        overflow: visible !important;
        min-height: 100vh;
    }

    #content {
        overflow-y: visible !important;
        overflow-x: hidden !important;
        /* Create new stacking context */
        position: relative;
    }

    /* Ensure topbar is sticky */
    .topbar {
        position: sticky !important;
        position: -webkit-sticky !important;
        top: 0;
        z-index: 1020;
        background-color: #fff;
        /* Ensure it stays above content */
        box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
    }

    /* Adjust container to prevent content hiding under sticky topbar */
    #content .container,
    #content .container-fluid {
        /* No additional padding needed as topbar height is already accounted for */
        padding-top: 1rem;
    }

    /* Ensure page content scrolls properly */
    .page-content-wrapper {
        min-height: calc(100vh - 4.375rem); /* Subtract topbar height */
    }

    /* Topbar logo */
    .topbar .navbar-brand-wrapper img {
        transform: scale(0.8);
        transform-origin: left center;
    }

    /* Footer */
    .footer .row > div {
        margin-bottom: 0.5rem;
    }

    .footer .row > div:last-child {
        margin-bottom: 0;
    }
}

/* ==========================================================================
   Z-index fix for sidebar - Add this to your sidebar.css
   ========================================================================== */

/* Increase sidebar z-index to ensure it stays above map elements */
.sidebar {
    z-index: 2000 !important;
}

/* Ensure mobile overlay stays above sidebar */
.sidebar-overlay {
    z-index: 1999!important;
}
