/*
 * Responsive application shell and interaction layer.
 * Kept separate from site_theme.css so the production theme can evolve independently.
 */
:root {
    --st-ui-bg: #f4f6fa;
    --st-ui-surface: #ffffff;
    --st-ui-surface-muted: #f7f9fc;
    --st-ui-hover: #eef3fb;
    --st-ui-border: #d9dfeb;
    --st-ui-text: #202638;
    --st-ui-muted: #687289;
    --st-ui-accent: #6f54d9;
    --st-ui-accent-soft: rgba(111, 84, 217, .11);
    --st-ui-focus: rgba(56, 116, 255, .28);
    --st-ui-navbar-height: 70px;
    --st-ui-sidebar-width: 272px;
    --st-ui-shadow-sm: 0 4px 16px rgba(30, 42, 70, .08);
    --st-ui-shadow-md: 0 14px 38px rgba(30, 42, 70, .14);
}

html[data-bs-theme="dark"] {
    --st-ui-bg: #0b0f17;
    --st-ui-surface: #121823;
    --st-ui-surface-muted: #171f2c;
    --st-ui-hover: #202a39;
    --st-ui-border: #2c3748;
    --st-ui-text: #e8edf5;
    --st-ui-muted: #9ba7ba;
    --st-ui-accent: #b89aff;
    --st-ui-accent-soft: rgba(184, 154, 255, .13);
    --st-ui-focus: rgba(120, 165, 255, .3);
    --st-ui-shadow-sm: 0 5px 18px rgba(0, 0, 0, .22);
    --st-ui-shadow-md: 0 18px 48px rgba(0, 0, 0, .42);
}

html,
body {
    min-width: 320px;
}

body.site-shell {
    background: var(--st-ui-bg);
    color: var(--st-ui-text);
    min-height: 100vh;
    min-height: 100dvh;
}

.skip-link {
    background: var(--st-ui-surface);
    border: 1px solid var(--st-ui-border);
    border-radius: 0 0 10px 10px;
    box-shadow: var(--st-ui-shadow-md);
    color: var(--st-ui-text);
    font-weight: 700;
    left: 1rem;
    padding: .65rem 1rem;
    position: fixed;
    top: 0;
    transform: translateY(-130%);
    transition: transform .18s ease;
    z-index: 1100;
}

.skip-link:focus {
    color: var(--st-ui-text);
    transform: translateY(0);
}

.site-layout {
    min-height: calc(100vh - var(--st-ui-navbar-height));
    min-height: calc(100dvh - var(--st-ui-navbar-height));
    min-width: 0;
}

.site-main {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: clamp(1rem, 2vw, 2rem);
    padding-right: clamp(1rem, 2vw, 2rem);
    width: calc(100% - var(--st-ui-sidebar-width));
}

/* Top navigation */
.site-navbar.top {
    align-items: center;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--st-ui-border);
    color: var(--st-ui-text);
    min-height: var(--st-ui-navbar-height);
    padding: .65rem clamp(.8rem, 2vw, 1.5rem);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.site-navbar__inner,
.site-navbar__start,
.site-navbar__actions {
    align-items: center;
    display: flex;
}

.site-navbar__inner {
    gap: 1rem;
    justify-content: space-between;
    padding: 0;
}

.site-navbar__start,
.site-navbar__actions {
    gap: .65rem;
}

.site-brand {
    color: var(--st-ui-text) !important;
    font-size: 1.16rem !important;
    font-weight: 900 !important;
    letter-spacing: .035em;
    line-height: 1;
    margin: 0;
    padding: .45rem .2rem;
    white-space: nowrap;
}

.site-menu-toggle,
.top-action,
.top-user-button,
.sidebar__close {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--st-ui-muted);
    display: inline-flex;
    justify-content: center;
    margin: 0;
    min-height: 44px;
}

.site-menu-toggle,
.top-action,
.sidebar__close {
    border-radius: 12px;
    flex: 0 0 44px;
    height: 44px;
    padding: 0;
    width: 44px;
}

.site-menu-toggle {
    border-color: var(--st-ui-border);
}

.site-menu-toggle .material-icons-outlined,
.top-action .material-icons-outlined,
.sidebar__close .material-icons-outlined {
    font-size: 22px;
    line-height: 1;
}

.site-menu-toggle[aria-expanded="true"] {
    background: var(--st-ui-accent-soft);
    border-color: rgba(111, 84, 217, .3);
    color: var(--st-ui-accent);
}

.top-action {
    background: var(--st-ui-surface-muted);
    border-color: var(--st-ui-border);
}

.top-action__badge {
    align-items: center;
    border: 2px solid var(--st-ui-surface);
    display: flex;
    font-size: 9px !important;
    height: 19px;
    justify-content: center;
    min-width: 19px;
    padding: 2px 4px !important;
    position: absolute;
    right: 1px;
    top: 1px;
}

.top-user-button {
    background: var(--st-ui-surface-muted);
    border-color: var(--st-ui-border);
    border-radius: 14px;
    gap: .55rem;
    padding: .3rem .55rem .3rem .35rem;
    text-align: left;
}

.top-user {
    border: 2px solid var(--st-ui-surface);
    box-shadow: 0 0 0 1px var(--st-ui-border);
    height: 36px;
    margin: 0;
    object-fit: cover;
    width: 36px;
}

.top-user-copy {
    display: flex;
    flex-direction: column;
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.2;
    max-width: 132px;
}

.top-user-chevron {
    color: var(--st-ui-muted);
    font-size: 18px !important;
    transition: transform .2s ease;
}

.top-user-button[aria-expanded="true"] .top-user-chevron {
    transform: rotate(180deg);
}

.site-notifications,
.site-user-menu {
    background: var(--st-ui-surface);
    border: 1px solid var(--st-ui-border);
    border-radius: 14px;
    box-shadow: var(--st-ui-shadow-md);
    margin-top: .55rem !important;
    min-width: 240px;
    overflow: hidden;
    padding: .4rem;
}

.site-notifications .dropdown-header {
    color: var(--st-ui-muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .06em;
    padding: .55rem .7rem;
    text-transform: uppercase;
}

.site-notifications .dropdown-item,
.site-user-menu .dropdown-item {
    align-items: center;
    border-radius: 9px;
    color: var(--st-ui-text);
    display: flex;
    gap: .65rem;
    min-height: 42px;
    padding: .58rem .7rem;
}

.site-user-menu .material-icons-outlined {
    font-size: 19px;
}

.theme-toggle {
    --st-ui-toggle-travel: 28px;
}

.theme-toggle .theme-toggle__thumb {
    height: 24px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
}

.theme-toggle .theme-toggle__sun,
.theme-toggle .theme-toggle__moon {
    align-items: center;
    display: inline-flex;
    font-size: 15px !important;
    height: 24px;
    justify-content: center;
    line-height: 1 !important;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    z-index: 2;
}

.theme-toggle .theme-toggle__sun {
    left: 3px;
}

.theme-toggle .theme-toggle__moon {
    right: 3px;
}

html[data-bs-theme="dark"] .theme-toggle .theme-toggle__thumb {
    transform: translate(var(--st-ui-toggle-travel), -50%);
}

.site-navbar .theme-toggle {
    --st-ui-toggle-travel: 26px;
    background: var(--st-ui-surface-muted);
    border-color: var(--st-ui-border);
    flex-basis: 56px;
    height: 32px;
    width: 56px;
}

/* Sidebar */
.sidebar {
    --bs-offcanvas-width: var(--st-ui-sidebar-width);
    background: var(--st-ui-surface);
    border-color: var(--st-ui-border);
    flex: 0 0 var(--st-ui-sidebar-width);
    height: calc(100vh - var(--st-ui-navbar-height));
    height: calc(100dvh - var(--st-ui-navbar-height));
    min-height: 0 !important;
    padding: 0;
    position: sticky;
    top: var(--st-ui-navbar-height);
    width: var(--st-ui-sidebar-width);
}

.sidebar__mobile-header {
    border-bottom: 1px solid var(--st-ui-border);
    display: none;
    min-height: 66px;
    padding: .7rem 1rem;
}

.sidebar__mobile-brand {
    color: var(--st-ui-text);
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: .035em;
    text-decoration: none;
}

.sidebar__close {
    border-color: var(--st-ui-border);
}

.sidebar__body {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem .75rem;
}

.sidebar__nav {
    display: grid;
    gap: .5rem;
}

.sidebar__nav > * {
    margin: 0 !important;
}

.sidebar__root,
.sidebar__quick-links ul,
.sidebar__footer ul {
    list-style: none;
    margin: 0;
    padding: 0 !important;
}

.sidebar__quick-links ul,
.sidebar__footer ul {
    display: grid;
    gap: .5rem;
}

.sidebar__root li,
.sidebar__quick-links li,
.sidebar__footer li,
.sidebar .accordion-body li {
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar__root a,
.sidebar__quick-links a,
.sidebar__footer a,
.sidebar .accordion-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 12px !important;
    color: var(--st-ui-muted);
    display: flex;
    font-size: .92rem;
    font-weight: 650;
    gap: .7rem;
    line-height: 1.25;
    min-height: 44px;
    padding: .68rem .75rem !important;
    width: 100%;
}

.sidebar__root a span,
.sidebar__quick-links a span,
.sidebar__footer a span,
.sidebar .accordion-button span {
    margin: 0;
}

.sidebar__root a .material-icons-outlined,
.sidebar__quick-links a .material-icons-outlined,
.sidebar__footer a .material-icons-outlined,
.sidebar .accordion-button .material-icons-outlined {
    color: #818da3;
    flex: 0 0 20px;
    font-size: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    width: 20px;
}

.sidebar__quick-links .sidebar__external {
    color: var(--st-ui-muted);
    font-size: 16px;
    margin-left: auto;
    opacity: .7;
}

.sidebar .accordion,
.sidebar .accordion-item,
.sidebar .accordion-button,
.sidebar .accordion-button:not(.collapsed),
.sidebar .accordion-body {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.sidebar .accordion-button::after {
    background-size: 12px;
    height: 12px !important;
    margin-left: auto;
    width: 12px !important;
}

.sidebar .accordion-body {
    padding: .3rem 0 0 .7rem;
}

.sidebar .accordion-body ul {
    display: grid;
    gap: .5rem;
    margin: 0;
    padding: 0;
}

.sidebar .accordion-body a {
    border-radius: 10px;
    color: var(--st-ui-muted);
    font-size: .86rem;
    min-height: 38px;
    padding: .52rem .65rem;
    width: 100%;
}

.sidebar a.active,
.sidebar a[aria-current="page"],
.sidebar .accordion-button:not(.collapsed) {
    background: var(--st-ui-accent-soft);
    color: var(--st-ui-accent);
}

.sidebar a.active,
.sidebar a[aria-current="page"] {
    position: relative;
}

.sidebar a.active::before,
.sidebar a[aria-current="page"]::before {
    background: var(--st-ui-accent);
    border-radius: 999px;
    content: "";
    height: 20px;
    left: 1px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
}

.sidebar__footer {
    border-top: 1px solid var(--st-ui-border);
    margin-top: auto;
    padding-top: .75rem;
}

.sidebar__footer a {
    font-size: .8rem;
    font-weight: 600;
}

/* Press, hover, ripple and keyboard feedback */
:where(.btn, button, .sidebar a, .dropdown-item, .nav-link, .sort-label) {
    -webkit-tap-highlight-color: transparent;
    isolation: isolate;
    overflow: hidden;
    position: relative;
    transition: transform .16s cubic-bezier(.22, 1, .36, 1), box-shadow .2s ease,
        background-color .2s ease, border-color .2s ease, color .2s ease, filter .2s ease;
}

.btn:not(:disabled):active,
button:not(:disabled):active,
.sidebar a:active,
.dropdown-item:active,
.nav-link:active,
.sort-label:active,
.is-pressing {
    box-shadow: none !important;
    filter: brightness(.96);
    transform: translateY(1px) scale(.975) !important;
}

.interaction-ripple {
    animation: st-interaction-ripple .56s cubic-bezier(.2, .75, .25, 1) forwards;
    background: currentColor;
    border-radius: 50%;
    opacity: .14;
    pointer-events: none;
    position: absolute;
    transform: scale(0);
    z-index: 0;
}

@keyframes st-interaction-ripple {
    70% { opacity: .09; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.08); }
}

.btn:focus-visible,
button:focus-visible,
.sidebar a:focus-visible,
.dropdown-item:focus-visible,
.nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    box-shadow: 0 0 0 3px var(--st-ui-focus) !important;
    outline: none !important;
}

@media (hover: hover) {
    .top-action:hover,
    .site-menu-toggle:hover,
    .top-user-button:hover,
    .theme-toggle:hover,
    .sidebar__close:hover {
        background: var(--st-ui-hover);
        border-color: #aeb8ca;
        color: var(--st-ui-text);
        transform: translateY(-1px);
    }

    .sidebar__root a:hover,
    .sidebar__quick-links a:hover,
    .sidebar__footer a:hover,
    .sidebar .accordion-button:hover,
    .sidebar .accordion-body a:hover {
        background: var(--st-ui-hover);
        color: var(--st-ui-text);
        transform: translateX(2px);
    }

    .btn:not(:disabled):hover {
        box-shadow: var(--st-ui-shadow-sm);
        transform: translateY(-1px);
    }
}

/* Dark navigation surfaces */
html[data-bs-theme="dark"] .site-navbar.top,
html[data-bs-theme="dark"] .sidebar {
    background: rgba(16, 22, 32, .96);
    border-color: var(--st-ui-border);
    color: var(--st-ui-text);
}

html[data-bs-theme="dark"] .site-navbar.top a,
html[data-bs-theme="dark"] .site-navbar.top .navbar-brand,
html[data-bs-theme="dark"] .sidebar__mobile-brand {
    color: var(--st-ui-text);
}

html[data-bs-theme="dark"] .sidebar .accordion-button::after {
    filter: brightness(0) invert(1);
    opacity: .68;
}

html[data-bs-theme="dark"] .site-notifications,
html[data-bs-theme="dark"] .site-user-menu {
    background: var(--st-ui-surface);
    border-color: var(--st-ui-border);
}

/* Narrow screens */
@media (max-width: 991.98px) {
    :root { --st-ui-navbar-height: 64px; }

    .site-navbar.top {
        min-height: var(--st-ui-navbar-height);
        padding: .55rem .75rem;
    }

    .site-layout { display: block !important; }

    .site-main {
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100%;
    }

    .sidebar {
        background: var(--st-ui-surface);
        box-shadow: 14px 0 40px rgba(25, 33, 51, .22);
        height: 100vh;
        height: 100dvh;
        max-width: 88vw;
        position: fixed;
        top: 0;
        width: min(88vw, 320px);
        z-index: 1045;
    }

    html[data-bs-theme="dark"] .sidebar {
        box-shadow: 14px 0 42px rgba(0, 0, 0, .5);
    }

    .sidebar__mobile-header { display: flex; }

    .sidebar__body {
        height: calc(100vh - 66px);
        height: calc(100dvh - 66px);
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--st-ui-border);
        border-radius: 12px;
        overflow-x: auto !important;
        overscroll-behavior-inline: contain;
    }

    .table-responsive > .table {
        margin-bottom: 0;
        min-width: 720px;
    }

    .regulation > .d-flex { flex-direction: column; }

    .regulation .art_menu {
        background: var(--st-ui-surface);
        border: 1px solid var(--st-ui-border);
        border-radius: 14px;
        margin: 0 0 1rem;
        max-height: 42vh;
        max-height: 42dvh;
        overflow: auto;
        padding: .75rem;
        width: 100%;
    }

    .regulation .art_content {
        min-width: 0;
        width: 100%;
    }

    .regulation .article-text { overflow-wrap: anywhere; }

    .regulation .article-text img,
    .regulation .article-text iframe,
    .regulation .article-text video {
        height: auto;
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    .site-navbar__inner,
    .site-navbar__start,
    .site-navbar__actions { gap: .42rem; }

    .top-user-copy,
    .top-user-chevron { display: none; }

    .top-user-button {
        border-radius: 12px;
        height: 44px;
        padding: .25rem;
        width: 44px;
    }

    .site-notifications {
        left: .75rem !important;
        margin: 0 !important;
        max-height: calc(100vh - 82px);
        max-height: calc(100dvh - 82px);
        overflow-y: auto;
        position: fixed !important;
        right: .75rem !important;
        top: 70px !important;
        transform: none !important;
        width: auto;
    }

    .modal-dialog { margin: .65rem; }

    .modal-content {
        border-radius: 16px;
        max-height: calc(100vh - 1.3rem);
        max-height: calc(100dvh - 1.3rem);
        overflow-y: auto;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: .55rem;
    }

    .modal-footer .btn { flex: 1 1 140px; }
}

@media (max-width: 575.98px) {
    .site-navbar.top {
        padding-left: max(.55rem, env(safe-area-inset-left));
        padding-right: max(.55rem, env(safe-area-inset-right));
    }

    .site-brand {
        font-size: .88rem !important;
        letter-spacing: .01em;
    }

    .site-navbar .theme-toggle {
        --st-ui-toggle-travel: 20px;
        flex-basis: 50px;
        margin-right: 0 !important;
        width: 50px;
    }

    .site-main {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .site-main h1 { font-size: clamp(1.35rem, 7vw, 1.7rem); }
    .site-main h2 { font-size: clamp(1.15rem, 6vw, 1.45rem); }

    .site-main .btn {
        min-height: 44px;
        max-width: 100%;
        padding: .65rem 1rem;
        white-space: normal;
    }

    .site-main .btn-group {
        max-width: 100%;
        overflow-x: auto;
    }

    .site-main .btn-group .btn { white-space: nowrap; }

    body.bg-fill .container { padding: .75rem; }
    body.bg-fill .card-body { padding: 1.25rem; }

    body.bg-fill .text-logo {
        font-size: clamp(2rem, 11vw, 2.7rem);
        margin-bottom: 2rem !important;
    }

    body.bg-fill .btn { min-height: 44px; }
    .theme-toggle--floating { right: 12px; top: 12px; }
}

@media (max-width: 380px) {
    .site-navbar__inner,
    .site-navbar__start,
    .site-navbar__actions { gap: .22rem; }

    .site-brand { font-size: .8rem !important; }

    .site-menu-toggle,
    .top-action,
    .top-user-button {
        flex-basis: 40px;
        height: 40px;
        min-height: 40px;
        width: 40px;
    }

    .site-navbar .theme-toggle {
        --st-ui-toggle-travel: 16px;
        flex-basis: 46px;
        width: 46px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }

    .interaction-ripple { display: none !important; }
}
