/* Shared admin panel responsiveness — phone + tablet (≤1023px).
   Loaded on every /admin page after admin-brand.css. */

/* --------------------------------------------------------------------------
   Tables: scroll the content area only — never clip toolbar dropdowns
   (التصفيات / الأعمدة panels break when .fi-ta-ctn has overflow:hidden
   and the empty-state body is short).
   -------------------------------------------------------------------------- */

.fi-ta-ctn {
    /* Filament already manages overflow; do not force hidden here —
       it clips .fi-dropdown-panel for filters & column manager. */
    overflow: visible;
}

.fi-ta-ctn .fi-ta-content-ctn,
.fi-ta-ctn .fi-ta-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Keep dropdown panels above empty-state / short table bodies */
.fi-ta-ctn .fi-dropdown-panel,
.fi-ta-ctn .fi-ta-filters-dropdown .fi-dropdown-panel,
.fi-ta-ctn .fi-ta-col-manager-dropdown .fi-dropdown-panel {
    z-index: 40;
}

@media (max-width: 1023px) {
    .fi-page .fi-ta-ctn {
        overflow: visible;
    }

    .fi-page .fi-ta-ctn .fi-ta-content-ctn,
    .fi-page .fi-ta-ctn .fi-ta-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Header actions: wrap / stack so Export & Save stay reachable */
    .fi-page .fi-header-actions-ctn,
    .fi-header-actions-ctn,
    .fi-page .fi-header-actions,
    .fi-header-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
        max-width: 100%;
    }

    .fi-page .fi-header-heading-col,
    .fi-header-heading-col {
        min-width: 0;
        max-width: 100%;
    }

    /* Toolbar wrap — do not clip dropdown overflow */
    .fi-ta-header,
    .fi-ta-header-toolbar,
    .fi-ta-actions {
        flex-wrap: wrap;
        max-width: 100%;
    }

    .fi-main,
    .fi-main-ctn,
    .fi-page,
    .fi-page > section {
        max-width: 100%;
        /* Avoid overflow-x:clip — it creates a containing block that
           truncates Floating UI dropdowns (filters / columns). */
        overflow-x: visible;
    }

    /* Session timeout / generic modals on narrow screens */
    .fi-modal-window-ctn {
        padding-inline: 0.75rem;
    }

    .fi-modal-window {
        max-width: min(100%, 28rem);
        width: 100%;
    }

    /* Stats overview: ensure cards don't overflow */
    .fi-wi-stats-overview-stat {
        min-width: 0;
    }

    .fi-wi-stats-overview-stat .fi-wi-stats-overview-stat-value {
        word-break: break-word;
    }

    /* Brand logo: don't force wide sidebar header on phones */
    .fi-sidebar .fi-brand-mark__img {
        max-width: 7.5rem;
    }
}

@media (max-width: 639px) {
    .fi-page .fi-header-actions-ctn .fi-btn,
    .fi-header-actions-ctn .fi-btn,
    .fi-page .fi-header-actions .fi-btn,
    .fi-header-actions .fi-btn {
        width: 100%;
        justify-content: center;
    }

    .fi-page .fi-header-actions-ctn,
    .fi-header-actions-ctn,
    .fi-page .fi-header-actions,
    .fi-header-actions {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   Floating scroll-to-top (all authenticated admin pages)
   -------------------------------------------------------------------------- */

.admin-scroll-to-top {
    position: fixed;
    /* Opposite the sidebar: left in RTL (ar), right in LTR (en). */
    inset-inline-end: max(0.75rem, env(safe-area-inset-end, 0px));
    inset-inline-start: auto;
    inset-block-end: max(1rem, env(safe-area-inset-bottom, 0px));
    z-index: 40;
    pointer-events: none;
}

.admin-scroll-to-top__btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 9999px;
    border: 0.5px solid rgba(13, 59, 46, 0.18);
    background: #0d3b2e;
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 59, 46, 0.28);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.admin-scroll-to-top__btn:hover {
    background: #164a3c;
}

.admin-scroll-to-top__btn:focus-visible {
    outline: 2px solid #c9a227;
    outline-offset: 2px;
}

.admin-scroll-to-top__icon {
    width: 1.25rem;
    height: 1.25rem;
}

@media (min-width: 640px) {
    .admin-scroll-to-top {
        inset-inline-end: max(1.25rem, env(safe-area-inset-end, 0px));
        inset-block-end: max(1.5rem, env(safe-area-inset-bottom, 0px));
    }

    .admin-scroll-to-top__btn {
        width: 3rem;
        height: 3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .admin-scroll-to-top__btn {
        transition: none;
    }
}
