/* Shared layout rules for public pages and both portals. */
body .main-content, body .card-portal, body .row > *,
body .d-flex > div, body .help-center > *, body .hero-content > * { min-width: 0; }
body img { max-width: 100%; }
body :is(.card-portal, .footer, .help-center, .modal-content) { overflow-wrap: anywhere; }
body .table-responsive { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
body .table-responsive:focus-visible { outline: 2px solid #121350; outline-offset: 3px; }
body .hero-full { width: 100%; left: auto; right: auto; margin-left: 0; margin-right: 0; }
body .contact-panels .stat-icon { flex-shrink: 0; }
body [data-aos="fade-left"], body [data-aos="fade-right"] { transform: translateY(16px); }
body [data-aos].aos-animate { transform: none; }
body .sidebar { top: 0; bottom: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
.sidebar-close, .sidebar-toggle, .sidebar-backdrop { display: none; }
body .sidebar-close { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; }
body .sidebar-header { position: relative; }
body .topbar > div { min-width: 0; }
body .topbar .page-title { overflow-wrap: anywhere; }
body .users-search { width: 260px; max-width: 100%; min-width: 0; flex: 1 1 180px; }
body .users-filter-tools { flex: 1 1 280px; min-width: 0; }
body .card-portal > .d-flex { flex-wrap: wrap; gap: 12px; }
body :is(#paginationButtons, .admin-pagination) { flex-wrap: wrap; gap: 4px; }

body .modal-content { min-width: 0; }
body .modal-title { min-width: 0; overflow-wrap: anywhere; }
body .modal-header .btn-close { flex-shrink: 0; }
body .modal-footer { flex-wrap: wrap; }

@media (max-width: 991.98px) {
    body .sidebar { width: min(280px, calc(100vw - 48px)); transform: translateX(-100%); visibility: hidden; z-index: 1040; transition: transform .2s ease, visibility .2s; }
    body .sidebar.open { transform: translateX(0); visibility: visible; }
    body .main-content { margin-left: 0; padding: 16px; }
    body .sidebar-toggle, body .sidebar-close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
    body .sidebar-toggle { width: 44px; height: 44px; padding: 0; }
    body .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 1035; border: 0; background: rgba(15,23,42,.45); }
    body.sidebar-open { overflow: hidden; }
    body .navbar-collapse { max-height: calc(100dvh - 80px); overflow-y: auto; padding: 12px 0; }
    body .navbar-brand { min-width: 0; margin-right: 8px; white-space: normal; }
    body .navbar-brand span { line-height: 1.2; }
    body .navbar-brand img { flex-shrink: 0; }
    body .navbar-toggler { flex-shrink: 0; }
    /* AOS horizontal entrance offsets must not enlarge the page on phones. */
    body [data-aos="fade-left"], body [data-aos="fade-right"] { transform: translateY(16px); }
    body [data-aos].aos-animate { transform: none; }
    body .hero-content { flex-direction: column; gap: 32px; }
    body .hero-right { width: 100%; max-width: 360px; }
    body .help-center { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px; }
    body #helpTopics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body .help-topic, body .help-chip { overflow-wrap: anywhere; }
}

@media (max-width: 575.98px) {
    body .main-content { padding: 12px; }
    body .main-content > .container-fluid { padding-left: 0; padding-right: 0; }
    body .topbar { padding: 12px; gap: 10px; margin-bottom: 16px; }
    body .topbar > .d-flex { gap: 10px !important; }
    body .page-title { font-size: 1.1rem; line-height: 1.3; }
    body .card-portal, body .card-portal.p-4, body .security-panel, body .profile-summary { padding: 16px !important; }
    body .profile-left { margin-bottom: 0; }
    body .profile-membership, body .profile-academic { flex-wrap: wrap; gap: 8px; }
    body .profile-year { text-align: left; }
    body .navbar-brand { font-size: 1rem; max-width: calc(100% - 64px); }
    body .navbar-brand img { height: 34px; width: auto; margin-right: 8px !important; }
    body .navbar { padding: 12px 0; }
    body .hero-full { padding: 36px 0; margin-bottom: 32px; }
    body .hero-title { font-size: clamp(1.9rem, 8vw, 2.6rem); overflow-wrap: anywhere; }
    body .hero-subtitle { font-size: 1rem; }
    body .hero-right .floating-icon { width: 44px; height: 44px; }
    body .hero-right .floating-icon-2 { right: 0; }
    body .hero-right .floating-icon-3 { left: 0; }
    body .services-grid, body .features-grid { grid-template-columns: minmax(0, 1fr); }
    body .service-card, body .feature-card { min-width: 0; padding: 24px 18px; }
    body .footer { padding: 32px 0 20px; margin-top: 32px; }
    body .help-center { padding: 16px; gap: 20px; }
    body .help-search { padding: 10px; gap: 8px; }
    body .help-answer summary { padding: 16px; gap: 12px; }
    body .help-answer-content { padding: 0 16px 16px; }
    body .help-support { flex-wrap: wrap; }
    body .help-support a { margin-left: 0; }
    body .student-panel, body .chart-container, body .stat-card-modern { padding: 16px; }
    body .student-panel-heading, body .inquiry-card > .d-flex { flex-wrap: wrap; gap: 8px; }
    body .student-recent-table { table-layout: fixed; width: 100%; }
    body .student-recent-table td { overflow-wrap: anywhere; }
    body .dashboard-chart { height: 250px; }
    body .users-toolbar .card-header { padding: 0 !important; }
    body .users-filter-tools { width: 100%; gap: 8px !important; }
    body .modal-dialog { margin: 12px auto; max-width: calc(100% - 24px); }
    body .modal-header, body .modal-body, body .modal-footer { padding: 16px; }
    body .modal-dialog-centered { min-height: calc(100% - 24px); }
    body :is(input.form-control, select.form-select, textarea.form-control, .help-search input) { font-size: 16px; }
    body .modal-footer .btn { min-height: 44px; }
    body .login-card, body .reset-card, body .register-card { padding: 24px 16px; }
    body .admission-steps { padding: 8px 16px; }
    body .btn-group { flex-wrap: wrap; }
}

@media (max-width: 359.98px) {
    body .student-stats, body #helpTopics { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    body .sidebar { transition: none; }
}
