/* Shared responsive layout safeguards for every ACE page. */

/* Keep short pill/link labels (View All, Details, Active, Pending,
   Resolved, Open, Closed, New, etc.) on one line at every screen size
   so they never wrap mid-label or overlap neighbouring text.
   NOTE: plain `.status` / `.status-message` message boxes are NOT
   included on purpose so long messages can still wrap normally. */
.view-all,
.badge,
.badge[class*="badge-"],
span.status,
.status-badge,
.status-active,
.status-inactive,
.status-pending,
.status-unknown,
.status-approved,
.status-resolved,
.status-open,
.status-closed,
.status-verified,
[class*="badge-"],
.pill,
.tag,
.role-badge,
.count-badge,
.notification-badge,
.unread-count,
.material-action,
.class-button,
.download,
.announcement-category {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Give card headers breathing room so a long heading can never
   collide with its View All / Details link on narrow screens. */
.section-header,
.section-heading-row,
.section-title {
    gap: 12px;
}

.section-header h2,
.section-heading-row h2,
.section-title h2,
.section-header h3,
.section-heading-row h3,
.section-title h3 {
    min-width: 0;
}

html,
body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

body {
    min-width: 0;
}

img,
picture,
video,
canvas,
svg,
iframe {
    max-width: 100%;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

main,
.main,
.content,
.container,
.wrapper,
.page-container,
.content-wrapper,
.dashboard-content,
.topbar,
.topbar-left,
.topbar-profile,
form,
section,
article,
aside,
[class*="grid"],
[class*="row"],
[class*="container"],
[class*="wrapper"] {
    min-width: 0;
}

/* ============================================================
   ONE-WORD TOKENS NEVER BREAK MID-WORD
   Role names, statuses and similar one-word values
   ("Administrator", "Active", "Learner", "Tutor", ...) must
   never be cut across lines ("Adminis-" / "trator").

   `break-word` (unlike `anywhere`, which several page
   stylesheets still set) only breaks a word when that word
   alone cannot fit the line - normally the whole word simply
   moves to the next line. `hyphens: none` stops automatic
   hyphenation from splitting words too.

   The universal selector + !important overrides every page
   and component stylesheet, no matter how specific.
   ============================================================ */

*,
*::before,
*::after {
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
}

h1,
h2,
h3,
p,
a,
button,
label,
td,
th {
    overflow-wrap: break-word;
}

pre {
    max-width: 100%;
    overflow: auto;
}

/* ============================================================
   FULL-BLEED PAGE LAYOUT
   Every page body / content wrapper occupies the entire
   screen width at every screen size. Component-sized boxes
   (modals, auth cards, dialogs, form columns) intentionally
   keep their caps - only page-body wrappers are un-capped.
   ============================================================ */

main,
.main,
.content,
.main-content,
.page,
.container,
.wrapper,
.page-container,
.content-wrapper,
.dashboard-content {
    max-width: 100% !important;
}

/* Card/stat grids expand into as many columns as the current
   screen allows instead of freezing at 2-3 columns on wide
   monitors. The small-screen media queries below still win
   (they carry !important and come later in this file). */
.cards,
.stats,
.stats-grid,
.stats-container,
.dashboard-grid,
.dashboard-cards,
.form-grid,
.filters-grid,
.filter-grid,
.detail-grid,
.impact-grid,
.impact-area-grid,
.services-grid,
.team-grid,
.features-grid,
.content-grid,
.classes-container,
.materials-grid,
.summary-grid,
.footer-container,
[class*="cards-grid"],
[class*="stats-grid"],
[class*="dashboard-grid"] {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)) !important;
}

@media (max-width: 1000px) {
    .cards,
    .stats,
    .stats-grid,
    .stats-container,
    .dashboard-grid,
    .dashboard-cards,
    .form-grid,
    .filters-grid,
    .filter-grid,
    .detail-grid,
    .impact-grid,
    .impact-area-grid,
    .services-grid,
    .team-grid,
    .features-grid,
    .content-grid,
    .footer-container,
    [class*="cards-grid"],
    [class*="stats-grid"],
    [class*="dashboard-grid"] {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)) !important;
    }
}

@media (max-width: 760px) {
    main,
    .main,
    .content,
    .container,
    .wrapper,
    .page-container,
    .content-wrapper,
    .dashboard-content,
    form {
        max-width: 100%;
    }

    .topbar-left,
    .topbar-profile,
    .page-header,
    .toolbar,
    .actions,
    .form-actions,
    .button-group,
    .filter-row {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .topbar {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .search-box,
    .search-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .cards,
    .stats,
    .stats-grid,
    .stats-container,
    .dashboard-grid,
    .dashboard-cards,
    .form-grid,
    .filters-grid,
    .filter-grid,
    .detail-grid,
    .impact-grid,
    .impact-area-grid,
    .services-grid,
    .team-grid,
    .features-grid,
    .content-grid,
    .footer-container,
    [class*="cards-grid"],
    [class*="stats-grid"],
    [class*="dashboard-grid"] {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)) !important;
    }

    table {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive,
    .table-wrapper,
    .table-container,
    .table-scroll {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
    select,
    textarea {
        width: 100%;
    }

    input,
    select,
    textarea {
        font-size: 1rem;
    }

    button:not(.view-all):not(.badge):not(.status):not(.status-badge):not(.pill):not(.tag):not(.chip):not(.material-action):not(.class-button):not(.download),
    input[type="submit"],
    input[type="button"] {
        white-space: normal;
    }

    .modal,
    .modal-content,
    .dialog,
    .popup {
        max-width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
        overflow: auto;
    }

    .content,
    .main-content,
    main.content {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: clamp(1.35rem, 6vw, 1.8rem);
    }

    .card,
    .panel,
    .modal-content {
        padding: clamp(0.75rem, 4vw, 1.25rem);
    }

    .topbar {
        height: auto;
        min-height: 3.5rem;
        padding-right: 0.75rem;
        padding-left: 0.75rem;
        gap: 0.375rem;
    }

    .topbar h1,
    .topbar h2,
    .page-title {
        font-size: clamp(0.85rem, 4vw, 1rem);
    }

    .menu-button,
    .menu-btn {
        width: 36px;
        height: 36px;
        
    }

    .ace-userchip {
        padding: 2px 6px 2px 2px;
        gap: 4px;
    }

    .ace-userchip-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 11px;
    }

    .ace-userchip-name {
        max-width: 70px;
        font-size: 0.6875rem;
    }
}

@media (max-width: 320px) {
    .topbar {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
        gap: 0.25rem;
    }

    .page-title {
        font-size: clamp(0.75rem, 4vw, 0.9rem);
    }

    .menu-btn {
        width: 32px;
        height: 32px;
        
    }

    .ace-userchip {
        padding: 2px 4px 2px 2px;
        gap: 2px;
    }

    .ace-userchip-avatar {
        width: 24px;
        height: 24px;
        min-width: 24px;
        font-size: 10px;
    }
}

/* ============================================================
   WHOLE-SPACE / FULL-WIDTH LAYOUT - every screen size
   Page wrappers, topbars, grids, tables and form controls
   fill the entire viewport width on mobile, tablet and
   desktop. Component-sized boxes (auth cards, modals,
   dialogs) keep their own caps and sit inside a full-width
   page.
   ============================================================ */

/* Root fills the viewport */
html,
body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Structural page wrappers - never capped, never centred,
   never pushed aside by a docked sidebar */
main,
.main,
.content,
.page-container,
.content-wrapper,
.dashboard-content,
header,
footer,
.topbar,
section,
article {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Generic containers / wrappers stretch to full width.
   Margins are preserved so centred auth cards still work
   (margin: auto is a no-op at 100% width). */
.container,
.wrapper,
[class*="container"],
[class*="wrapper"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Grid layouts fill the width at every screen size */
.cards,
.stats,
.stats-grid,
.stats-container,
.dashboard-grid,
.dashboard-cards,
.form-grid,
.filters-grid,
.filter-grid,
.detail-grid,
.impact-grid,
.impact-area-grid,
.services-grid,
.team-grid,
.features-grid,
.content-grid,
[class*="cards-grid"],
[class*="stats-grid"],
[class*="dashboard-grid"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Tables fill their container's width; wide tables scroll inside
   their .table-wrapper (or their own overflow) instead of pushing
   the page sideways. Tables must keep their native display:table --
   forcing display:block here shrank the columns to their content
   and left the table short of the container's full width (and
   silently disabled table-layout:fixed, which only applies to
   display:table elements). */
table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.table-responsive,
.table-wrapper,
.table-container,
.table-scroll {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Form controls fill their container */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select,
textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* ============================================================
   UNIVERSAL SCREEN-SIZE COVERAGE - one layer for every page
   Phones (<=480px), large phones/small tablets (<=768px),
   tablets/small laptops (<=1024px) and desktops (>1024px).
   These rules only *collapse* over-wide multi-column layouts
   and *scale down* fixed type - they never restyle branding.
   ============================================================ */

/* ---- Fluid media everywhere: never overflow narrow screens ---- */
img,
picture,
video,
canvas,
svg,
iframe,
embed,
object {
    max-width: 100% !important;
    height: auto;
}

img[width][height] {
    height: auto;
}

/* Long words / URLs / emails wrap instead of forcing sideways scroll */
p, li, td, th, a, span, div, h1, h2, h3, h4, label, figcaption {
    overflow-wrap: anywhere;
}

/* ---- Any grid with 2+ fixed columns collapses on small screens ---- */
@media (max-width: 1024px) {
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns:repeat(3"],
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns:repeat(4"],
    .cards,
    .stats,
    .stats-grid,
    .stats-container,
    .dashboard-grid,
    .dashboard-cards,
    .impact-grid,
    .impact-area-grid,
    .services-grid,
    .team-grid,
    .features-grid,
    .content-grid,
    .form-grid,
    .detail-grid,
    .filters-grid,
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    /* Two-column layouts become one column */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns:repeat(2"],
    .cards,
    .stats,
    .stats-grid,
    .stats-container,
    .dashboard-grid,
    .dashboard-cards,
    .impact-grid,
    .impact-area-grid,
    .services-grid,
    .team-grid,
    .features-grid,
    .content-grid,
    .form-grid,
    .detail-grid,
    .filters-grid,
    .filter-grid,
    .footer-container,
    .auth-columns,
    .login-columns,
    .register-columns {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    /* Flex rows wrap instead of squeezing off-screen */
    .topbar,
    .toolbar,
    .filters,
    .filter-bar,
    .filter-row,
    .search-row,
    .actions-row,
    .button-row,
    .btn-row,
    .card-actions,
    .section-heading-row,
    .page-head {
        flex-wrap: wrap !important;
    }

    /* Wide tables scroll inside their wrapper, page never scrolls sideways */
    .table-responsive,
    .table-wrapper,
    .table-container,
    .table-scroll,
    .table-card,
    .card-table {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Fixed-pixel type scales down one step on tablets/phones */
    .hero h1 { font-size: clamp(1.75rem, 8vw, 2.5rem) !important; }
    .section h2 { font-size: clamp(1.25rem, 5vw, 1.75rem) !important; }
}

/* ---- Phones: single column, full-width controls, comfy tap targets ---- */
@media (max-width: 480px) {
    body { font-size: 0.875rem; }

    main,
    .main,
    .content,
    .page-container,
    .content-wrapper,
    .dashboard-content,
    section,
    article {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Buttons / links that sat side-by-side stack full width */
    .actions-row > *,
    .button-row > *,
    .btn-row > *,
    .form-actions > *,
    .modal-actions > * {
        flex: 1 1 100% !important;
    }

    button,
    .btn,
    input[type="submit"],
    input[type="button"],
    a.btn,
    a.button {
        min-height: 44px;
    }

    /* Auth / dialog cards use the whole phone width */
    .login-card,
    .login-box,
    .login-container,
    .register-card,
    .register-box,
    .register-container,
    .auth-card,
    .auth-box,
    .card.auth,
    .modal,
    .modal-box,
    .dialog,
    .forgot-card,
    .reset-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Chat / message rows never squeeze the text bubble off-screen */
    .chat-messages,
    .messages,
    .message-list {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Footer stacks */
    .footer-container {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 24px !important;
        text-align: center;
    }
}

/* ---- Very small phones (<=360px): tighten padding, keep text readable ---- */
@media (max-width: 360px) {
    main,
    .main,
    .content,
    .page-container,
    .content-wrapper,
    .dashboard-content,
    section,
    article {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    h1 { font-size: clamp(1.125rem, 7vw, 1.5rem) !important; }
    h2 { font-size: clamp(1rem, 6vw, 1.25rem) !important; }
}

/* ---- Large desktops: cap line length for readability, keep centred ---- */
@media (min-width: 1400px) {
    main > .content,
    .page-container,
    .content-wrapper,
    .dashboard-content {
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Standardize portal menu buttons to match index.html .menu-button size */
.menu-button,
.menu-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

