/* ============================================================
   listpage.css  (shared, global; prefix lp-)
   ============================================================ */

.lp-page {
    --lp-ink: #17324d;
    --lp-ink-soft: #5b6b7c;
    --lp-line: #e6ebf1;
    --lp-surface: #ffffff;
    --lp-bg-soft: #f5f8fb;
    --lp-teal: #0e8f82;
    --lp-teal-bg: #e3f5f2;
    --lp-red: #c2453a;
    --lp-red-bg: #fbeae8;
    direction: rtl;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem;
}

/* ───────── Hero ───────── */

.lp-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, #17324d 0%, #1f4d6e 55%, #0e8f82 130%);
    box-shadow: 0 10px 30px -12px rgba(23, 50, 77, 0.55);
}

.lp-hero-top {
    flex-basis: 100%;
    display: flex;
    justify-content: flex-end; /* سمت چپ */
    margin-bottom: -0.25rem;
}

.lp-hero .lp-back-btn {
    color: #fff;
    padding: 0.25rem 0.75rem 0.25rem 0.9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(6px);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

    .lp-hero .lp-back-btn:hover {
        background: rgba(255, 255, 255, 0.26);
        transform: translateX(-3px);
    }

    .lp-hero .lp-back-btn:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

    .lp-hero .lp-back-btn .mud-button-icon-start {
        margin-inline-end: 0.35rem;
        margin-inline-start: 0;
    }

.lp-hero-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lp-hero-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.lp-hero .lp-hero-heading {
    font-weight: 700;
    color: #fff;
}

.lp-hero .lp-hero-sub {
    color: rgba(255, 255, 255, 0.78);
}

/* ───────── Stats ───────── */

.lp-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.lp-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 92px;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lp-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.lp-stat-label {
    font-size: 0.78rem;
    opacity: 0.85;
}

.lp-stat-active .lp-stat-value {
    color: #8ff0e1;
}

.lp-stat-inactive .lp-stat-value {
    color: #ffb4ab;
}

/* ───────── Card & Grid ───────── */

.lp-card {
    border-radius: 16px;
    overflow: hidden;
    background: var(--lp-surface);
    box-shadow: 0 4px 24px -14px rgba(23, 50, 77, 0.35);
}

    .lp-card .lp-grid.mud-table-outlined {
        border: 1px solid var(--lp-line);
        border-radius: 16px;
    }

.lp-toolbar {
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0;
}

    .lp-toolbar .lp-search {
        /* Fixed width so the toolbar looks the same on desktop and mobile */
        flex: 0 0 auto;
        width: 380px;
        max-width: 380px;
    }

    .lp-toolbar .lp-add-btn {
        white-space: nowrap;
    }

    .lp-toolbar .lp-search .mud-input-outlined-border {
        border-radius: 12px;
        border-color: var(--lp-line);
    }

    .lp-toolbar .lp-search .mud-input-root {
        background: var(--lp-bg-soft);
        border-radius: 12px;
    }

    .lp-toolbar .lp-add-btn {
        border-radius: 12px;
        padding: 0.45rem 1.25rem;
        font-weight: 600;
        box-shadow: 0 6px 16px -8px rgba(14, 143, 130, 0.8);
    }

.lp-card .mud-table-head .mud-table-cell {
    background: var(--lp-bg-soft);
    color: var(--lp-ink-soft);
    font-weight: 700;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--lp-line);
}

.lp-card .mud-table-body .mud-table-row {
    transition: background-color 0.15s ease;
}

.lp-card .mud-table-body .mud-table-cell {
    border-bottom: 1px solid #f0f3f7;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.lp-card .mud-table-foot .mud-table-cell {
    background: var(--lp-bg-soft);
    border-top: 1px solid var(--lp-line);
    font-weight: 600;
}

.lp-footer-text {
    color: var(--lp-ink-soft);
}

/* ───────── Cells ───────── */

.lp-row-number {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--lp-bg-soft);
    color: var(--lp-ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
}

.lp-name-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lp-name {
    color: var(--lp-ink);
    font-weight: 600;
}

.lp-code {
    display: inline-block;
    direction: ltr;
    padding: 0.15rem 0.6rem;
    border-radius: 8px;
    background: var(--lp-bg-soft);
    border: 1px solid var(--lp-line);
    color: var(--lp-ink);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

/* ───────── Status ───────── */

.lp-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.lp-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.lp-status-on {
    color: var(--lp-teal);
    background: var(--lp-teal-bg);
}

.lp-status-off {
    color: var(--lp-red);
    background: var(--lp-red-bg);
}

/* ───────── Empty / Loading ───────── */

.lp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 3rem 1rem;
    text-align: center;
}

.lp-empty-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: var(--lp-bg-soft);
    color: var(--lp-ink-soft);
}

.lp-empty .lp-empty-sub {
    color: var(--lp-ink-soft);
}

/* ───────── Pager ───────── */

.lp-card .mud-table-pagination {
    background: var(--lp-bg-soft);
    border-top: 1px solid var(--lp-line);
    border-radius: 0 0 16px 16px;
    padding: 0.25rem 0.75rem;
    direction: rtl;
    color: var(--lp-ink-soft);
    font-size: 0.82rem;
}

    .lp-card .mud-table-pagination .mud-table-pagination-toolbar {
        min-height: 44px;
        padding-inline: 0.5rem;
    }

    .lp-card .mud-table-pagination .mud-table-page-number-information {
        color: var(--lp-ink-soft);
        font-weight: 600;
        font-size: 0.82rem;
    }

    .lp-card .mud-table-pagination .mud-select {
        margin-inline-end: 0.5rem;
    }

        .lp-card .mud-table-pagination .mud-select .mud-input-outlined-border {
            border-radius: 10px;
            border-color: var(--lp-line);
        }

        .lp-card .mud-table-pagination .mud-select .mud-input-root {
            background: var(--lp-surface);
            border-radius: 10px;
            font-size: 0.82rem;
        }

    .lp-card .mud-table-pagination .mud-icon-button {
        color: var(--lp-ink-soft);
        border-radius: 10px;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

        .lp-card .mud-table-pagination .mud-icon-button:hover:not(:disabled) {
            background: var(--lp-teal-bg);
            color: var(--lp-teal);
        }

        .lp-card .mud-table-pagination .mud-icon-button:disabled {
            opacity: 0.4;
        }

/* ───────── Extras for the students list ───────── */

.lp-stat-selected .lp-stat-value {
    color: #ffe08a;
}

.lp-name {
    white-space: nowrap;
}

.lp-card-tabs {
    border-radius: 16px;
    overflow: hidden;
    padding: 0.25rem;
    background: var(--lp-surface);
    box-shadow: 0 4px 24px -14px rgba(23, 50, 77, 0.35);
}

    .lp-card-tabs .lp-tabs {
        background: transparent;
        box-shadow: none;
    }

    .lp-card-tabs .mud-tabs-toolbar {
        background: var(--lp-bg-soft);
        border-radius: 12px;
    }

    .lp-card-tabs .mud-tab.mud-tab-active {
        color: var(--lp-teal);
        font-weight: 700;
    }

    .lp-card-tabs .mud-tab-slider {
        background: var(--lp-teal);
    }

    .lp-card-tabs .mud-button-root {
        border-radius: 12px;
    }

@media (max-width: 960px) {
    .lp-page {
        padding: 0.25rem;
        gap: 0.75rem;
    }

    .lp-hero {
        padding: 1rem;
        border-radius: 14px;
        gap: 0.9rem;
    }

    .lp-hero-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .lp-stats {
        width: 100%;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .lp-stat {
        flex: 1;
        min-width: 0;
        padding: 0.45rem 0.25rem;
    }

    .lp-stat-value {
        font-size: 1.2rem;
    }

    .lp-stat-label {
        font-size: 0.72rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lp-hero .lp-back-btn {
        transition: none;
    }

        .lp-hero .lp-back-btn:hover {
            transform: none;
        }

    .lp-card .mud-table-body .mud-table-row {
        transition: none;
    }
}

/* ───────── Fit-to-viewport mode (opt-in: add "lp-page-fit" to the page root) ─────────
   The page itself never scrolls; only the records area of the grid does.
   Tune --lp-offset to the height of the app bar + main-content padding. */

.lp-page.lp-page-fit {
    --lp-offset: 5.5rem;
    height: calc(100vh - var(--lp-offset));
    height: calc(100dvh - var(--lp-offset));
    overflow: hidden;
    box-sizing: border-box;
}

.lp-page-fit > * {
    flex: 0 0 auto;
}

.lp-page-fit > .lp-card-fill {
    flex: 1 1 auto;
    min-height: 12rem;
    display: flex;
    flex-direction: column;
}

.lp-page-fit .lp-card-fill > .lp-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

    .lp-page-fit .lp-card-fill > .lp-grid .mud-table-container {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        max-height: none;
        overflow: auto;
    }

@media (max-width: 960px) {
    .lp-page.lp-page-fit {
        --lp-offset: 4.5rem;
    }

    .lp-page-fit .lp-hero-sub {
        display: none;
    }
}

/* ───────── Pager: side/top/bottom padding kept, but never a vertical scroll ───────── */

.lp-card .mud-table-pagination {
    overflow-x: auto;
    overflow-y: hidden;
}

    .lp-card .mud-table-pagination .mud-table-pagination-toolbar {
        height: auto;
        min-height: 44px;
        overflow: hidden;
    }

/* ───────── Grid toolbar: grows with its content ───────── */

/* Tune spacing per page by overriding these two variables on .lp-page */
.lp-page {
    --lp-toolbar-padding: 0.5rem 1rem;
    --lp-toolbar-margin: 0.5rem 0.5rem 0.25rem;
}

.lp-grid .mud-toolbar,
.lp-grid .mud-table-toolbar {
    height: auto;
    min-height: 0;
    padding: var(--lp-toolbar-padding);
    margin: var(--lp-toolbar-margin);
    border-radius: 12px;
    box-sizing: border-box;
}

/* ───────── Row actions (inline icon buttons) ───────── */

.lp-actions-inline {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
}

@media (max-width: 959.98px) {

    /* Toolbar: same size and spacing as desktop; the only difference is that it scrolls horizontally */
    .lp-grid .mud-toolbar,
    .lp-grid .mud-table-toolbar {
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

        .lp-grid .mud-toolbar::-webkit-scrollbar,
        .lp-grid .mud-table-toolbar::-webkit-scrollbar {
            display: none;
        }

    .lp-toolbar {
        flex-wrap: nowrap;
        /* Grows to fill the toolbar, never shrinks below its content: the toolbar scrolls instead.
           Keeps the grid's own column menu (ShowMenuIcon) right after it. */
        flex: 1 0 auto;
        width: max-content;
        min-width: 0;
    }

        .lp-toolbar > * {
            flex: 0 0 auto;
        }

    /* Tabs: swipe horizontally when the headers do not fit */
    .lp-tabs .mud-tabs-tabbar-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

        .lp-tabs .mud-tabs-tabbar-content::-webkit-scrollbar {
            display: none;
        }

    .lp-tabs .mud-tabs-tabbar-wrapper {
        transform: none !important;
    }

    .lp-tabs .mud-tabs-scroll-button {
        display: none;
    }

    .lp-tabs .mud-tab {
        flex: 0 0 auto;
        min-width: max-content;
    }
}

/* ───────── Avatar (letter avatar, pastel palette) ───────── */

.lp-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
    color: var(--lp-ink);
    border: 1px solid rgba(23, 50, 77, 0.08);
}

.lp-card .lp-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 0.9rem;
}

.lp-avatar-0 {
    background: #dbeafe;
    color: #1e40af;
}
/* blue */
.lp-avatar-1 {
    background: #d1fae5;
    color: #047857;
}
/* mint */
.lp-avatar-2 {
    background: #ede9fe;
    color: #5b21b6;
}
/* lavender */
.lp-avatar-3 {
    background: #ffedd5;
    color: #9a3412;
}
/* peach */
.lp-avatar-4 {
    background: #fce7f3;
    color: #9d174d;
}
/* pink */
.lp-avatar-5 {
    background: #ecfccb;
    color: #3f6212;
}
/* lime */

/* ───────── Small cell helpers ───────── */

.lp-text {
    color: var(--lp-ink);
    font-size: 0.875rem;
}

.lp-ltr {
    direction: ltr;
    display: inline-block;
}

.lp-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--lp-bg-soft);
    border: 1px solid var(--lp-line);
    color: var(--lp-ink);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.lp-tag-accent {
    padding: 0.1rem 0.35rem;
    color: var(--lp-teal);
    background: var(--lp-teal-bg);
    border-color: transparent;
}

/* ───────── Fit-to-viewport: compact header so the grid gets the height ───────── */

.lp-page-fit .lp-hero {
    padding: 0.85rem 1.25rem;
    gap: 0.75rem;
}

.lp-page-fit .lp-hero-top {
    margin-bottom: -0.5rem;
}

.lp-page-fit .lp-hero-icon {
    width: 46px;
    height: 46px;
}

.lp-page-fit .lp-stat {
    padding: 0.4rem 0.85rem;
}

.lp-page-fit .lp-stat-value {
    font-size: 1.25rem;
}

/* Tabs card: tab bar and panel never wrap to extra lines */
.lp-card-tabs .mud-tabs-tabbar-inner {
    min-height: 42px;
}

.lp-card-tabs .mud-tab {
    min-height: 42px;
}

@media (max-width: 959.98px) {
    /* The app bar already has Dashboard / Home buttons; hide the back row to save height */
    .lp-page-fit .lp-hero-top {
        display: none;
    }

    .lp-page-fit .lp-hero {
        padding: 0.6rem 0.75rem;
        gap: 0.5rem;
    }

    .lp-page-fit .lp-hero-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .lp-page-fit .lp-hero .lp-hero-heading {
        font-size: 1.1rem;
    }

    .lp-page-fit .lp-stat {
        padding: 0.3rem 0.2rem;
    }

    .lp-page-fit .lp-stat-value {
        font-size: 1.05rem;
    }

    .lp-page-fit .lp-stat-label {
        font-size: 0.68rem;
        white-space: nowrap;
    }

    .lp-page-fit .lp-card-fill {
        min-height: 9rem;
    }

    .lp-page-fit .lp-empty {
        padding: 1.25rem 0.75rem;
    }
}

/* Very short viewports (phone in landscape): fitting everything would leave no room for records,
   so fall back to normal page scrolling there. */
@media (max-height: 520px) {
    .lp-page.lp-page-fit {
        height: auto;
        overflow: visible;
    }

    .lp-page-fit > .lp-card-fill {
        flex: 0 0 auto;
    }

    .lp-page-fit .lp-card-fill > .lp-grid .mud-table-container {
        max-height: 70vh;
    }
}

/* ───────── Pager: identical on every screen size ─────────
   MudBlazor shrinks the pager on phones (hides first/last buttons, doubles the height on <=416px,
   moves the select and caption). These rules restore the desktop layout; if it does not fit,
   the pager scrolls horizontally (see .lp-card .mud-table-pagination above). */

.lp-card .lp-grid .mud-table-pagination .mud-table-pagination-toolbar {
    flex-wrap: nowrap;
    min-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
    padding-inline: 0.5rem;
}

.lp-card .lp-grid .mud-table-pagination .mud-table-pagination-spacer {
    flex: 1 1 auto;
}

.lp-card .lp-grid .mud-table-pagination .mud-table-pagination-caption {
    margin: 0 !important;
    white-space: nowrap;
}

.lp-card .lp-grid .mud-table-pagination .mud-table-pagination-select {
    margin-left: 10px !important;
    margin-right: 10px !important;
}

.lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions {
    display: flex;
    margin: 0;
    margin-inline-start: 10px;
}

    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions .mud-button-root:first-child,
    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions .mud-button-root:last-child {
        display: inline-flex;
    }


/* ============================================================
   FINAL OVERRIDES
   ToolbarContent and PagerContent: consistent desktop/mobile layout
   Pager has no outer margin in any viewport.
   ============================================================ */

/* Keep the grid toolbar visible and horizontally scrollable on narrow screens. */
.lp-card .lp-grid .mud-toolbar,
.lp-card .lp-grid .mud-table-toolbar {
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Pager wrapper: never hidden, collapsed, or given an outer margin. */
.lp-card .lp-grid .mud-table-pagination {
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    box-sizing: border-box;
    direction: rtl;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

    .lp-card .lp-grid .mud-table-pagination::-webkit-scrollbar {
        display: none;
    }

    /* Keep all pager controls in one desktop-like row. If they do not fit,
   the pager itself scrolls horizontally instead of hiding controls. */
    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-toolbar {
        display: flex !important;
        flex: 1 0 auto !important;
        flex-wrap: nowrap !important;
        width: 100%;
        min-width: max-content;
        min-height: 44px;
        height: auto;
        margin: 0 !important;
        padding: 0 0.5rem !important;
        box-sizing: border-box;
        overflow: visible !important;
    }

    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-spacer {
        flex: 1 1 auto;
    }

    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-caption {
        flex: 0 0 auto;
        margin: 0 !important;
        white-space: nowrap;
    }

    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-select {
        flex: 0 0 auto;
        margin-inline: 10px !important;
    }

    .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions {
        display: flex !important;
        flex: 0 0 auto;
        margin: 0 !important;
        margin-inline-start: 10px !important;
    }

        .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions .mud-button-root:first-child,
        .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-actions .mud-button-root:last-child {
            display: inline-flex !important;
        }

/* Mobile: preserve the same toolbar content and allow horizontal scrolling. */
@media (max-width: 959.98px) {
    .lp-card .lp-grid .mud-toolbar,
    .lp-card .lp-grid .mud-table-toolbar {
        display: flex !important;
        flex: 0 0 auto !important;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        box-sizing: border-box;
    }

        .lp-card .lp-grid .mud-toolbar::-webkit-scrollbar,
        .lp-card .lp-grid .mud-table-toolbar::-webkit-scrollbar {
            display: none;
        }

    .lp-card .lp-grid .lp-toolbar {
        display: flex;
        flex-wrap: nowrap !important;
        flex: 1 0 auto;
        width: max-content;
        min-width: max-content;
    }

        .lp-card .lp-grid .lp-toolbar > * {
            flex: 0 0 auto;
        }

    .lp-card .lp-grid .mud-table-pagination {
        display: flex !important;
        flex: 0 0 auto !important;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        visibility: visible !important;
    }

        .lp-card .lp-grid .mud-table-pagination .mud-table-pagination-toolbar {
            display: flex !important;
            flex-wrap: nowrap !important;
            min-width: max-content;
            min-height: 44px;
            margin: 0 !important;
        }
}
