/*
 * Desktop menu (1024px and wider): a narrow icon rail on the start edge and a
 * side panel that slides over the page when a rail section is chosen.
 *
 * This is the only stylesheet for the desktop menu. Colours and sizes come from
 * the --crm-rail-* and --crm-panel-* tokens (defaults in the design tokens; a
 * brand theme can change them), so a new brand never edits this file.
 * Written with logical properties, so Arabic (right to left) needs no extra rules
 * except the slide direction. Nothing here is marked important: rules win by load order.
 * Phones and tablets keep the standard Filament menu (smartco-navigation.css).
 */

@media (min-width: 1024px) {
    .smartco-nav-ready {
        --crm-sidebar-width: var(--crm-rail-width);
        --sidebar-width: var(--crm-rail-width);
        --crm-panel-closed: translateX(calc(-1 * (var(--crm-panel-width) + 16px)));
        --crm-panel-shadow-x: 16px;
    }

    html[dir="rtl"].smartco-nav-ready,
    html[dir="rtl"] .smartco-nav-ready {
        --crm-panel-closed: translateX(calc(var(--crm-panel-width) + 16px));
        --crm-panel-shadow-x: -16px;
    }

    /* Rail */
    .smartco-nav-rail {
        position: fixed;
        z-index: 100;
        inset-block: 0;
        inset-inline-start: 0;
        width: var(--crm-rail-width);
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        background: var(--crm-rail);
        border-inline-end: 1px solid var(--crm-rail-edge);
        overflow-x: hidden;
        overflow-y: auto;
        scrollbar-width: none;
    }

    .smartco-nav-rail::-webkit-scrollbar {
        display: none;
    }

    .smartco-nav-brand {
        display: none;
    }

    .smartco-nav-items {
        display: flex;
        flex-direction: column;
        gap: var(--crm-rail-gap);
        padding: 12px var(--crm-rail-inset);
    }

    .smartco-nav-footer {
        padding-bottom: 16px;
        border-top: 1px solid var(--crm-rail-divider);
    }

    .smartco-nav-button {
        position: relative;
        width: 100%;
        min-height: 64px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        padding: 7px 2px;
        border: 0;
        border-radius: var(--crm-rail-radius);
        background: transparent;
        color: var(--crm-rail-text);
        box-shadow: none;
        cursor: pointer;
        transition: background-color .12s ease, color .12s ease;
    }

    .smartco-nav-button:hover {
        background: var(--crm-rail-hover);
        color: var(--crm-rail-hover-text);
    }

    .smartco-nav-button:focus-visible {
        outline: 2px solid var(--crm-rail-focus);
        outline-offset: 1px;
    }

    /* Where you are: the section of the current page. */
    .smartco-nav-button.is-active {
        background: var(--crm-rail-active);
        color: var(--crm-rail-active-text);
    }

    .smartco-nav-button.is-active::before {
        content: "";
        position: absolute;
        inset-inline-start: calc(-1 * var(--crm-rail-inset));
        top: var(--crm-rail-marker-inset);
        bottom: var(--crm-rail-marker-inset);
        width: 3px;
        border-start-end-radius: var(--crm-rail-marker-radius);
        border-end-end-radius: var(--crm-rail-marker-radius);
        background: var(--crm-rail-marker);
    }

    /* The section whose panel is open. */
    .smartco-nav-button.is-selected {
        background: var(--crm-rail-selected);
        color: var(--crm-rail-active-text);
    }

    .smartco-nav-icon {
        width: 22px;
        height: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .smartco-nav-icon svg {
        width: 22px;
        height: 22px;
        color: inherit;
    }

    .smartco-nav-label {
        display: block;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: inherit;
        font-size: 11px;
        line-height: 1.15;
        font-weight: 500;
        letter-spacing: 0;
    }

    /* Arabic labels need more line height and may wrap onto two lines. */
    html[dir="rtl"] .smartco-nav-label {
        font-size: 11.5px;
        line-height: 1.4;
        white-space: normal;
        text-overflow: clip;
        text-align: center;
    }

    /* Side panel */
    .smartco-nav-ready .fi-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        inset-inline-start: var(--crm-rail-width);
        width: var(--crm-panel-width);
        min-width: var(--crm-panel-width);
        max-width: var(--crm-panel-width);
        height: 100vh;
        z-index: 95;
        overflow: visible;
        visibility: visible;
        background: var(--crm-surface);
        border-inline-end: 1px solid var(--crm-panel-edge);
        box-shadow: var(--crm-panel-shadow-x) 0 40px var(--crm-panel-shadow);
        transform: var(--crm-panel-closed);
        transition: transform .17s ease;
    }

    .smartco-nav-ready .fi-sidebar.smartco-nav-flyout-open {
        transform: translateX(0);
    }

    .smartco-nav-ready .fi-sidebar-header {
        display: none;
    }

    .smartco-nav-ready .fi-sidebar-nav {
        height: 100vh;
        padding: 24px 14px;
        overflow-y: auto;
    }

    .smartco-nav-ready .fi-sidebar-group {
        display: block;
        margin: 0;
        padding: 0;
    }

    .smartco-nav-ready .smartco-nav-group-hidden {
        display: none;
    }

    .smartco-nav-ready .fi-sidebar-group-label {
        display: flex;
        margin: 0 0 14px;
        padding: 0 10px;
        border-bottom: 0;
        color: var(--crm-panel-heading);
        font-size: 18px;
        line-height: 1.2;
        font-weight: 600;
        letter-spacing: -.015em;
        text-transform: none;
    }

    html[dir="rtl"] .smartco-nav-ready .fi-sidebar-group-label,
    html[dir="rtl"].smartco-nav-ready .fi-sidebar-group-label {
        letter-spacing: normal;
    }

    /* The panel shows one section at a time, so collapsing it adds nothing. */
    .smartco-nav-ready .fi-sidebar-group-collapse-btn {
        display: none;
    }

    .smartco-nav-ready .fi-sidebar-group-items {
        gap: 2px;
    }

    .smartco-nav-ready .fi-sidebar-item {
        margin: 0;
        padding: 0;
    }

    /* Small section headings inside the Settings panel. */
    /* Bold and in the brand colour, with a thin rule above, so each group stands out. */
    .smartco-nav-ready .axis-nav-subheading {
        margin: 16px 0 6px;
        padding: 12px 10px 0;
        border-top: 1px solid var(--crm-panel-subheading-rule, var(--crm-panel-edge));
        color: var(--crm-panel-subheading, var(--crm-panel-heading));
        font-size: 13.5px;
        line-height: 1.3;
        font-weight: 700;
        letter-spacing: 0.01em;
        list-style: none;
    }

    .smartco-nav-ready .axis-nav-subheading:first-child {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .smartco-nav-ready .fi-sidebar-item-btn {
        min-height: 38px;
        padding: 8px 10px;
        gap: 10px;
        border-radius: 8px;
        box-shadow: none;
    }

    .smartco-nav-ready .fi-sidebar-item-btn:hover {
        background: var(--crm-panel-hover);
    }

    /* Menu items at their natural weight and a touch larger: sharper, less bold (owner 22/11/2026). Headings stay as they are. */
    .smartco-nav-ready .fi-sidebar-item-label {
        color: var(--crm-panel-text);
        font-size: 14.5px;
        line-height: 1.35;
        font-weight: 400;
        letter-spacing: 0;
    }

    .smartco-nav-ready .fi-sidebar-item-btn svg {
        width: 19px;
        height: 19px;
        color: var(--crm-panel-icon);
    }

    /* Current page inside the panel. */
    .smartco-nav-ready .fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
        background: color-mix(in srgb, var(--primary-600) 9%, #fff);
    }

    .smartco-nav-ready .fi-sidebar-item.fi-active .fi-sidebar-item-label,
    .smartco-nav-ready .fi-sidebar-item.fi-active .fi-sidebar-item-btn svg {
        color: var(--primary-600);
        font-weight: 500;
    }

    /* Counts beside items, e.g. documents waiting to be checked. */
    .smartco-nav-ready .fi-sidebar-item .fi-badge {
        min-width: 22px;
        justify-content: center;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
    }

    /*
     * Page and top bar always clear the rail only. The panel slides over the page
     * (closing on Escape or a click outside) instead of squeezing wide tables.
     */
    .smartco-nav-ready .fi-main-ctn {
        --sidebar-width: var(--crm-rail-width);
        margin-inline-start: var(--crm-rail-width);
    }

    .smartco-nav-ready .fi-topbar {
        inset-inline-start: auto;
        margin-inline-start: var(--crm-rail-width);
        width: calc(100% - var(--crm-rail-width));
        overflow: visible;
    }

    /* Logo in the top bar; its height is the one set in Company Settings. */
    .fi-topbar .fi-topbar-start {
        width: 310px;
        min-width: 310px;
        max-width: 310px;
        margin: 0;
        padding-block: 0;
        padding-inline: 24px 12px;
        overflow: visible;
    }

    .fi-topbar-start > a {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
    }

    .fi-topbar .fi-logo {
        display: block;
        width: auto;
        min-width: 0;
        max-width: 220px;
        max-height: 42px;
        margin: 0;
        padding: 0;
        flex: 0 0 auto;
        object-fit: contain;
        object-position: left center;
    }

    html[dir="rtl"] .fi-topbar .fi-logo {
        object-position: right center;
    }
}
