/* Admin app -- PHONE / small-tablet layout (2026-11-23; Sabari: "convert all the screens under admin app to fully mobile compatible,
   let the PC screen stay as is"). Loaded by admin_templates/base.html ONLY for windows up to 820px wide
   (<link media="(max-width: 820px)">), so a PC window never sees one rule of this file and style.css is untouched.
   A screen is converted by giving its <body> the class `m-ready` ({% block body_class %}m-ready{% endblock %}); until then a wide
   table just scrolls sideways inside its own box (the fallback below), so nothing is ever cut off.
   Table rows become cards on an m-ready screen: base.html's small script copies every column heading onto its cells
   (data-label) and this file prints it in front of the value. */

/* ---- every admin screen: shell, tap sizes, no sideways page scroll ---- */
html { -webkit-text-size-adjust: 100%; }
body.m-ready { overflow-x: hidden; }      /* only converted screens: an unconverted wide page must still scroll sideways, never be clipped */
.topbar { padding: 8px 12px !important; flex-wrap: wrap; row-gap: 2px; }
.brand { font-size: 1rem; }
.crumb { font-size: 0.78rem; }
.content { padding: 10px 10px 28px; }
.panel { padding: 12px; }
.panel-head { flex-wrap: wrap; gap: 6px 14px; }
.panel-head h1 { font-size: 1.05rem; }
.panel-head > div { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.fy-line { font-size: 0.82rem; }
.link { padding: 6px 2px; }
.btn { min-height: 40px; padding: 9px 14px; font-size: 0.95rem; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="email"], input[type="search"], select, textarea {
  font-size: 16px;          /* 16px stops Android / iOS from zooming the page when a box is tapped */
  min-height: 40px;
}
input[type="file"] { max-width: 100%; font-size: 0.9rem; }
.form-page { max-width: none; }
.panel.form-page { margin: 16px auto !important; }
.dialog { width: auto; min-width: 0; max-width: 94vw; padding: 16px; }
.dialog .dialog-actions { flex-wrap: wrap; gap: 8px; }
.dialog input[type="text"], .dialog input[type="password"], .dialog textarea { width: 100%; box-sizing: border-box; }
details.type-group > form { flex-direction: column; align-items: stretch !important; }
details.type-group > form input { min-width: 0 !important; width: 100%; box-sizing: border-box; }

/* installed app: keep clear of the phone's status bar / gesture bar */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(8px + env(safe-area-inset-top)) !important; }
  .content { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

/* ---- Home: one card per row ---- */
.home-cards { padding: 8px 0; gap: 10px; }
/* two cards per row, name only (Sabari, 2026-11-23: the description line is dropped on the phone) */
.home-card { width: calc(50% - 5px); box-sizing: border-box; padding: 18px 12px; min-height: 64px; justify-content: center; text-align: center; }
.home-card-title { font-size: 0.98rem; }
.home-card-desc { display: none; }

/* ---- tables on a screen that is NOT converted yet: scroll inside the table's own box ---- */
table.grid { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- tables on a converted screen (body.m-ready): every row is a card ---- */
.m-ready table.grid, .m-ready table.grid tbody, .m-ready table.grid tr, .m-ready table.grid td { display: block; width: 100%; box-sizing: border-box; overflow: visible; }
.m-ready table.grid, .m-ready table.grid tbody { border: 0; padding: 0; background: none; }
.m-ready table.grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* headings stay for screen readers */
.m-ready table.grid tr { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 10px; padding: 4px 12px; background: var(--panel); }
.m-ready table.grid td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; text-align: right; padding: 7px 0; border: 0; border-bottom: 1px dashed var(--border); white-space: normal; word-break: break-word; }
.m-ready table.grid td:last-child { border-bottom: 0; }
.m-ready table.grid td.empty { border: 0; }
.m-ready table.grid td[data-label]::before { content: attr(data-label); flex: 0 0 34%; text-align: left; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.m-ready table.grid td:not([data-label]) { display: block; text-align: left; }
.m-ready table.grid td.empty { text-align: center; border: 0; }
.m-ready table.grid td.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px 16px; padding-top: 10px; }
.m-ready table.grid td.row-actions .link { padding: 8px 2px; font-size: 0.95rem; }
.m-ready table.grid td.row-actions form.inline { display: inline; }
.m-ready table.grid td[data-label="Name"] { font-weight: 600; font-size: 1.02rem; text-align: left; }
.m-ready table.grid td[data-label="Name"]::before { display: none; }
.m-ready table.grid td[data-label="ID"], .m-ready table.grid td[data-label="Address"] { display: none; }   /* kept on the Edit screen; the card stays short */

/* ---- Server Status ---- */
.status-cols { grid-template-columns: minmax(0, 1fr); }
.status-row { flex-wrap: wrap; gap: 4px 10px; }

/* =================== BATCH 2 (2026-11-23): forms and the smaller screens =================== */

/* ---- cards: a hidden row stays hidden; a cell that holds a box puts its caption ABOVE the box ---- */
.m-ready table.grid tr[hidden] { display: none; }
.m-ready table.grid td, .m-ready table.grid th { min-width: 0 !important; }    /* a screen's own <style> may give a column a minimum width */
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) { flex-direction: column; align-items: stretch; gap: 4px; text-align: left; }
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) input[type="text"],
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) input[type="number"],
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) input[type="password"],
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) select,
.m-ready table.grid td:has(input[type="text"], input[type="number"], input[type="password"], select, textarea) textarea { width: 100% !important; min-width: 0 !important; max-width: 100%; box-sizing: border-box; }
.m-ready table.grid td form { width: 100%; margin: 0; }
.m-ready table.grid td[data-label="File"], .m-ready table.grid td[data-label="Format"] { font-weight: 600; text-align: left; }
.m-ready table.grid td[data-label="File"]::before, .m-ready table.grid td[data-label="Format"]::before { display: none; }

/* ---- Add / Edit Client (client_form.html): the two PC columns become one, captions go above their boxes ---- */
.client-form-tight .client-form-columns { flex-direction: column; gap: 0; }
.client-form-tight .client-form-col-left, .client-form-tight .client-form-col-right { flex: 1 1 auto; width: 100%; min-width: 0; }
.client-form-tight .field-row { flex-wrap: wrap; gap: 2px 10px; margin-bottom: 12px; }
.client-form-tight .field-caption { flex: 0 0 100%; text-align: left; }
.client-form-tight .field-row input[type="text"], .client-form-tight .field-row input[type="password"], .client-form-tight .field-row input[type="date"], .client-form-tight .field-row select {
  flex: 1 1 100%; width: 100%; min-width: 0; box-sizing: border-box;
}
.client-form-tight .client-form-split-row { width: 100%; }
.client-form-tight .client-form-split-field { flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 2px; margin-bottom: 10px; }
.client-form-tight .client-form-split-field .field-caption, .client-form-tight .field-caption.client-form-caption-narrow { flex: 0 0 auto; text-align: left; }
.client-form-tight .client-form-split-field input, .client-form-tight .client-form-split-field select { width: 100% !important; box-sizing: border-box; }
.client-form-tight .hint { margin-left: 0; }
.client-form-tight .field-checkbox { align-items: flex-start; padding: 4px 0; }
.client-form-tight .field-checkbox input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 1px; }
.client-form-tight .client-form-actions-bottom, .client-form-tight .dialog-actions { flex-wrap: wrap; gap: 8px; }

/* ---- Menu Templates list: name on its own line, then Build Menu / Edit / Delete ---- */
.tmpl-tree { display: block; }
.tmpl-tree > li { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tmpl-tree .catalog-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.tmpl-tree .catalog-row > span:first-child { flex: 1 1 100%; }
.tmpl-tree .catalog-row .link { padding: 8px 2px; font-size: 0.95rem; }
.tmpl-tree .catalog-row form.inline { display: inline; }

/* ---- File Manager: keep the folder tree as a table that scrolls sideways (names never squeezed into a narrow column) ---- */
.file-tree-grid th, .file-tree-grid td { white-space: nowrap; }
.file-tree-grid td.file-tree-name { min-width: 150px; }

/* ---- Import review / other wide review tables keep their own scroll box; make taps easy ---- */
.import-review-grid input[type="checkbox"], .grid input[type="checkbox"] { width: 20px; height: 20px; }

/* Sandbox copy: its orange SANDBOX tag sits on the top edge -- leave it room so it never covers the title */
html[data-sandbox="1"] .topbar { padding-top: 22px !important; }

/* =================== BATCH 3 (2026-11-23): Menu Builder, Linked Screens, Database Structure =================== */

/* ---- Menu Builder: every item is a small block -- tick + name on top, its buttons wrapped underneath; headings indent their children ---- */
.catalog-tree, .catalog-tree.menu-vis-tree { display: block; overflow-x: visible; }
.catalog-tree > li { display: block; }
.catalog-tree > li > .catalog-tree { display: block; margin-left: 10px; padding-left: 8px; border-left: 2px solid var(--border); }
.catalog-tree .catalog-children[hidden] { display: none; }
.catalog-tree .catalog-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; padding: 8px 0 8px 40px; border-bottom: 1px solid var(--border); }
.catalog-tree .catalog-row > span { padding: 0; }
.catalog-tree .catalog-row > .catalog-vis { position: absolute; left: 0; top: 10px; }
.catalog-tree .catalog-vis input[type="checkbox"] { width: 22px; height: 22px; }
.catalog-tree .catalog-row > .catalog-caption { flex: 1 1 100%; min-width: 0; padding-left: 0 !important; white-space: normal; word-break: break-word; }
.catalog-tree .catalog-toggle-spacer { display: none; }
.catalog-tree .catalog-caption .mono { word-break: break-all; }
.catalog-tree .catalog-toggle { min-width: 30px; min-height: 30px; }
.catalog-tree .catalog-handle { display: none; }                 /* dragging needs a mouse; the up / down arrows do the same job */
.catalog-tree .catalog-row > .catalog-mover, .catalog-tree .catalog-row > .catalog-add-child, .catalog-tree .catalog-row > .catalog-add-sep,
.catalog-tree .catalog-row > .catalog-clients, .catalog-tree .catalog-row > .catalog-edit, .catalog-tree .catalog-row > .catalog-delete { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; }
.catalog-tree .catalog-row > :is(.catalog-mover, .catalog-add-child, .catalog-add-sep, .catalog-clients, .catalog-edit, .catalog-delete):not(:has(button, a, form)) { display: none; }
.catalog-tree .catalog-row .link { padding: 9px 4px; font-size: 0.95rem; }
.catalog-tree .catalog-row form.inline { display: inline; }
.catalog-tree .catalog-separator-row > span:first-child { flex: 0 0 auto; }
.catalog-tree .catalog-separator-line { flex: 1 1 100%; min-width: 0; }

/* ---- Linked Screens: each file is a card (rows that share a Transaction Type keep it only on their first card); the Client Type ticks sit two to a line ---- */
.m-ready table.grid.ls-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; }
.m-ready table.grid.ls-table td { grid-column: 1 / -1; }
.m-ready table.grid.ls-table td.mct-td { grid-column: auto; padding: 5px 0; }
.m-ready .ls-table td.mct-td::before { flex: 1 1 auto; font-size: 0.7rem; text-transform: none; }
.m-ready .ls-table td.mct-td input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; }
.m-ready .ls-table td[data-label="File"] { color: var(--ink); font-size: 1rem; }
.m-ready .ls-table td.desc-cell { padding-top: 10px; }
.m-ready .ls-table .desc-edit { min-height: 5.2em; }

/* ---- Database Structure: field tables fit the phone (small type, wrapped headings) instead of scrolling ---- */
.dbstruct-table-block table.grid { display: table; width: 100%; font-size: 0.8rem; }
.dbstruct-table-block table.grid th, .dbstruct-table-block table.grid td { padding: 6px 4px; word-break: break-word; }
.dbstruct-table-block table.grid th { font-size: 0.68rem; }
.m-ready table.grid.ls-table { min-width: 0 !important; table-layout: auto; }      /* the screen's own <style> sets a 1100px minimum for the PC matrix */
.m-ready table.grid.ls-table td.mono { white-space: normal; text-overflow: clip; overflow: visible; word-break: break-all; }
.ls-body { overflow-x: visible; }
.m-ready table.grid.ls-table td.mct-td { word-break: normal; overflow-wrap: normal; align-items: center; gap: 8px; }
.m-ready table.grid.ls-table td.mct-td::before { word-break: normal; overflow-wrap: normal; line-height: 1.25; }

/* ---- Clients (phone): a client is one line (its name); tap the name and its details + buttons open underneath like a drawer ---- */
.m-ready table.client-grid tr { padding: 0 12px; margin-bottom: 8px; }
.m-ready table.client-grid td:not([data-label="Name"]) { display: none; }
.m-ready table.client-grid tr.m-open td:not([data-label="Name"]):not([data-label="ID"]):not([data-label="Address"]) { display: flex; }
.m-ready table.client-grid tr.m-open td.row-actions { display: flex; }
.m-ready table.client-grid td[data-label="Name"] { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0; border-bottom: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.m-ready table.client-grid td[data-label="Name"]::after { content: "\25B8"; color: var(--muted); font-size: 1rem; font-weight: 400; }
.m-ready table.client-grid tr.m-open td[data-label="Name"]::after { content: "\25BE"; }
.m-ready table.client-grid tr.m-open td[data-label="Name"] { border-bottom: 1px dashed var(--border); }
.m-ready table.client-grid tr.m-open { background: var(--panel); border-color: var(--accent); }

/* ---- Clients (phone): Edit / Login as client / Export / Delete as four buttons, two per row ---- */
.m-ready table.client-grid tr.m-open td.row-actions { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; padding: 12px 0 14px; }
.m-ready table.client-grid tr.m-open td.row-actions form.inline { display: block; margin: 0; }
.m-ready table.client-grid tr.m-open td.row-actions :is(a.link, button.link, span.link) {
  display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 100%; min-height: 44px; padding: 8px 6px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--accent); text-decoration: none; font-size: 0.95rem; text-align: center;
}
.m-ready table.client-grid tr.m-open td.row-actions :is(button.link-danger, span.link) { border-color: #b91c1c; color: #b91c1c; }
