/* ═══════════════════════════════════════════════════════════
   mobile.css — Global responsive behavior (≤ 960px)
   Desktop layout is untouched; these rules only engage on small
   viewports. Highest target: 320 / 375 / 425 / 576 / 768px.
   ═══════════════════════════════════════════════════════════ */

/* ── Kill horizontal scrolling everywhere ── */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

@media (max-width: 960px) {

    /* ── Main content breathing room ── */
    .custom-main-content {
        padding-top: 4px;
    }

    /* The drawer is a temporary overlay on mobile — content must not
       be pushed by a mini rail. */
    .mud-main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* ── AppBar: tighten icon spacing so actions fit on 320px ── */
    .custom-appbar .mud-toolbar {
        padding-left: 4px;
        padding-right: 4px;
    }

    .custom-appbar .mud-icon-button {
        padding: 5px;
    }

    /* فاصلهٔ بیشتر بین آیکن‌های تم / اعلان / پیام / پروفایل */
    .custom-appbar .mud-badge,
    .custom-appbar > .mud-tooltip-root,
    .custom-appbar > .mud-menu {
        margin: 0 16px;
    }
}

@media (max-width: 600px) {
    .custom-appbar .mud-icon-button {
        padding: 5px;
    }

    .custom-appbar .mud-badge,
    .custom-appbar > .mud-tooltip-root,
    .custom-appbar > .mud-menu {
        margin: 0 14px;
    }

    /* ── Tables: never force the page wider than the screen.
       Wrap every table in a horizontal scroll context instead. ── */
    .mud-table-container,
    .table-responsive,
    .table-scroll-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Plain HTML tables used in some pages */
    table {
        max-width: 100%;
    }

    /* ── Dialogs: محتوا اسکرول، دکمه‌ها همیشه پیدا ── */
    .mud-dialog {
        margin: 8px !important;
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100vh - 16px) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* بدنهٔ دیالوگ تا فضای موجود رشد می‌کند و خودش اسکرول می‌خورد */
    .mud-dialog > .mud-dialog-content {
        padding: 12px !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }

    /* دکمه‌های پایین دیالوگ همیشه دیده شوند (چسبیده به پایین) */
    .mud-dialog > .mud-dialog-actions {
        flex-shrink: 0 !important;
        position: sticky;
        bottom: 0;
        z-index: 2;
        background: var(--mud-palette-surface);
        border-top: 1px solid var(--mud-palette-lines-default);
        padding: 10px 14px !important;
        gap: 8px;
    }

    /* دیالوگ‌هایی با ارتفاع ثابت (مثل ثبت مریض) در موبایل به ارتفاع محتوا برسند */
    .patient-dialog,
    .mud-dialog.patient-dialog {
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100vh - 16px) !important;
    }

    /* Two-column dialog bodies stack on mobile */
    .two-column-section {
        grid-template-columns: 1fr !important;
    }

    /* ── Cards: smaller radius + padding so they don't dominate ── */
    .mud-card,
    .stat-card,
    .chart-card {
        border-radius: 12px;
    }

    /* ── Notification / message panels fit the screen width ── */
    .panel-popup {
        width: calc(100vw - 24px) !important;
        max-width: 360px;
    }

    /* Pin the notification / message popover near the left edge so it
       doesn't overflow off the right side of the screen on mobile */
    .mud-popover.topbar-panel-popover {
        left: 12px !important;
        right: auto !important;
        max-width: calc(100vw - 24px) !important;
        transform: none !important;
    }

    /* ── Page section padding trim ── */
    .pa-4 {
        padding: 12px !important;
    }

    /* ── Forms: full-width fields, comfortable tap height ── */
    .mud-input-control {
        width: 100%;
    }
}

/* ── Extra-small phones (≤ 420px): edge-to-edge density ── */
@media (max-width: 420px) {

    .custom-main-content .mud-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Hide non-essential tooltips/labels that crowd tiny bars */
    .custom-appbar .mud-icon-button {
        padding: 5px;
    }

    /* Stat cards stack to a single column */
    .stat-card,
    .dashboard-stat {
        min-width: 100% !important;
    }
}
