/*
 * Manager on phones (m4.2.13).
 *
 * Every page loads this file with
 *   media="(max-width: 600px), (pointer: coarse) and (max-height: 500px)"
 * so a browser only applies it on a phone, upright or on its side. iPads
 * (744px and wider, never under 500px tall) and desktops never load these
 * rules, and their screens stay exactly as they are. Phone-only fixes go
 * here and nowhere else; ui-tests/lock.mjs checks iPad and desktop screens
 * are unchanged.
 */

/* ── Header: the tabs scroll sideways; badge and logout stay on screen ── */
.manager-header { padding: 0 0 0 0.5rem; gap: 0.25rem; }
.manager-brand { margin-right: 0; }
.manager-brand .manager-title { display: none; }
.manager-nav {
  margin-left: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.manager-nav::-webkit-scrollbar { display: none; }
.manager-nav a { padding: 0 0.6rem; font-size: 0.82rem; white-space: nowrap; flex: 0 0 auto; }
.manager-version-badge { margin-left: 0.25rem; margin-right: 0.15rem; padding: 0.15rem 0.4rem; flex: 0 0 auto; }
.manager-logout { flex: 0 0 auto; padding: 0 0.7rem; min-width: 44px; }

/* ── Page edges ── */
.manager-main { padding: 1rem 0.75rem 2.5rem; }
.main { padding: 0.25rem 0 1.5rem; }
.section-header, .manager-page-header, .page-header { flex-wrap: wrap; gap: 0.6rem; }

/* ── Instances: one card per instance instead of an 8-column table ── */
#instance-table thead { display: none; }
#instance-table, #instance-table tbody { display: block; width: 100%; }
#instance-table tr {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name status"
    "version heartbeat"
    "agents agents"
    "actions actions";
  gap: 0.35rem 0.75rem;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid #1e1e2e;
}
#instance-table tr:last-child { border-bottom: none; }
#instance-table td { display: block; padding: 0; border: none; background: none; }
#instance-table td:nth-child(2), #instance-table td.cell-region { display: none; }
#instance-table td.cell-name { grid-area: name; font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
#instance-table td.cell-status { grid-area: status; justify-self: end; }
#instance-table td.cell-version, #instance-table td.cell-heartbeat { font-size: 0.8rem; color: var(--muted-foreground, #888); }
#instance-table td.cell-version { grid-area: version; }
#instance-table td.cell-version::before { content: "Version "; }
#instance-table td.cell-heartbeat { grid-area: heartbeat; justify-self: end; }
#instance-table td.cell-heartbeat::before { content: "Heartbeat "; color: var(--muted-foreground, #888); }
#instance-table td.cell-agents { grid-area: agents; font-size: 0.82rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
#instance-table td.cell-agents::before { content: "Agents"; color: var(--muted-foreground, #888); margin-right: 0.15rem; }
#instance-table td.cell-actions { grid-area: actions; }
#instance-table .open-instance-btn { width: 40px; height: 36px; }

/* ── Other tables scroll inside their own box, not the whole page ── */
table:not(#instance-table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-container { max-width: 100%; }

/* ── Settings and detail rows wrap instead of running off the edge ── */
.settings-row { flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.settings-value { overflow-wrap: anywhere; }
.detail-card, .detail-grid > * { min-width: 0; }
.detail-card code, .detail-card a, .cell-id { overflow-wrap: anywhere; word-break: break-word; }

/* ── Comfortable tap sizes for the buttons people press most ── */
.btn-sm { min-height: 36px; }
.kebab-trigger { min-width: 40px; min-height: 36px; }
