/* ========================================
   UNIFIED FLOATING ELEMENTS
   St. Lawrence Junior School - Kabowa
   
   Clean, conflict-free floating elements
   with proper z-index hierarchy
   ======================================== */

/* ========== Z-INDEX HIERARCHY ========== */
:root {
    --z-sweetalert: 999999;      /* SweetAlert modals - highest priority */
    --z-hamburger: 10000;        /* Mobile hamburger menu */
    --z-back-to-top: 10001;      /* Back to top button - above chatbot */
    --z-chatbot: 9999;           /* AI chatbot button */
    --z-page-loader: 9997;       /* Page loading screen */
    --z-dropdown: 1000;          /* Navigation dropdowns */
}

/* ========== BACK-TO-TOP BUTTON ========== */
.back-to-top,
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-back-to-top);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.back-to-top.show,
#backToTop.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover,
#backToTop:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4);
}

/* ========== CHATBOT BUTTON ========== */
.chat-button,
#chatButton {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0, 102, 204, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-chatbot);
    transition: all 0.3s ease;
    border: 3px solid #fff;
    opacity: 1;
    visibility: visible;
}

.chat-button:hover,
#chatButton:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(0, 102, 204, 0.5);
}

/* ========== HAMBURGER MENU ========== */
.hamburger,
#hamburger {
    z-index: var(--z-hamburger) !important;
}

.nav-menu,
#navMenu {
    z-index: calc(var(--z-hamburger) - 1) !important;
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
    /* Chatbot: bottom-right, higher up */
    .chat-button,
    #chatButton {
        width: 52px;
        height: 52px;
        bottom: 85px;
        right: 20px;
        left: auto;
    }

    /* Back-to-top: bottom-right, below chatbot */
    .back-to-top,
    #backToTop {
        width: 44px;
        height: 44px;
        bottom: 25px;
        right: 24px;
        left: auto;
        font-size: 18px;
    }
}

/* ========== SAFE AREA SUPPORT ========== */
@supports (bottom: env(safe-area-inset-bottom)) {
    .back-to-top,
    #backToTop {
        bottom: max(30px, calc(24px + env(safe-area-inset-bottom, 0px)));
        right: max(30px, calc(24px + env(safe-area-inset-right, 0px)));
    }
    
    .chat-button,
    #chatButton {
        bottom: max(100px, calc(80px + env(safe-area-inset-bottom, 0px)));
        right: max(30px, calc(24px + env(safe-area-inset-right, 0px)));
    }
    
    @media (max-width: 768px) {
        /* Chatbot: right side, higher */
        .chat-button,
        #chatButton {
            bottom: max(85px, calc(70px + env(safe-area-inset-bottom, 0px)));
            right: max(20px, calc(16px + env(safe-area-inset-right, 0px)));
            left: auto;
        }

        /* Back-to-top: right side, below chatbot */
        .back-to-top,
        #backToTop {
            bottom: max(25px, calc(16px + env(safe-area-inset-bottom, 0px)));
            right: max(24px, calc(16px + env(safe-area-inset-right, 0px)));
            left: auto;
        }
    }
}