/* EduNexora v1.1.4 mobile compatibility layer.
   Loaded after module styles so legacy and newly-added screens behave consistently. */
html {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.responsive-table,
.table-responsive,
.table-wrap,
.canvas-scroll,
.monthly-attendance-scroll,
.reception-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.responsive-table > table,
.table-responsive > table,
.table-wrap > table {
    margin: 0;
}

.modal,
.dialog,
[role="dialog"] {
    max-width: 100vw;
}

@media (max-width: 850px) {
    .erp-shell,
    .main,
    .portal-main,
    .content,
    .portal-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .topbar {
        min-height: 64px;
        height: auto;
        padding: 10px 14px;
        gap: 10px;
    }

    .top-actions {
        margin-left: auto;
        gap: 5px;
    }

    .top-actions .profile-copy,
    .top-actions .header-welcome,
    .top-actions .select-pill,
    .top-actions .branch-pill,
    .top-actions .academic-session-pill {
        display: none !important;
    }

    .notification-menu,
    .profile-menu,
    .quick-menu {
        position: fixed;
        top: 68px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 82px);
        overflow-y: auto;
    }

    .content,
    .portal-content,
    .permission-page {
        padding: 14px !important;
    }

    .page-head,
    .cms34-head,
    .theme-manager-heading,
    .permission-head,
    .reception-panel-head,
    .panel-title,
    .toolbar,
    .student-toolbar {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .page-head {
        display: flex;
    }

    .page-head h1 {
        font-size: 20px;
        overflow-wrap: anywhere;
    }

    .page-actions,
    .fee-head-actions,
    .form-actions,
    .fee-form-actions,
    .current-actions,
    .permission-actions,
    .reception-form-actions,
    .bulk-actions,
    .property-actions,
    .theme-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100%;
        gap: 9px !important;
    }

    .page-actions > *,
    .fee-head-actions > *,
    .form-actions > *,
    .fee-form-actions > *,
    .current-actions > *,
    .permission-actions > *,
    .reception-form-actions > *,
    .bulk-actions > *,
    .theme-actions > * {
        width: 100% !important;
        justify-content: center;
        text-align: center;
    }

    .form-grid,
    .details-grid,
    .filter-grid,
    .filter-row,
    .fee-filter-bar,
    .student-filters,
    .reception-filter,
    .reception-form,
    .reception-report-filter,
    .bulk-settings,
    .permission-meta,
    .permission-groups,
    .cms34-grid,
    .phase321-settings-grid,
    .communication-kpis {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .span-2,
    .wide,
    .reception-span-2,
    .channel-picker,
    .reception-report-actions {
        grid-column: auto !important;
    }

    .form-grid,
    .filter-row,
    .fee-filter-bar,
    .student-filters,
    .reception-form,
    .reception-report-filter {
        padding: 14px !important;
    }

    .form-grid input,
    .form-grid select,
    .form-grid textarea,
    .filter-row input,
    .filter-row select,
    .fee-filter-bar input,
    .fee-filter-bar select,
    .toolbar input,
    .toolbar select {
        width: 100% !important;
        min-width: 0 !important;
    }

    .kpi-grid,
    .fee-kpi-grid,
    .reception-stats,
    .phase18-page .stat-grid,
    .v36-kpis,
    .communication-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .dashboard-grid,
    .lower-grid.two,
    .two-col,
    .reception-dashboard-grid,
    .transport-grid,
    .profile-page-grid,
    .phase18-page .grid-2,
    .designer-layout {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .card,
    .panel,
    .reception-panel,
    .permission-card,
    .cms34-card {
        max-width: 100%;
        min-width: 0;
    }

    table {
        max-width: none;
    }

    th,
    td {
        white-space: nowrap;
    }

    td p,
    td .description,
    td .message,
    td .notes {
        min-width: 220px;
        white-space: normal;
    }

    .designer-sidebar {
        position: static !important;
        width: 100%;
    }

    .designer-workspace {
        width: 100%;
        min-width: 0;
        padding: 8px !important;
    }

    .canvas-scroll {
        padding: 12px !important;
        max-height: none !important;
    }

    .document-canvas {
        transform-origin: top left;
    }

    .receipt,
    .fee-receipt {
        padding: 16px !important;
    }

    .receipt-head,
    .receipt-header,
    .receipt-bottom {
        align-items: flex-start !important;
        flex-direction: column !important;
        gap: 12px;
    }

    .receipt-title,
    .receipt-total,
    .ledger-total,
    .signature {
        margin-left: 0 !important;
        text-align: left !important;
    }

    .receipt-grid,
    .receipt-meta {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .portal-topbar {
        min-height: 68px;
        height: auto;
        padding: 10px 14px;
    }

    .portal-topbar-user > div {
        display: none;
    }

    .portal-logout-button {
        padding: 8px 10px;
    }
}

@media (max-width: 560px) {
    .content,
    .portal-content,
    .permission-page {
        padding: 10px !important;
    }

    .kpi-grid,
    .fee-kpi-grid,
    .reception-stats,
    .phase18-page .stat-grid,
    .v36-kpis,
    .communication-kpis,
    .quick-grid,
    .reception-module-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .welcome-card,
    .profile-card,
    .student-import-card,
    .transport-hero,
    .automation-list article {
        align-items: flex-start !important;
        flex-direction: column !important;
    }

    .welcome-date,
    .profile-copy,
    .header-welcome {
        display: none !important;
    }

    .notification-menu,
    .profile-menu,
    .quick-menu {
        right: 6px;
        left: 6px;
    }

    .portal-topbar-left small {
        display: none;
    }

    .portal-topbar-left b {
        display: block;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media print {
    .responsive-table,
    .table-responsive,
    .table-wrap {
        overflow: visible !important;
    }
}
