/**
 * Modern SaaS Scrolling & Ambient Progress Indicator Styles
 * Premium Custom Scrollbars for Light and Dark Modes
 */

/* =========================================================================
   1. Global Root & HTML Smooth Scrolling
   ========================================================================= */
:root,
html {
    scroll-behavior: smooth !important;
    scrollbar-width: thin;
    scrollbar-color: #d92d3a #f1f5f9;
}

html.dark,
body.dark {
    scrollbar-color: #d92d3a #090e24;
}

/* =========================================================================
   2. WebKit Custom Scrollbar (Chrome, Edge, Safari, Brave, Opera)
   ========================================================================= */
/* Main Window & Container Scrollbar Dimensions */
::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 10px !important;
    height: 10px !important;
}

/* Scrollbar Track */
::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
    border-left: 1px solid rgba(226, 232, 240, 0.9) !important;
}

html.dark ::-webkit-scrollbar-track,
html.dark *::-webkit-scrollbar-track {
    background: #090e24 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Scrollbar Thumb */
::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d92d3a 0%, #b91c28 50%, #991b1b 100%) !important;
    border-radius: 9999px !important;
    border: 2px solid #f1f5f9 !important;
    background-clip: padding-box !important;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease !important;
}

html.dark ::-webkit-scrollbar-thumb,
html.dark *::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d92d3a 0%, #b91c28 50%, #7f1d1d 100%) !important;
    border: 2px solid #090e24 !important;
    background-clip: padding-box !important;
    box-shadow: 0 0 10px rgba(217, 45, 58, 0.35) !important;
}

/* Scrollbar Thumb Hover */
::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 50%, #b91c28 100%) !important;
    border: 1.5px solid #ffffff !important;
    background-clip: padding-box !important;
    box-shadow: 0 0 14px rgba(217, 45, 58, 0.65) !important;
}

html.dark ::-webkit-scrollbar-thumb:hover,
html.dark *::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 50%, #dc2626 100%) !important;
    border: 1.5px solid #1e293b !important;
    background-clip: padding-box !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.8) !important;
}

/* Scrollbar Corner */
::-webkit-scrollbar-corner,
*::-webkit-scrollbar-corner {
    background: #f1f5f9 !important;
}

html.dark ::-webkit-scrollbar-corner,
html.dark *::-webkit-scrollbar-corner {
    background: #090e24 !important;
}

/* =========================================================================
   3. Inner Containers (Sidebars, Modals, Tables, Dropdowns)
   ========================================================================= */
.tour-sidebar::-webkit-scrollbar,
.tour-modules-bar::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar,
.overflow-x-auto::-webkit-scrollbar,
aside::-webkit-scrollbar,
nav::-webkit-scrollbar,
pre::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

.tour-sidebar::-webkit-scrollbar-track,
.tour-modules-bar::-webkit-scrollbar-track,
.overflow-y-auto::-webkit-scrollbar-track,
.overflow-x-auto::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15) !important;
    border: none !important;
}

.tour-sidebar::-webkit-scrollbar-thumb,
.tour-modules-bar::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb,
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: rgba(217, 45, 58, 0.65) !important;
    border-radius: 9999px !important;
    border: 1px solid transparent !important;
}

.tour-sidebar::-webkit-scrollbar-thumb:hover,
.tour-modules-bar::-webkit-scrollbar-thumb:hover,
.overflow-y-auto::-webkit-scrollbar-thumb:hover,
.overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #d92d3a !important;
}

/* =========================================================================
   4. Top Ambient Reading & Scroll Progress Bar
   ========================================================================= */
#scroll-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3.5px;
    z-index: 9999999;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.05);
}

#scroll-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d92d3a 0%, #f97316 45%, #2563eb 85%, #60a5fa 100%);
    box-shadow: 0 0 12px rgba(217, 45, 58, 0.8), 0 0 6px rgba(37, 99, 235, 0.6);
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    transition: width 0.06s ease-out;
}

/* =========================================================================
   5. Modern Circular Scroll-To-Top Dynamic Ring Button
   ========================================================================= */
.modern-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(11, 21, 51, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 20px rgba(217, 45, 58, 0.3);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.85);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.modern-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.modern-back-to-top:hover {
    background: #0f172a;
    border-color: #d92d3a;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 14px 30px -5px rgba(0, 0, 0, 0.7), 0 0 25px rgba(217, 45, 58, 0.6);
}

.modern-back-to-top .progress-ring {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.modern-back-to-top .progress-ring-track {
    stroke: rgba(255, 255, 255, 0.12);
}

.modern-back-to-top .progress-ring-fill {
    stroke: #d92d3a;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.08s linear;
}

.modern-back-to-top-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
}

.modern-back-to-top:hover .modern-back-to-top-icon {
    transform: translateY(-2px);
    color: #f87171;
}

/* Avoid overlapping on mobile screens where quick help widget sits */
@media (max-width: 640px) {
    .modern-back-to-top {
        bottom: 84px;
        right: 18px;
        width: 42px;
        height: 42px;
    }
}
