/*
 * Hand-written additions to the precompiled Metronic Tailwind build
 * (assets/css/styles.css has no build step here, so a utility class the
 * templates need but that file lacks must be defined here). Loaded after it.
 */

/* Responsive column spans (2026-11-06). Form grids are one column on phones
 * (`grid lg:grid-cols-2`); a plain `col-span-2` child forced a second implicit
 * column there and squeezed every field into half the width. Spans now apply
 * only from the breakpoint where the grid has the columns. Breakpoints match
 * styles.css (sm 40rem, lg 64rem, xl 80rem). */
@media (width >= 40rem) {
  .sm\:col-span-2 { grid-column: span 2 / span 2; }
  .sm\:col-span-3 { grid-column: span 3 / span 3; }
}
@media (width >= 64rem) {
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
}
@media (width >= 80rem) {
  .xl\:col-span-2 { grid-column: span 2 / span 2; }
}

/* iOS Safari gives date/time inputs a native minimum width and look, so they
 * spill out of their column; keep them inside the box like the other inputs. */
input[type="date"].kt-input,
input[type="time"].kt-input,
input[type="datetime-local"].kt-input,
input[type="month"].kt-input {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  width: 100%;
}
input.kt-input::-webkit-date-and-time-value {
  text-align: start;
  min-height: 1.25rem;
}

/* Image boxes (2026-11-07). `size-20`, `size-28`, `object-cover` and
 * `object-contain` are missing from styles.css, so logos and photos rendered
 * at their natural size and pushed the page around (Settings → Company showed
 * a 600px logo). `.fw-contain` fits an image inside its box without cropping
 * — the right fit for logos, which are rarely square. */
.size-20 { width: calc(var(--spacing) * 20); height: calc(var(--spacing) * 20); }
.size-28 { width: calc(var(--spacing) * 28); height: calc(var(--spacing) * 28); }
.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }
.fw-contain { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }

/* Utilities the settings pages (and others) use but styles.css lacks
 * (2026-11-07, found by scanning console/templates/settings for classes with
 * no rule). Colours follow Metronic's own badges: success = green-500,
 * warning = yellow/amber, danger = the destructive token. */
.text-success { color: var(--color-green-500); }
.text-warning { color: var(--color-amber-500); }
.text-danger { color: var(--color-destructive); }
.bg-success\/10 { background-color: color-mix(in oklab, var(--color-green-500) 10%, transparent); }
.border-success\/20 { border-color: color-mix(in oklab, var(--color-green-500) 20%, transparent); }
.bg-warning\/10 { background-color: color-mix(in oklab, var(--color-amber-500) 10%, transparent); }
.border-warning\/20 { border-color: color-mix(in oklab, var(--color-amber-500) 20%, transparent); }
.border-warning\/30 { border-color: color-mix(in oklab, var(--color-amber-500) 30%, transparent); }
.bg-accent\/40 { background-color: color-mix(in oklab, var(--color-accent, var(--accent)) 40%, transparent); }
.items-baseline { align-items: baseline; }
.p-10 { padding: calc(var(--spacing) * 10); }
.py-8 { padding-block: calc(var(--spacing) * 8); }
.text-4xl { font-size: 2.25rem; line-height: 1.11; }
.text-5xl { font-size: 3rem; line-height: 1; }
.w-\[80px\] { width: 80px; }
.min-w-\[100px\] { min-width: 100px; }

/* Checkbox with a label beside it. Templates use Metronic 8 names that the
 * v9 build dropped, so the box and its text rendered as unrelated inline bits. */
.kt-checkbox-group { display: flex; align-items: flex-start; gap: calc(var(--spacing) * 2.5); cursor: pointer; }
.kt-checkbox-group > .kt-checkbox { flex-shrink: 0; margin-top: 1px; }
.kt-checkbox-label { font-size: var(--text-sm); line-height: 1.35; }

/* Settings -> Document Design (2026-11-07): controls beside a live PDF
 * preview. The preview gets the wider column so the page is readable; one
 * column below lg. */
.fw-design-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (width >= 64rem) {
  .fw-design-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}

/* Settings menu (2026-11-08): below xl the grid is one column, so the full
 * menu card sat above every settings page. There a dropdown replaces it. */
.fw-settings-nav-select { display: block; }
.fw-settings-nav-card { display: none; }
@media (width >= 80rem) {
  .fw-settings-nav-select { display: none; }
  .fw-settings-nav-card { display: flex; }
}

/* Clickable summary tiles (invoices list). */
.hover\:border-primary:hover { border-color: var(--primary); }

/* List search + status: one row from sm up, stacked on phones. */
.fw-list-filters { display: flex; flex-wrap: wrap; }
@media (width >= 40rem) { .fw-list-filters { flex-wrap: nowrap; } }
.kt-menu-link.text-destructive, .kt-menu-link.text-destructive .kt-menu-icon i { color: var(--destructive); }

/* Dashboard money tiles: 2 per row, 4 from xl. */
.fw-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (width >= 80rem) { .fw-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Page background (2026-11-11). The content area used to be the same white
 * as the cards, so cards and tables barely stood out. The page now gets its
 * own soft neutral (--fw-page); the header bar, inputs and cards keep their
 * colours. Do NOT retint --background instead: the header, kt-input,
 * kt-select and kt-textarea all paint with it. Only the main layout
 * (body.demo1, layouts/base.html) gets it, so the login/minimal layouts and
 * printing stay white. Card borders change through the --border variable,
 * not border-color, so `border-primary` / `hover:border-primary` on tiles
 * still win. */
:root {
  --fw-page: #f4f4f6;                 /* option A neutral */
  --fw-card-head: #fafafa;
  --fw-card-border: #e4e4e7;
  --fw-table-head: #f4f4f5;
  --fw-table-head-fg: var(--color-zinc-500);
}
.dark {
  --fw-page: var(--color-zinc-950);   /* #09090b, unchanged */
  --fw-card-border: var(--color-zinc-800);
  --fw-card-head: #161619;            /* a step above the card */
  --fw-table-head: #1c1c20;           /* a step above the card header */
  --fw-table-head-fg: var(--color-zinc-400);
  --card: #131316;                    /* lifted off the page */
}
body.demo1 { background-color: var(--fw-page); }
.kt-card { --border: var(--fw-card-border); }
/* Card header band and table header row get a faint tint so the title
 * and the column labels separate from the white rows. The header's top
 * corners follow the card's (radius + 4px, minus its 1px border). Table
 * header text is muted, smaller, semibold; no uppercase/letter-spacing —
 * both hurt Arabic. */
.kt-card-header {
  background-color: var(--fw-card-head);
  border-start-start-radius: calc(var(--radius) + 3px);
  border-start-end-radius: calc(var(--radius) + 3px);
}
.kt-table thead th {
  background-color: var(--fw-table-head);
  color: var(--fw-table-head-fg);
  font-size: 0.75rem;
  font-weight: 600;
}
@media print {
  body.demo1 { background-color: #fff; }
}
