/* ============================================================
   Puenteceso S.D. — Shared design-system layer
   Canonical component variants and layout primitives loaded by
   every layout, before the surface-specific stylesheets.
   Base component styles (`.btn`, typography, tokens) live in
   styles.css; this layer only adds the variants/classes that
   were previously used without a definition.
   ============================================================ */

/* ---------- Focus ring ---------- */
:root {
  --focus-ring: var(--brand-500);

  /* Page title: one size for every page head (.in-page-head); smaller on phones. */
  --title-page: 32px;

  /* Buttons: the intranet dashboard look (42px, 4px radius) is the standard for the whole web.
     Shape, size and colour live here so they change in one place. */
  --btn-radius: 4px;
  --seg-height: 32px;
  --btn-height: 42px;
  --btn-height-sm: 38px;
  --btn-pad-x: 16px;
  --btn-primary-bg: var(--brand-blue);
  --btn-primary-bg-hover: var(--brand-navy-deep);
  --btn-outline-fg: var(--brand-navy);
  --btn-outline-border: var(--border-input);
  --btn-outline-hover-bg: #EEF3F9;
}
@media (max-width: 640px) { :root { --title-page: 26px; } }
[data-theme="dark"] {
  --btn-outline-fg: var(--fg);
  --btn-outline-border: var(--border-strong);
  --btn-outline-hover-bg: var(--surface-alt);
}
:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
/* Base shape (.btn) and the size modifiers are in styles.css; variants here. */
.btn svg { flex: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-filled {
  background: var(--btn-primary-bg);
  color: #fff;
  border-color: var(--btn-primary-bg);
}
.btn-filled:hover { background: var(--btn-primary-bg-hover); border-color: var(--btn-primary-bg-hover); color: #fff; }

.btn-tonal {
  background: var(--surface-alt);
  color: var(--fg);
  border-color: var(--border);
}
.btn-tonal:hover { background: var(--border); }

/* Secondary action on a light surface (white fill + border). */
.btn-outline {
  background: var(--surface);
  color: var(--btn-outline-fg);
  border-color: var(--btn-outline-border);
}
.btn-outline:hover { background: var(--btn-outline-hover-bg); color: var(--btn-outline-fg); }

/* Destructive actions: solid, or outlined for a quieter placement. */
.btn-danger {
  background: var(--accent-red-deep);
  color: #fff;
  border-color: var(--accent-red-deep);
}
.btn-danger:hover { background: color-mix(in oklab, var(--accent-red-deep) 82%, #000); border-color: color-mix(in oklab, var(--accent-red-deep) 82%, #000); color: #fff; }
.btn-danger-ghost {
  background: transparent;
  color: var(--accent-red-deep);
  border-color: var(--accent-red-deep);
}
.btn-danger-ghost:hover { background: color-mix(in oklab, var(--accent-red-deep) 10%, transparent); }
[data-theme="dark"] .btn-danger-ghost { color: var(--accent-red); border-color: var(--accent-red); }
[data-theme="dark"] .btn-danger-ghost:hover { background: color-mix(in oklab, var(--accent-red) 14%, transparent); }

/* Icon-only button (square, same height as the text buttons) and full-width button. */
.btn-icon { width: var(--btn-height); padding: 0; }
.btn-icon.btn-sm { width: var(--btn-height-sm); }
.btn-full { width: 100%; }

/* ---------- Modal ---------- */
/* Pages add/remove `.open` on the backdrop; behaviour (Esc, focus, scroll lock,
   dialog semantics) is in modal.js. A modal sets its own width inline
   (style="max-width:420px"); the default is 520px. The blur, the fade/rise
   animation, the border and the round close button are the look the web already
   had; this is now their only definition. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn 200ms ease;
}
.modal-backdrop.open { display: flex; }
html.has-modal { overflow: hidden; }

.modal {
  position: relative;
  box-sizing: border-box;
  width: 94%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: rise 240ms cubic-bezier(0.2, 0.6, 0.2, 1);
}
.modal h2 { margin: 0; font-size: 20px; font-weight: 700; }
.modal h3 { margin: 0; font-size: 20px; font-weight: 700; }
.modal .modal-sub { margin: 4px 0 20px; color: var(--fg-muted); font-size: 13px; }
.modal .close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal .close:hover { color: var(--fg); background: var(--surface-alt); }
/* Buttons inside a modal share the row (a single one fills it). */
.modal .btn { width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { animation: none; }
}

/* ---------- Cards ---------- */
.card-outlined {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
}

.card-elev {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

/* ---------- Layout primitives ---------- */
.col { min-width: 0; }

/* ---------- Accessibility ---------- */
/* Skip link: first thing a keyboard user reaches; jumps over the menu to <main>. */
.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 10000;
  padding: 10px 16px;
  border-radius: var(--btn-radius);
  background: var(--btn-primary-bg);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }
/* <main> is focused programmatically by the skip link; no ring around the whole page. */
main[tabindex="-1"]:focus-visible { outline: none !important; }

/* Keyboard focus ring. Many component rules remove the outline (`outline: none`)
   and rely on a border colour that is hard to see, so this one wins over them.
   Only keyboard focus shows it (:focus-visible); mouse clicks stay clean. */
:is(a, button, input, select, textarea, summary, [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--brand-500) !important;
  outline-offset: 2px;
}
:is(input, select, textarea):focus-visible { outline-offset: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* A loading spinner must keep turning, only slower. */
  .rf-spinner, [class*="spinner"] { animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
}

/* ---------- Segmented control (.seg) and filter chips (.chip-btn) ---------- */
/* .seg: one pill holding the options; the active one floats. Used for a single
   choice that filters or sorts a list (status, payment method, order). */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 100px; background: var(--surface-alt); }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--seg-height); padding: 0 14px;
  border: none; border-radius: 100px; background: transparent; color: var(--fg-muted);
  font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.active, .seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
.seg-btn .badge-count { font-size: 11px; opacity: .8; }

/* .chip-btn: an outlined pill in a row of independent choices (teams, categories,
   groups). Selected = tinted with the brand colour. */
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 100px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg-muted);
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip-btn:hover { background: var(--surface-alt); color: var(--fg); }
.chip-btn.active, .chip-btn[aria-pressed="true"] {
  border-color: var(--brand-500);
  background: color-mix(in oklab, var(--brand-500) 10%, var(--surface));
  color: var(--brand-text);
}
.chip-btn .count { font-size: 11px; opacity: .75; }
