/* Admin panel. Loaded after base.css, but light: caja is read on a phone
   at the front desk, often in daylight, so it does not use the site's dark
   palette. Colours come from the --k-* tokens below; base.css tokens are
   left as they are for the public page. One accent colour, for the primary
   button and for errors; everything else is neutral. */
:root {
  color-scheme: light;
  --k-bg: #F4F3F0;          /* page */
  --k-panel: #FFFFFF;       /* fieldsets, header, inputs */
  --k-text: #1A1918;
  --k-text-muted: #55524D;  /* hints, captions: 7.8:1 on white */
  --k-line: #D5D2CB;        /* panel borders */
  --k-field: #77736B;       /* input borders: 4.7:1 on white */
  --k-hover: #E9E7E2;
  --k-accent: #B83A0B;      /* save button and errors: 5.8:1 on white */
  --k-on-accent: #FFFFFF;
  --k-top-h: 63px;          /* header height on wide screens */
}

/* The scrollbar's space is always reserved, so a short page (no scrollbar)
   and a long one lay out at the same width. Without it, switching sections
   moved the centred column by half a scrollbar on wide screens and changed
   its width on narrow ones. No effect where scrollbars overlay the page
   (phones, default macOS). */
html { background: var(--k-bg); scrollbar-gutter: stable; }
body { font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--k-text); background: var(--k-bg); }
a { color: var(--k-text); }

/* ---------- Header ---------- */
.top { position: sticky; top: 0; z-index: 2; background: var(--k-panel); border-bottom: 1px solid var(--k-line); }
/* Title and buttons share a row when they fit; on phones the buttons
   drop to a second row and share its width */
.top-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  max-width: 1180px; min-height: 60px; margin: 0 auto; padding: 8px 16px; }
.top strong { font-size: 18px; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Page list and content ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 16px 24px; }
.side ul { list-style: none; margin: 0; padding: 0; }
/* Two blocks, Contenido and Administración, each under a small heading
   that is a label, not a link */
.side-heading { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--k-text-muted); }
.side a { display: flex; align-items: center; min-height: 48px; font-weight: 600; text-decoration: none; color: var(--k-text); }
.side a:hover { background: var(--k-hover); }
.side a[aria-current] { background: var(--k-text); color: var(--k-panel); font-weight: 700; }
.main { min-width: 0; max-width: 760px; }
.intro { margin: 0 0 16px; color: var(--k-text-muted); }

/* Phones and small tablets: the list is a tab strip under the header that
   scrolls sideways, full width; the current tab is scrolled into view.
   Both blocks share the strip: each starts with its heading as plain text
   before its tabs, and a rule divides the two. */
@media (max-width: 39.99em) {
  .side { margin: 0 -16px; background: var(--k-panel); border-bottom: 1px solid var(--k-line); }
  .side-groups { display: flex; overflow-x: auto; padding: 10px 16px; scrollbar-width: thin; }
  .side-group { flex: none; display: flex; align-items: center; gap: 8px; }
  .side-group + .side-group { margin-left: 16px; padding-left: 16px; border-left: 1px solid var(--k-line); }
  .side-heading { font-size: 12px; }
  .side ul { display: flex; gap: 8px; }
  .side li { flex: none; }
  .side a { min-height: 44px; padding: 0 16px; border: 1px solid var(--k-field); white-space: nowrap; }
  .side a[aria-current] { border-color: var(--k-text); }
}
/* Wider: a sidebar beside the content, staying in view while it scrolls */
@media (min-width: 40em) {
  .shell { display: grid; grid-template-columns: 180px minmax(0, 1fr); column-gap: 32px; }
  .side { position: sticky; top: var(--k-top-h); align-self: start; max-height: calc(100vh - var(--k-top-h)); overflow-y: auto; padding: 24px 0; }
  .side ul { display: grid; gap: 2px; }
  .side a { padding: 0 14px; }
  .side-heading { padding: 0 14px 8px; }
  .side-group + .side-group { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--k-line); }
}

/* ---------- Text and forms ---------- */
h1 { font-size: 28px; line-height: 1.2; margin: 24px 0 6px; }
h2 { font-size: 21px; line-height: 1.25; margin: 0 0 8px; }
fieldset { margin: 0 0 20px; padding: 20px 18px 6px; border: 1px solid var(--k-line); background: var(--k-panel); }
legend { padding: 0 6px; font-size: 19px; font-weight: 700; }
/* A page with one section: the h1 names it, the legend is for screen readers */
legend.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.field { margin-bottom: 18px; }
/* Two short fields side by side (caja_field_pairs()), each with its own label
   and hint. The subgrid lines up label, input, hint and error across the
   pair, so a label that wraps does not push one input below the other. */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); gap: 0 16px; align-items: start; }
.pair > .field { display: grid; grid-row: span 4; grid-template-rows: subgrid; align-content: start; }
label, .label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { display: block; font-size: 15px; color: var(--k-text-muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=time], textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; font: inherit; color: var(--k-text);
  background: var(--k-panel); border: 1px solid var(--k-field); border-radius: 0; }
input[type=file] { max-width: 100%; min-height: 48px; font: inherit; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus, a:focus { outline: 3px solid var(--k-text); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; }
.check input { flex: none; width: 24px; height: 24px; accent-color: var(--k-text); }
.invalid input, .invalid textarea, .invalid select, .row.invalid input { border: 2px solid var(--k-accent); }
.error-text { display: block; color: var(--k-accent); font-size: 15px; margin-top: 4px; font-weight: 700; }
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 15px; color: var(--k-text-muted); }
/* Three columns (tarifas: name, detail, price) */
.row.cols-3, .row-head.cols-3 { grid-template-columns: 2fr 2fr 1fr; }
/* A fixed table with a label per row (tarifas plans: name, price, period,
   note). Four columns need the room: it stacks, as the rows fields do on
   phones, whenever the form is narrower than 640px, whatever the screen
   (the sidebar takes 212px of it from 40em up). */
.table-field { container-type: inline-size; }
.row.cols-4.has-row-label, .row-head.cols-4.has-row-label { grid-template-columns: 4em 2fr 1fr 1.2fr 2.2fr; }
.row.cols-4.has-row-label input { padding-inline: 10px; }
.row-label { align-self: center; font-weight: 600; }
/* Clases: name, description, a Mostrar box. Its column heading names it
   here; stacked, the box shows its own "Mostrar" text. */
.row.cols-3.has-row-label, .row-head.cols-3.has-row-label { grid-template-columns: 5em 1.4fr 3fr 5em; }
.row.cols-3.has-row-label input[type="text"] { padding-inline: 10px; }
.cell-check { align-self: center; justify-content: center; }
.cell-check span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@container (max-width: 640px) {
  .row.cols-3.has-row-label { grid-template-columns: 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--k-line); }
  .row.cols-3.has-row-label input[type="text"] { padding-inline: 14px; }
  .row-head.cols-3.has-row-label { display: none; }
  .rows.cols-3 { gap: 16px; }
  .cell-check { justify-content: flex-start; }
  .cell-check span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .row.cols-4.has-row-label { grid-template-columns: 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--k-line); }
  .row.cols-4.has-row-label input { padding-inline: 14px; }
  .row-head.cols-4 { display: none; }
  .rows.cols-4 { gap: 16px; }
}
.rows input[aria-invalid="true"] { border: 2px solid var(--k-accent); }
/* Timetable: a folding block per day, each row a time and a class */
.tt-edit { margin-top: 8px; border: 1px solid var(--k-field); background: var(--k-panel); }
.tt-edit summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 48px; padding: 8px 14px; cursor: pointer; }
.tt-edit-day { font-weight: 700; }
.tt-edit-count { color: var(--k-text-muted); }
.tt-edit[open] summary { border-bottom: 1px solid var(--k-line); }
.tt-edit-rows { container-type: inline-size; display: grid; gap: 8px; padding: 12px 14px 14px; }
/* The time takes what "09:30" and the browser's clock icon need; the class
   list gets the rest. Stacked only where even that leaves the list too
   narrow for "Baile deportivo" (about a 320px screen). */
.tt-edit-row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; }
.tt-edit-row input[type=time], .tt-edit-row select { padding-inline: 10px; }
.tt-edit-row select { max-width: none; }
@container (max-width: 279px) {
  .tt-edit-row { grid-template-columns: 1fr; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--k-line); }
  .tt-edit-rows { gap: 12px; }
}
.tt-edit-row.invalid input, .tt-edit-row.invalid select { border: 2px solid var(--k-accent); }
select { width: 100%; max-width: 320px; min-height: 48px; padding: 11px 14px; font: inherit; color: var(--k-text);
  background: var(--k-panel); border: 1px solid var(--k-field); border-radius: 0; }

button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 20px;
  font: inherit; font-weight: 700; cursor: pointer; border: 2px solid var(--k-accent); background: var(--k-accent); color: var(--k-on-accent); text-decoration: none; }
button.secondary, .button.secondary { min-height: 44px; border-color: var(--k-text); background: var(--k-panel); color: var(--k-text); }
button.secondary:hover, .button.secondary:hover { background: var(--k-hover); }

/* Save bar: stays at the bottom of the screen while the form scrolls */
.actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 12px 0; background: linear-gradient(rgba(244,243,240,0), var(--k-bg) 30%); }
.unsaved { display: none; font-weight: 700; }
.unsaved::before { content: "● "; }
.is-dirty .unsaved { display: inline; }

.block { margin: 32px 0 20px; padding: 20px 18px 6px; border: 1px solid var(--k-line); background: var(--k-panel); }
.block > .hint:first-of-type { margin: -4px 0 16px; }

.msg { padding: 12px 14px; margin: 16px 0; border: 1px solid var(--k-line); border-left: 5px solid; background: var(--k-panel); }
.msg.error { border-left-color: var(--k-accent); }
.msg.ok { border-left-color: var(--k-text); }
.msg.warning { border-left-color: var(--k-accent); border-left-width: 8px; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }   /* setup screen */

/* Image fields: the current photo above its file input */
.image-now { display: block; width: auto; height: auto; max-width: min(100%, 320px); max-height: 320px; border: 1px solid var(--k-line); background: var(--k-hover); }   /* a tall poster stays 320px tall */
.image-field > .hint:first-of-type { margin: 4px 0 10px; }
.image-field .check { margin-top: 6px; }
pre, .code { white-space: pre-wrap; word-break: break-all; font: 14px/1.5 ui-monospace, Consolas, monospace; }
textarea.code { background: var(--k-bg); }
code, .msg { overflow-wrap: anywhere; } /* long server paths */

@media (max-width: 520px) {
  .top nav { flex: 1 1 100%; }
  .top nav > * { flex: 1 1 auto; }
  .top nav form { display: flex; }
  .top nav .button, .top nav button { flex: 1 1 auto; padding-inline: 10px; }
  .row, .row-head, .row.cols-3, .row-head.cols-3,
  .row.cols-3.has-row-label, .row.cols-4.has-row-label { grid-template-columns: 1fr; }
  .pair, .pair > .field { display: block; }
  /* Stacked inputs: space between rows so each row reads as one */
  .rows.cols-3 { gap: 16px; }
  .rows.cols-4 { gap: 16px; }
  .row-head.cols-3, .row-head.cols-4 { display: none; }   /* the placeholders name the columns */
  .row-head { display: none; }
  .row { padding-bottom: 8px; border-bottom: 1px solid var(--k-line); }
  fieldset, .block { padding-inline: 14px; }
  .tt-edit-rows { padding-inline: 8px; }
}
