/* ==========================================================================
   CAMDEMICS SMOOTH SCROLLING & APPLE GLASS SCROLLBAR DESIGN SYSTEM
   ========================================================================== */

/* 1. Universal Smooth Scroll Behavior & Anchor Offsets */
html {
    scroll-behavior: smooth !important;
    scroll-padding-top: 85px; /* Offset for fixed navigation header */
}

/* Enable momentum scrolling on iOS devices */
body,
.main-panel,
.content-wrapper,
.container-scroller,
.sidebar,
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* 2. Apple Glass Minimalist Scrollbar (Light & Dark Mode) */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background-color 0.25s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.7);
    background-clip: content-box;
}

/* Dark Mode Frosted Glass Scrollbars */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.42);
    background-clip: content-box;
}

/* Firefox Scrollbar Styling */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

[data-theme="dark"] * {
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

/* 3. Apple-Style Floating "Back to Top" Glass Button */
.back-to-top-btn {
    position: fixed !important;
    bottom: 84px !important;
    right: 24px !important;
    z-index: 1028 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 2px solid rgba(0, 115, 59, 0.25) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
    color: var(--primary-color, #00733B) !important;
    cursor: pointer !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.9);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, border-color 0.2s ease !important;
    pointer-events: none;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

.back-to-top-btn.btn-visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

.back-to-top-btn:hover {
    background: #f8fafc !important;
    color: var(--primary-color, #00733B) !important;
    transform: translateY(-2px) scale(1.08) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), 0 0 16px rgba(var(--primary-color-rgb, 0, 115, 59), 0.25) !important;
    border-color: var(--primary-color, #00733B) !important;
}

.back-to-top-btn:active {
    transform: translateY(0) scale(0.96) !important;
}

.back-to-top-btn svg {
    width: 22px !important;
    height: 22px !important;
    stroke-width: 2.5;
    transition: transform 0.25s ease;
}

.back-to-top-btn:hover svg {
    transform: translateY(-2px);
}

/* Dark Theme Variant */
[data-theme="dark"] .back-to-top-btn {
    background: rgba(18, 26, 43, 0.95) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 2px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.65), 0 0 12px rgba(134, 239, 172, 0.2) !important;
    color: #86efac !important;
}

[data-theme="dark"] .back-to-top-btn:hover {
    background: rgba(26, 38, 62, 0.98) !important;
    color: #bbf7d0 !important;
    border-color: #86efac !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.75), 0 0 20px rgba(134, 239, 172, 0.35) !important;
}

/* Coordinated Stacking with WhatsApp Widget */
body.has-wa-widget .back-to-top-btn,
body:has(#camdemics-whatsapp-widget.bottom-right) .back-to-top-btn,
#camdemics-whatsapp-widget.bottom-right ~ .back-to-top-btn {
    bottom: 152px !important;
    right: 28px !important;
}

@media (max-width: 768px) {
    .back-to-top-btn {
        bottom: 68px !important;
        right: 16px !important;
        width: 42px !important;
        height: 42px !important;
    }
    body.has-wa-widget .back-to-top-btn,
    body:has(#camdemics-whatsapp-widget.bottom-right) .back-to-top-btn,
    #camdemics-whatsapp-widget.bottom-right ~ .back-to-top-btn {
        bottom: 132px !important;
        right: 20px !important;
        width: 42px !important;
        height: 42px !important;
    }
}

/* Print Cleanliness */
@media print {
    .back-to-top-btn {
        display: none !important;
    }
}
