/**
 * System-wide scrollbar — the single source of truth for every scroll area
 * in the application: page, sidebar, tables, modals, dropdowns, chat.
 *
 * Linked from:
 *   resources/views/layouts/app.blade.php           (dashboard)
 *   resources/views/layouts/setup.blade.php         (setup wizard)
 *   resources/views/layout/header.blade.php         (chat / support)
 *   resources/views/layouts/booking-site.blade.php  (public booking site)
 *
 * Both scrollbar APIs are shipped, because no browser supports both:
 *   - ::-webkit-scrollbar        -> Chrome, Edge, Opera, Safari
 *   - scrollbar-width/-color     -> Firefox
 *
 * Rules are deliberately written on `*`. Its specificity is (0,0,0), so any
 * component that already styles its own scrollbar (Chatify's .app-scroll,
 * Select2, FullCalendar) still wins and keeps its tuned appearance. The
 * sidebar is restyled through custom properties rather than extra selectors,
 * so its pseudo-elements pick the light thumb up by inheritance.
 */

:root {
    --sb-width: 12px; /* reserved gutter; the visible thumb is 8px (see --sb-inset) */
    --sb-inset: 2px; /* transparent border that turns the thumb into a pill */
    --sb-thumb: rgba(15, 23, 42, .26);
    --sb-thumb-hover: rgba(15, 23, 42, .46);
    --sb-track: transparent;
    --sb-radius: 999px;
}

/* ---------------------------------------------------------------
 * Firefox
 * --------------------------------------------------------------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--sb-thumb) var(--sb-track);
}

/* ---------------------------------------------------------------
 * Chrome / Edge / Opera / Safari
 * --------------------------------------------------------------- */
*::-webkit-scrollbar {
    width: var(--sb-width);
    height: var(--sb-width);
    background: var(--sb-track);
}

*::-webkit-scrollbar-track {
    background: var(--sb-track);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--sb-thumb);
    border-radius: var(--sb-radius);
    border: var(--sb-inset) solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--sb-thumb-hover);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

/* Touch devices: reclaim layout space, the thumb stays usable. */
@media (hover: none) {
    :root {
        --sb-width: 8px;
    }
}

/* ---------------------------------------------------------------
 * Dark sidebar
 *
 * --sidebar-text is defined by the theme customiser and is guaranteed to
 * contrast with --sidebar-bg, so deriving the thumb from it means a
 * recoloured sidebar automatically gets a readable scrollbar.
 * --------------------------------------------------------------- */
#sidebar {
    --sb-thumb: rgba(255, 255, 255, .30);
    --sb-thumb-hover: rgba(255, 255, 255, .55);
    --sb-track: rgba(255, 255, 255, .06);
}

@supports (background-color: color-mix(in srgb, red 50%, blue)) {
    #sidebar {
        --sb-thumb: color-mix(in srgb, var(--sidebar-text, #ffffff) 34%, transparent);
        --sb-thumb-hover: color-mix(in srgb, var(--sidebar-text, #ffffff) 58%, transparent);
        --sb-track: color-mix(in srgb, var(--sidebar-text, #ffffff) 10%, transparent);
    }
}

/* ---------------------------------------------------------------
 * RTL: the browser mirrors the scrollbar side for us, so nothing here
 * is direction-specific. Verified against dir="rtl" (Arabic) pages.
 * --------------------------------------------------------------- */
