/* ==========================================================================
   Application sidebar — executive menubar shell
   Loaded after petrolerp.css so it can restyle Filament's sidebar without
   touching navigation logic, permissions, collapse state or mobile drawer.
   ========================================================================== */

:root {
    --pe-sb-expanded: 17.25rem;
    --pe-sb-collapsed: 4.875rem;
    --sidebar-width: 17.25rem;
    --sidebar-collapsed-width: 4.875rem;
    --pe-sb-border: #e5e1d6;
    --pe-sb-border-strong: #d5cfc0;
    --pe-sb-emerald: #1e4d36;
    --pe-sb-emerald-soft: rgba(30, 77, 54, .11);
    --pe-sb-emerald-hover: rgba(30, 77, 54, .055);
    --pe-sb-amber: #f4a226;
    --pe-sb-text: #1e2923;
    --pe-sb-text-soft: #5b665f;
    --pe-sb-group: #87908a;
    --pe-sb-ease: cubic-bezier(.22, 1, .36, 1);
    --pe-sb-spring: cubic-bezier(.34, 1.35, .64, 1);
}

/* ---------- shell -------------------------------------------------------- */

.fi-sidebar {
    background:
        radial-gradient(105% 40% at 100% 0%, rgba(46, 112, 81, .14) 0%, transparent 62%),
        radial-gradient(80% 32% at 0% 100%, rgba(244, 162, 38, .07) 0%, transparent 65%),
        linear-gradient(180deg, #f9f7f1 0%, #f7f5ee 58%, #f3f0e6 100%) !important;
    border-right: 1px solid var(--pe-sb-border) !important;
    box-shadow:
        4px 0 24px -12px rgba(30, 41, 35, .08),
        inset -1px 0 0 rgba(255, 255, 255, .75) !important;
    color: var(--pe-sb-text);
}

.fi-sidebar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(90deg, var(--pe-sb-emerald), #35825c, var(--pe-sb-amber));
    opacity: .85;
}

/* The custom brand block replaces Filament's header. */
.fi-sidebar .fi-sidebar-header-ctn {
    display: none !important;
}

.fi-sidebar .fi-sidebar-nav {
    padding: .75rem .85rem .4rem !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(135, 144, 138, .38) transparent;
}

.fi-sidebar .fi-sidebar-nav::-webkit-scrollbar { width: 5px; }
.fi-sidebar .fi-sidebar-nav::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.fi-sidebar .fi-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(120, 131, 124, .28);
    border-radius: 999px;
}
.fi-sidebar .fi-sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(30, 77, 54, .38); }

.fi-sidebar .fi-sidebar-nav-groups {
    gap: 1.05rem;
    display: flex;
    flex-direction: column;
}

/* ---------- brand header ------------------------------------------------- */

.pe-sb-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .45rem;
    flex: none;
    height: 48px;
    padding: 0 .55rem 0 .7rem;
    border-bottom: 1px solid var(--pe-sb-border);
    background:
        radial-gradient(130% 200% at 100% 0%, rgba(46, 112, 81, .12) 0%, transparent 58%),
        rgba(252, 251, 247, .5);
}

.pe-sb-collapse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #4d5751;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .28s var(--pe-sb-spring);
}

.pe-sb-collapse svg { width: 1rem; height: 1rem; }

.pe-sb-collapse:hover {
    background: #ece8dc;
    border-color: var(--pe-sb-border);
    color: var(--pe-sb-emerald);
}

.pe-sb-collapse:active { transform: scale(.93); }

/* ---------- quick jump search -------------------------------------------- */

.pe-sb-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.pe-sb-search-icon {
    position: absolute;
    left: .5rem;
    display: inline-flex;
    color: #859089;
    pointer-events: none;
}

.pe-sb-search-icon svg { width: .72rem; height: .72rem; }

.pe-sb-search input {
    width: 100%;
    height: 1.95rem;
    padding: 0 1.45rem 0 1.65rem;
    border: 1px solid var(--pe-sb-border);
    border-radius: .55rem;
    background: #fcfbf7;
    color: var(--pe-sb-text);
    font: inherit;
    font-size: .68rem;
    font-weight: 500;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.pe-sb-search input::placeholder { color: #98a29b; }

.pe-sb-search input:focus {
    border-color: var(--pe-sb-emerald);
    box-shadow: 0 0 0 3px rgba(30, 77, 54, .1);
}

.pe-sb-search kbd {
    position: absolute;
    right: .28rem;
    padding: .05rem .25rem;
    border: 1px solid var(--pe-sb-border);
    border-radius: .25rem;
    background: #efece2;
    color: #8a948d;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .5rem;
    font-weight: 600;
}

/* ---------- group headers ------------------------------------------------ */

.fi-sidebar .fi-sidebar-group-btn {
    padding: .2rem .55rem .35rem !important;
}

.fi-sidebar .fi-sidebar-group-label {
    color: var(--pe-sb-group) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: .11em !important;
    text-transform: uppercase;
}

.fi-sidebar .fi-sidebar-group-collapse-btn {
    color: #96a099 !important;
}

/* ---------- menu items --------------------------------------------------- */

.fi-sidebar .fi-sidebar-item-btn {
    position: relative;
    gap: 13px;
    padding: 10.5px 14px !important;
    border: 1px solid transparent;
    border-radius: 13px !important;
    background: transparent;
    color: #2b352f;
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.25;
    transition:
        background-color .2s var(--pe-sb-ease),
        color .2s var(--pe-sb-ease),
        border-color .2s var(--pe-sb-ease),
        transform .22s var(--pe-sb-ease),
        box-shadow .22s ease;
}

.fi-sidebar .fi-sidebar-item-btn::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3.5px;
    border-radius: 0 4px 4px 0;
    background: var(--pe-sb-emerald);
    transform: scaleY(0);
    opacity: 0;
    transition: transform .28s var(--pe-sb-spring), opacity .2s ease;
}

.fi-sidebar .fi-sidebar-item-btn:hover {
    background: var(--pe-sb-emerald-hover) !important;
    border-color: rgba(30, 77, 54, .08);
    color: var(--pe-sb-emerald) !important;
    transform: translateX(2px);
}

.fi-sidebar .fi-sidebar-item-icon {
    width: 20px;
    height: 20px;
    color: #6f7a73 !important;
    transition: color .2s ease, transform .26s var(--pe-sb-spring);
}

.fi-sidebar .fi-sidebar-item-btn:hover .fi-sidebar-item-icon {
    color: var(--pe-sb-emerald) !important;
    transform: scale(1.06);
}

.fi-sidebar .fi-sidebar-item-label {
    flex: 1;
    color: #2b352f;
    font-size: 14.5px;
    font-weight: 500;
    letter-spacing: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fi-sidebar .fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background: linear-gradient(90deg, rgba(30, 77, 54, .14) 0%, rgba(30, 77, 54, .095) 100%) !important;
    border-color: rgba(30, 77, 54, .16) !important;
    color: var(--pe-sb-emerald) !important;
    box-shadow:
        0 2px 8px -3px rgba(30, 77, 54, .14),
        inset 0 1px 0 rgba(255, 255, 255, .65);
}

.fi-sidebar .fi-sidebar-item.fi-active > .fi-sidebar-item-btn::before {
    transform: scaleY(1);
    opacity: 1;
}

.fi-sidebar .fi-sidebar-item.fi-active > .fi-sidebar-item-btn .fi-sidebar-item-icon,
.fi-sidebar .fi-sidebar-item.fi-active > .fi-sidebar-item-btn .fi-sidebar-item-label {
    color: var(--pe-sb-emerald) !important;
    font-weight: 600 !important;
}

/* ---------- station footer ----------------------------------------------- */

.pe-sb-station {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex: none;
    margin: .55rem .85rem .9rem;
    padding: .7rem .75rem;
    border: 1px solid var(--pe-sb-border);
    border-radius: 14px;
    background: rgba(252, 251, 247, .85);
}

.pe-sb-station-dot {
    position: relative;
    flex: none;
    width: .45rem;
    height: .45rem;
    border-radius: 999px;
    background: #22c55e;
}

.pe-sb-station-dot::after {
    content: "";
    position: absolute;
    inset: -3px;
    border: 1px solid rgba(34, 197, 94, .5);
    border-radius: 999px;
    animation: pe-sb-pulse 2.2s infinite;
}

@keyframes pe-sb-pulse {
    0% { transform: scale(.9); opacity: .8; }
    70%, 100% { transform: scale(1.7); opacity: 0; }
}

.pe-sb-station-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: .1rem;
}

.pe-sb-station-copy strong {
    color: var(--pe-sb-text);
    font-size: .7rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pe-sb-station-copy span {
    color: var(--pe-sb-text-soft);
    font-size: .6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- collapsed rail ----------------------------------------------- */

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .pe-sb-brand {
    justify-content: center;
    padding: 0 .5rem;
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .pe-sb-search,
.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .pe-sb-station {
    display: none !important;
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-nav {
    padding: .7rem .55rem !important;
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-nav-groups {
    align-items: center;
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-item-btn {
    justify-content: center;
    gap: 0;
    padding: 11px 0 !important;
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-item-btn:hover {
    transform: translateY(-1px);
}

.fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-item-btn::before {
    display: none;
}

/* The sidebar's own chevron replaces Filament's topbar collapse control. */
@media (min-width: 64rem) {
    .fi-topbar-close-collapse-sidebar-btn,
    .fi-topbar-open-collapse-sidebar-btn {
        display: none !important;
    }
}

@media (max-width: 1023px) {
    .pe-sb-brand {
        height: 48px;
    }

    /* Keep the mobile drawer scrollable all the way to Settings. */
    .fi-sidebar .fi-sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto !important;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        scroll-padding-bottom: 1rem;
        padding-bottom: 1rem !important;
    }

    /* The station card is already shown in the topbar; free the space here. */
    .fi-sidebar .pe-sb-station {
        display: none !important;
    }
}

/* Branch panel logo: nudge the brand mark left and keep breathing room. */
.fi-panel-app .fi-topbar-start .fi-logo {
    margin-inline-start: 0.1rem;
}

.fi-panel-app .fi-topbar-start {
    margin-inline-end: 1rem;
}

@media (min-width: 64rem) {
    .fi-panel-app .fi-topbar {
        padding-inline-start: 0.75rem;
    }

    .fi-panel-app .fi-topbar-collapse-sidebar-btn-ctn {
        display: none;
    }
}
