/*
 * Drag-to-resize sidebar — default admin theme only.
 *
 * Scoped to body[data-admin-theme="default"] so the split-sidebar rail theme is left
 * entirely alone. The grip rides on Filament's own sidebar machinery: the Alpine
 * component writes --sidebar-width (which Filament's layout already reads) and flips the
 * native collapse store, so the icon rail, tooltips and content shift come for free.
 */

/* Only meaningful when the sidebar sits beside the content (desktop). */
@media (min-width: 1024px) {
    /* Purely visual full-height divider on the trailing edge. Never takes pointer events. */
    body[data-admin-theme='default'] .fi-sidebar-resize-line {
        position: absolute;
        inset-block: 0;
        inset-inline-end: 0;
        width: 1px;
        background-color: var(--gray-200);
        pointer-events: none;
        z-index: 30;
    }

    .dark body[data-admin-theme='default'] .fi-sidebar-resize-line {
        background-color: var(--gray-800);
    }

    /* The always-present grip — the only place a drag can begin. */
    body[data-admin-theme='default'] .fi-sidebar-resize-handle {
        position: absolute;
        inset-block: 0;
        inset-inline-end: -7px;
        width: 14px;
        cursor: col-resize;
        touch-action: none;
        z-index: 31;
    }

    /* Highlight the divider on hover/drag. */
    body[data-admin-theme='default'] .fi-sidebar-resize-handle:hover + .fi-sidebar-resize-line,
    body.fi-sidebar-resizing[data-admin-theme='default'] .fi-sidebar-resize-line {
        background-color: var(--primary-500);
        width: 2px;
    }

    /* Kill transitions while dragging so the panel tracks the pointer exactly. */
    body.fi-sidebar-resizing[data-admin-theme='default'] .fi-sidebar,
    body.fi-sidebar-resizing[data-admin-theme='default'] .fi-main-ctn {
        transition: none !important;
    }

    /* Disable text selection mid-drag. */
    body.fi-sidebar-resizing[data-admin-theme='default'] {
        user-select: none;
    }

    /* Pin the collapsed icon rail to COLLAPSE_AT (104px) so crossing in/out doesn't jump. */
    body[data-admin-theme='default'].fi-body-has-sidebar-collapsible-on-desktop .fi-sidebar:not(.fi-sidebar-open) {
        width: 104px !important;
    }

    /* Fade the whole label as the sidebar narrows toward collapse. */
    body[data-admin-theme='default'] .fi-sidebar .fi-sidebar-item-label {
        opacity: var(--resizer-label-opacity, 1) !important;
    }
}

/* Below the desktop breakpoint, leave Filament's mobile drawer completely alone. */
@media (max-width: 1023px) {
    .fi-sidebar-resize-line,
    .fi-sidebar-resize-handle {
        display: none;
    }
}

/*
 * Sidebar navigation search box (default theme). Sits at the top of the nav, where the
 * tenant switcher usually lives, and filters the menu client-side.
 */
body[data-admin-theme='default'] .fi-sidebar-nav-search {
    padding: 0.5rem 0.75rem 0.25rem;
}

body[data-admin-theme='default'] .fi-sidebar-nav-search-input {
    width: 100%;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    background-color: var(--gray-50);
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--gray-950);
    outline: none;
    transition: border-color 75ms ease;
}

body[data-admin-theme='default'] .fi-sidebar-nav-search-input::placeholder {
    color: var(--gray-400);
}

body[data-admin-theme='default'] .fi-sidebar-nav-search-input:focus {
    border-color: var(--primary-500);
}

.dark body[data-admin-theme='default'] .fi-sidebar-nav-search-input {
    border-color: var(--gray-700);
    background-color: var(--gray-900);
    color: var(--white);
}

/* Hide the search box when the sidebar is collapsed to the icon rail. */
body[data-admin-theme='default'] .fi-sidebar:not(.fi-sidebar-open) .fi-sidebar-nav-search {
    display: none;
}

/* Items/groups filtered out by the search. */
.fi-nav-search-hidden {
    display: none !important;
}
