/*
 * Responsive safety net, loaded after the compiled Tailwind CSS on every
 * layout (app, borrower, guest). Page-specific fixes belong in the views;
 * this file only holds the rules that apply app-wide.
 */

/* A grid / flex item defaults to min-width:auto, so one long unbroken string
   (a file name, an email, a nowrap label) stretches its track past the
   viewport. Letting grid items shrink fixes that everywhere at once. */
.grid > * { min-width: 0; }

img, video, canvas { max-width: 100%; height: auto; }

/* File-upload rows ("doc_row_*"): the text block and the Upload button wrap
   instead of squeezing a long file name against the button. */
[id^="doc_row_"] { flex-wrap: wrap; }
[id^="doc_row_"] > .flex-1 { min-width: 0; flex: 1 1 12rem; }
[id^="doc_row_"] .truncate { max-width: 100%; }
.uploaded-file-line { max-width: 100%; word-break: break-all; }

/* Side-menu labels wrap instead of being cut off ("Application for IIF Taggi…",
   "Declarations & Other Formats"). */
aside .truncate { white-space: normal; overflow: visible; text-overflow: clip; }

/* Cards that hold a table scroll the table, not the page. */
.dt-container, .dataTables_wrapper { max-width: 100%; }

/* Fixed-width panels (inline 40% / w-[30%] side panels and pop-ups) go full
   width on small screens. */
@media (max-width: 767px) {
    [style*="width:40%"], [style*="width: 40%"], [style*="width:30%"], [style*="width: 30%"] {
        width: 100% !important;
    }
    .my-swal-popup { width: 92vw !important; max-width: 92vw; height: auto !important; }
    .swal2-popup { max-width: 92vw; }
}

/* DataTables toolbar (page length / search / status filter): stack and let the
   controls take the full row on phones. */
@media (max-width: 639px) {
    div.dt-container div.dt-layout-row:not(.dt-layout-table) {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    div.dt-container div.dt-layout-row:not(.dt-layout-table) > .dt-layout-cell {
        width: 100%;
        justify-content: flex-start !important;
    }
    div.dt-container .dt-search { width: 100%; flex-wrap: wrap; }
    div.dt-container .dt-search input { flex: 1 1 8rem; width: auto !important; min-width: 0; }
    div.dt-container .dt-search select { flex: 1 1 8rem; min-width: 0; }
    div.dt-container .dt-paging { flex-wrap: wrap; }
}

/* Page headers with a title on the left and a block on the right wrap
   instead of overflowing. */
@media (max-width: 639px) {
    main .flex.items-start.justify-between { flex-wrap: wrap; }
    main .text-right.flex-shrink-0 { text-align: left; flex-shrink: 1; }
}

/* ------------------------------------------------------------------ *
 * Brand logos. The SMFCL logo (539x311, artwork drawn for a white
 * backing) is shown at its natural aspect ratio - never cropped into a
 * circle - at roughly the same visual weight as the Ministry emblem.
 * ------------------------------------------------------------------ */
.brand-logo-smfcl { display: block; height: 52px; width: auto; max-width: none; flex-shrink: 0; }
.brand-logo-plate {
    display: inline-flex; align-items: center; justify-content: center;
    background: #ffffff; border-radius: 0.875rem; padding: 0.5rem 1rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.brand-logo-plate .brand-logo-smfcl { height: 68px; }
@media (max-width: 639px) {
    .brand-logo-smfcl { height: 40px; }
    .brand-logo-plate .brand-logo-smfcl { height: 52px; }
    .brand-emblem { width: 112px; max-width: 40vw; }
}

/* ------------------------------------------------------------------ *
 * Language switch (EN | हिन्दी) and Hindi typography.
 * ------------------------------------------------------------------ */
.lang-switch {
    display: inline-flex; align-items: center; flex-shrink: 0;
    border: 1px solid rgba(13, 43, 85, 0.3); border-radius: 9999px; overflow: hidden;
    font-size: 0.75rem; font-weight: 700; line-height: 1; white-space: nowrap; background: #fff;
}
.lang-switch a { display: block; padding: 0.4rem 0.7rem; color: #0d2b55; text-decoration: none; }
.lang-switch a:not(.is-active):hover { background: rgba(13, 43, 85, 0.08); }
.lang-switch a.is-active { background: #0d2b55; color: #fff; }
@media (max-width: 400px) {
    .lang-switch a { padding: 0.35rem 0.5rem; }
}
/* The single "अ A" icon version of the switch: no pill, just the icon. */
.lang-switch.lang-switch--icon {
    border: 0; border-radius: 8px; padding: 4px 6px; background: transparent; overflow: visible;
    color: #0d2b55; text-decoration: none; cursor: pointer;
}
.lang-switch--icon img { display: block; height: 30px; width: auto; }
.lang-switch.lang-switch--icon:hover { background: rgba(13, 43, 85, 0.08); }
.lang-switch.lang-switch--icon:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
/* Header-only variant: hidden on phones (the mobile menu carries its own copy). */
.lang-switch.lang-switch--sm-up { display: none; }
@media (min-width: 640px) {
    .lang-switch.lang-switch--sm-up { display: inline-flex; }
}
html[lang="hi"] body {
    font-family: 'Figtree', 'Noto Sans Devanagari', 'Nirmala UI', 'Mangal', system-ui, sans-serif;
}
html[lang="hi"] .hero-heading-gradient { line-height: 1.35; }

/* Devanagari carries matras above and below the line, so the tight line heights tuned for
   Latin text (1.2 - 1.4, or Tailwind's leading-tight / text-xs / text-sm sizes) make wrapped
   Hindi lines collide. Give Hindi text room wherever it can wrap. */
html[lang="hi"] :is(h1, h2, h3, h4, h5, h6) { line-height: 1.5; }
html[lang="hi"] :is(p, li, dd, dt, label, td, th, small, blockquote, .leading-tight, .leading-snug, .leading-none, .text-xs, .text-sm, .text-base) { line-height: 1.6; }
html[lang="hi"] .hero-heading-gradient { line-height: 1.35; }

/* ------------------------------------------------------------------ *
 * Helpdesk / IT-support block (landing footer, login card, app footer).
 * ------------------------------------------------------------------ */
.helpdesk-block { font-size: 0.78rem; line-height: 1.5; }
.helpdesk-block .hd-title { font-weight: 700; margin-bottom: 0.25rem; display: block; }
.helpdesk-block ul { list-style: none; margin: 0; padding: 0; }
.helpdesk-block li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.helpdesk-block .hd-label { opacity: 0.75; }
.helpdesk-block a { text-decoration: underline; word-break: break-all; }
.helpdesk--footer { color: #bfdbfe; }
.helpdesk--footer .hd-title { color: #ffffff; }
.helpdesk--footer a { color: #ffffff; }
.helpdesk--card { color: #4b5563; border-top: 1px solid #e5e7eb; margin-top: 1rem; padding-top: 0.75rem; }
.helpdesk--card .hd-title { color: #0d2b55; }
.helpdesk--card a { color: #1d4ed8; }
.helpdesk--app { color: #6b7280; text-align: center; margin-bottom: 0.5rem; }
.helpdesk--app ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.15rem 1.25rem; }
.helpdesk--app .hd-title { display: inline; margin-right: 0.5rem; color: #0d2b55; }
.helpdesk--app a { color: #1d4ed8; }

/* ------------------------------------------------------------------ *
 * Scheme workflow (landing page + compact version on dashboards):
 * phases laid out in a responsive grid, each a vertical timeline.
 * ------------------------------------------------------------------ */
.wf-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (min-width: 768px) { .wf-wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .wf-wrap { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wf-phase {
    background: #ffffff; border: 1px solid #e5e7eb; border-radius: 1rem;
    padding: 1rem 1rem 1.1rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.wf-phase-title {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
    color: #0d2b55; margin-bottom: 0.9rem; padding-bottom: 0.5rem; border-bottom: 2px solid #f7941d;
}
.wf-steps { list-style: none; margin: 0; padding: 0; }
.wf-step { position: relative; padding: 0 0 1.1rem 2.6rem; min-height: 1.9rem; }
.wf-step:last-child { padding-bottom: 0; }
.wf-step::before {
    content: ""; position: absolute; left: 0.93rem; top: 2rem; bottom: 0.1rem; width: 2px; background: #e5e7eb;
}
.wf-step:last-child::before { display: none; }
.wf-num {
    position: absolute; left: 0; top: 0; width: 1.9rem; height: 1.9rem; border-radius: 9999px;
    background: var(--wf-color, #0d2b55); color: #fff; font-size: 0.8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.wf-title { font-weight: 700; font-size: 0.875rem; color: #111827; line-height: 1.3; }
.wf-desc { font-size: 0.78rem; color: #6b7280; margin-top: 0.15rem; line-height: 1.45; }
.wf-actor {
    display: inline-block; margin-top: 0.3rem; font-size: 0.65rem; font-weight: 700;
    padding: 0.1rem 0.55rem; border-radius: 9999px; color: var(--wf-color, #0d2b55);
    background: var(--wf-bg, #eef2f7);
}
.wf-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.25rem; margin-bottom: 1.25rem; font-size: 0.75rem; color: #4b5563; }
.wf-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.wf-legend i { width: 0.7rem; height: 0.7rem; border-radius: 9999px; display: inline-block; }
/* Compact (dashboards): titles only. */
.wf-compact .wf-desc { display: none; }
.wf-compact .wf-step { padding-bottom: 0.7rem; }
.wf-compact .wf-title { font-size: 0.8rem; }
.wf-compact .wf-phase { padding: 0.75rem; }
