/* ==========================================================================
   HETRIIL — application-wide responsive layer
   --------------------------------------------------------------------------
   Additive only. Hardens the existing Metronic / Tailwind styles for small
   viewports, ultra-wide monitors, browser zoom and display scaling without
   altering the established desktop design.

   Loaded last on every layout so it acts as a final safety net. Rules are
   intentionally low-specificity / cause-oriented so existing component
   styles (dashboard.css, list-pages.css, nav.css, auth.css, landing.css)
   keep their own responsive behaviour and take precedence where they are
   more specific.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base: consistent box model, zoom-safe text scaling, overflow guards
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    /* Keep text size consistent across mobile browsers and orientation changes
       (prevents iOS "text inflation"). */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Note: horizontal overflow is fixed at the source (fluid media, shrinkable
   flex children, scrolling table wrappers, wrapping text) rather than by
   clipping the page, so nothing is ever hidden or cut off. */

/* --------------------------------------------------------------------------
   2. Fluid media — images, charts, embeds and canvases never overflow their
      container and keep their aspect ratio. Class-based sizing still wins,
      so component-specific dimensions are unaffected.
   -------------------------------------------------------------------------- */
img,
svg,
video,
canvas,
iframe,
embed,
object {
    max-width: 100%;
}

img,
video {
    height: auto;
}

/* --------------------------------------------------------------------------
   3. Flex / grid children must be allowed to shrink below their content
      width, otherwise wide tables & cards force horizontal scrolling.
   -------------------------------------------------------------------------- */
.card,
.het-dash-card,
.het-list-page,
.wrapper,
.flex-row-fluid,
.flex-column-fluid {
    min-width: 0;
}

/* --------------------------------------------------------------------------
   4. Long, unbreakable strings (emails, URLs, reference codes) wrap instead
      of forcing the layout wider than the screen. Normal words are only
      broken when they genuinely cannot fit.
   -------------------------------------------------------------------------- */
.card,
.card-body,
.modal-body,
.het-dash,
.het-list-page,
.het-auth-card {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* --------------------------------------------------------------------------
   5. Forms & buttons — never exceed the available width.
   -------------------------------------------------------------------------- */
.form-control,
.custom-select,
.custom-file,
.select2-container,
.select2-selection,
.btn {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   6. Tables — data tables and their wrappers scroll horizontally instead of
      breaking the layout (complements the per-page table styles).
   -------------------------------------------------------------------------- */
.table-responsive,
.het-dash-table-wrap,
.het-list-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   7. Small screens (<= 575px, incl. 375px phones): tighten card padding so
      content keeps a comfortable reading width instead of being squeezed by
      desktop-sized padding.
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .card-body {
        padding: 1rem;
    }

    .card-header,
    .card-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Card / section titles stay balanced on small screens */
    .card-title {
        margin-bottom: 1rem;
    }
}

/* --------------------------------------------------------------------------
   8. Profile page — the fixed 250px sidebar stacks above the content on
      tablets and phones instead of squeezing it. When Metronic turns the
      aside into an off-canvas panel (adds `.offcanvas`) the built-in
      behaviour is preserved.
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Parent flex row collapses to a column when it holds the profile aside */
    .d-flex.flex-row:has(> #kt_profile_aside) {
        flex-direction: column;
    }

    #kt_profile_aside.w-250px:not(.offcanvas) {
        width: 100% !important;
        margin-bottom: 1.5rem;
    }
}

/* --------------------------------------------------------------------------
   9. Admin subheader — on tablets & phones the subheader sits in normal flow
      (auto height), so its title / breadcrumbs / action cluster is allowed to
      wrap instead of overflowing the page. On desktop Metronic's fixed-height
      behaviour is preserved untouched.
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    #kt_subheader .container-fluid,
    #kt_subheader .container-fluid > .d-flex {
        flex-wrap: wrap;
    }
}
