/* =====================================================================
   SACCO app shell: rail, flyouts, top bar, dock, and calmer Filament pages
   (file: public/css/sacco-app.css)
   ===================================================================== */

:root {
    --sx-rail-w: 104px;
    --sx-top-h: 76px;
    --sx-page: #F4F6FB;
    --sx-surface: #FFFFFF;
    --sx-border: #E6EBF5;
    --sx-navy-1: #0F1B3D;
    --sx-navy-2: #172554;
}

/* ---------- remove Filament's own chrome when our shell is present ---------- */
body:has(.sx-shell) {
    background: var(--sx-page) !important;
}

body:has(.sx-shell) .fi-sidebar,
body:has(.sx-shell) .fi-sidebar-close-overlay,
body:has(.sx-shell) .fi-topbar-ctn,
body:has(.sx-shell) .fi-topbar {
    display: none !important;
}

body:has(.sx-shell) .fi-layout {
    padding-left: var(--sx-rail-w);
    padding-top: var(--sx-top-h);
    background: transparent;
}

body:has(.sx-shell) .fi-main-ctn,
body:has(.sx-shell) .fi-main {
    background: transparent !important;
}

body:has(.sx-shell) .fi-main {
    padding-top: 12px;
    padding-right: 84px; /* room for the dock */
}

/* ---------- rail ---------- */
.sx-rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sx-rail-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 0;
    background: linear-gradient(180deg, var(--sx-navy-1), var(--sx-navy-2));
    box-shadow: 4px 0 24px rgba(15, 27, 61, .18);
}

.sx-rail-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    margin-bottom: 16px;
}

.sx-rail-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--sx-royal), var(--sx-indigo));
    box-shadow: 0 8px 18px rgba(37, 99, 235, .35);
    font-family: var(--sx-display);
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.sx-rail-word {
    font-family: var(--sx-display);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .75);
}

.sx-rail-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.sx-rail-btn {
    position: relative;
    width: 84px;
    padding: 11px 0 9px;
    border: 0;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: rgba(255, 255, 255, .6);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.sx-rail-btn:hover,
.sx-rail-btn.is-open {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sx-rail-btn.is-active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}

/* glowing pill on the active item */
.sx-rail-btn.is-active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: #60A5FA;
    box-shadow: 0 0 12px #60A5FA;
}

.sx-rail-ico {
    width: 23px;
    height: 23px;
}

.sx-rail-label {
    line-height: 1;
}

/* ---------- flyout beside the clicked rail button ---------- */
.sx-flyout {
    position: fixed;
    z-index: 41;
    left: calc(var(--sx-rail-w) + 12px);
    width: 250px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(10px);
    border: 1px solid var(--sx-border);
    box-shadow: 0 24px 60px rgba(23, 37, 84, .2);
}

/* small pointer towards the rail */
.sx-flyout::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 22px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid var(--sx-border);
    border-bottom: 1px solid var(--sx-border);
    transform: rotate(45deg);
}

.sx-flyout-title {
    margin: 2px 8px 10px;
    font-family: var(--sx-display);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--sx-muted);
}

.sx-flyout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--sx-ink);
    transition: background .12s;
}

.sx-flyout-link:hover {
    background: #F1F5FD;
}

.sx-flyout-link.is-active {
    background: #E8EFFF;
    color: var(--sx-cobalt);
}

.sx-flyout-ico {
    width: 20px;
    height: 20px;
    color: var(--sx-royal);
}

/* ---------- top bar ---------- */
.sx-top {
    position: fixed;
    z-index: 30;
    top: 0;
    left: var(--sx-rail-w);
    right: 0;
    height: var(--sx-top-h);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--sx-border);
    box-shadow: 0 4px 18px rgba(23, 37, 84, .05);
}

.sx-top-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sx-greet {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.sx-greet strong {
    font-size: 15px;
    color: var(--sx-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sx-greet span {
    font-size: 12.5px;
    color: var(--sx-muted);
}

.sx-top-center {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--sx-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--sx-navy-2);
}

.sx-top-center i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sx-royal);
    box-shadow: 0 0 0 4px #DBE7FF;
}

.sx-top-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.sx-icon-btn,
.sx-menu-btn {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    border: 1px solid var(--sx-border);
    background: #fff;
    display: grid;
    place-items: center;
    color: var(--sx-muted);
    cursor: pointer;
}

.sx-icon-btn:disabled {
    cursor: default;
    opacity: .6;
}

.sx-menu-btn {
    display: none;
}

.sx-btn-ico {
    width: 20px;
    height: 20px;
}

/* user menu */
.sx-user {
    position: relative;
}

.sx-user-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 14px 5px 5px;
    border-radius: 999px;
    border: 1px solid var(--sx-border);
    background: #fff;
    cursor: pointer;
}

.sx-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--sx-royal), var(--sx-indigo));
}

.sx-user-meta {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.25;
}

.sx-user-meta strong {
    font-size: 13.5px;
    color: var(--sx-ink);
}

.sx-user-meta small {
    font-size: 11.5px;
    color: var(--sx-muted);
}

.sx-chev {
    width: 16px;
    height: 16px;
    color: var(--sx-muted);
}

.sx-user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 250px;
    padding: 8px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--sx-border);
    box-shadow: 0 20px 50px rgba(23, 37, 84, .16);
}

.sx-user-menu a,
.sx-user-menu button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--sx-ink);
    cursor: pointer;
    text-align: left;
}

.sx-user-menu a:hover,
.sx-user-menu button:hover {
    background: #F1F5FD;
}

.sx-menu-ico {
    width: 18px;
    height: 18px;
    color: var(--sx-muted);
}

/* ---------- right dock ---------- */
.sx-dock {
    position: fixed;
    z-index: 30;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--sx-border);
    box-shadow: 0 16px 40px rgba(23, 37, 84, .14);
}

.sx-dock-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--sx-action), var(--sx-action-hi));
}

.sx-dock-btn.is-soon {
    opacity: .5;
}

.sx-dock-btn::after {
    content: attr(data-label);
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    background: var(--sx-ink);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
}

.sx-dock-btn:hover::after {
    opacity: 1;
}

/* ---------- mobile drawer ---------- */
.sx-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(15, 23, 42, .45);
}

.sx-drawer {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    overflow-y: auto;
    padding: 16px;
    background: #fff;
    box-shadow: 20px 0 50px rgba(15, 23, 42, .25);
}

.sx-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sx-drawer-brand {
    font-family: var(--sx-display);
    font-weight: 700;
    letter-spacing: .16em;
    color: var(--sx-navy-2);
}

/* =====================================================================
   Calmer Filament pages (cards, tables, buttons)
   ===================================================================== */

body:has(.sx-shell) .fi-header-heading {
    font-family: var(--sx-display);
    letter-spacing: -.02em;
    color: var(--sx-ink);
}

body:has(.sx-shell) .fi-breadcrumbs {
    font-size: 13px;
}

body:has(.sx-shell) .fi-section {
    border-radius: 22px !important;
    border: 1px solid var(--sx-border);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, .04),
        0 14px 36px rgba(23, 37, 84, .08) !important;
}

body:has(.sx-shell) .fi-section-header-heading {
    font-family: var(--sx-display);
    font-size: 15px;
    letter-spacing: -.01em;
}

body:has(.sx-shell) .fi-ta-ctn {
    border-radius: 20px !important;
    border: 1px solid var(--sx-border);
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, .04),
        0 14px 36px rgba(23, 37, 84, .08) !important;
}

body:has(.sx-shell) .fi-ta-header-cell {
    background: #F8FAFD;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--sx-muted) !important;
}

body:has(.sx-shell) .fi-ta-row:hover {
    background: #F7F9FE;
}

body:has(.sx-shell) .fi-btn {
    border-radius: 12px !important;
    font-weight: 700;
}

body:has(.sx-shell) .fi-badge {
    border-radius: 999px !important;
}

/* ---------- small screens: rail becomes a drawer ---------- */
@media (max-width: 1023px) {
    .sx-rail,
    .sx-flyout {
        display: none !important;
    }

    body:has(.sx-shell) .fi-layout {
        padding-left: 0;
        padding-top: 64px;
    }

    .sx-top {
        left: 0;
        height: 64px;
        padding: 0 14px;
        grid-template-columns: auto 1fr auto;
    }

    .sx-menu-btn {
        display: grid;
    }

    .sx-greet {
        display: none;
    }

    .sx-top-center {
        justify-content: center;
        font-size: 15px;
    }

    .sx-user-meta,
    .sx-chev,
    .sx-top-right .sx-icon-btn {
        display: none;
    }

    .sx-user-btn {
        padding: 3px;
    }

    .sx-dock {
        display: none;
    }

    body:has(.sx-shell) .fi-main {
        padding-right: 0;
    }
}