/* ═══════════════════════════════════════════════════════════════════
   SIG 1.0 — sistema de diseño "Sello"
   Marca Unitrópico: verde PANTONE 329 (#00594E) + bronce PANTONE 4515 (#B5A160)
   Tipografía: Montserrat (títulos) · Raleway (cuerpo) · IBM Plex Mono (códigos)
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* marca */
  --verde:        #00594E;
  --verde-2:      #0B7A6B;
  --verde-deep:   #00332C;
  --verde-ink:    #071F1B;
  --bronce:       #B5A160;
  --bronce-2:     #D8C07C;
  --bronce-deep:  #7A6A38;

  /* superficies (papel con sesgo verde: institucional, no gris) */
  --bg:           #F3F6F4;
  --bg-2:         #E9EFEC;
  --surface:      #FFFFFF;
  --surface-2:    #F7FAF8;
  --line:         rgba(0, 89, 78, .14);
  --line-strong:  rgba(0, 89, 78, .28);

  /* texto */
  --ink:          #10211E;
  --ink-2:        #2E413D;
  --muted:        #5B6B67;
  --muted-2:      #8A9793;
  --on-verde:     #F3F6F4;

  /* acento en uso */
  --accent:       var(--verde);
  --accent-ink:   var(--on-verde);
  --gold:         var(--bronce);
  --gold-ink:     var(--verde-ink);
  --gold-text:    var(--bronce-deep);   /* bronce como TEXTO sobre superficies claras (5,9:1) */
  --focus:        #1EA89A;

  /* semántico (independiente del acento) */
  --ok:           #1F7A4D;
  --ok-bg:        #E4F3EA;
  --warn:         #9A6B00;
  --warn-bg:      #FBF1D6;
  --bad:          #A83232;
  --bad-bg:       #F9E3E3;
  --info:         #2C5F8A;
  --info-bg:      #E3EEF8;

  /* tipos por prefijo (paleta de la comunidad universitaria: series, no acento) */
  --t-FR: #00594E; --t-PR: #006AB4; --t-CP: #B5A160; --t-IN: #7DC189;
  --t-GU: #9E9E22; --t-MN: #005469; --t-PT: #F59D15; --t-PLL: #AB806E;

  /* tipografía */
  --f-display: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --f-body:    "Raleway", "Segoe UI", system-ui, sans-serif;
  --f-mono:    "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --fs-0: .78rem; --fs-1: .875rem; --fs-2: 1rem; --fs-3: 1.125rem; --fs-4: 1.375rem;
  --fs-5: 1.75rem; --fs-6: 2.25rem; --fs-7: clamp(2.4rem, 5vw, 3.6rem);

  --r-1: 6px; --r-2: 10px; --r-3: 16px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(7, 31, 27, .06), 0 1px 1px rgba(7, 31, 27, .04);
  --sh-2: 0 8px 24px -8px rgba(7, 31, 27, .18), 0 2px 6px rgba(7, 31, 27, .06);
  --sh-3: 0 24px 48px -16px rgba(7, 31, 27, .28);

  --w-max: 1180px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1B18; --bg-2: #0F2622; --surface: #12302A; --surface-2: #163A33;
    --line: rgba(216, 192, 124, .14); --line-strong: rgba(216, 192, 124, .30);
    --ink: #EEF3F0; --ink-2: #CDD9D4; --muted: #9DB0A9; --muted-2: #6F8580;
    --on-verde: #EEF3F0;
    --accent: #1EA89A; --accent-ink: #071F1B;
    --gold: #D8C07C; --gold-ink: #071F1B; --gold-text: #D8C07C;
    --ok: #6CCB94; --ok-bg: rgba(108, 203, 148, .14);
    --warn: #E9B949; --warn-bg: rgba(233, 185, 73, .14);
    --bad: #F08A8A; --bad-bg: rgba(240, 138, 138, .14);
    --info: #7FB3E0; --info-bg: rgba(127, 179, 224, .14);
    --t-FR: #4FC0B1; --t-PR: #6FB4EE; --t-CP: #D8C07C; --t-IN: #8FD9A1;
    --t-GU: #C8C84C; --t-MN: #6FBFD8; --t-PT: #F5B04E; --t-PLL: #D2A48F;
    --sh-1: 0 1px 2px rgba(0,0,0,.35); --sh-2: 0 8px 24px -8px rgba(0,0,0,.5); --sh-3: 0 24px 48px -16px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1B18; --bg-2: #0F2622; --surface: #12302A; --surface-2: #163A33;
  --line: rgba(216, 192, 124, .14); --line-strong: rgba(216, 192, 124, .30);
  --ink: #EEF3F0; --ink-2: #CDD9D4; --muted: #9DB0A9; --muted-2: #6F8580;
  --on-verde: #EEF3F0;
  --accent: #1EA89A; --accent-ink: #071F1B;
  --gold: #D8C07C; --gold-ink: #071F1B; --gold-text: #D8C07C;
  --ok: #6CCB94; --ok-bg: rgba(108, 203, 148, .14);
  --warn: #E9B949; --warn-bg: rgba(233, 185, 73, .14);
  --bad: #F08A8A; --bad-bg: rgba(240, 138, 138, .14);
  --info: #7FB3E0; --info-bg: rgba(127, 179, 224, .14);
  --t-FR: #4FC0B1; --t-PR: #6FB4EE; --t-CP: #D8C07C; --t-IN: #8FD9A1;
  --t-GU: #C8C84C; --t-MN: #6FBFD8; --t-PT: #F5B04E; --t-PLL: #D2A48F;
  --sh-1: 0 1px 2px rgba(0,0,0,.35); --sh-2: 0 8px 24px -8px rgba(0,0,0,.5); --sh-3: 0 24px 48px -16px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ── base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: var(--fs-2); line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: var(--fs-7); font-weight: 800; }
h2 { font-size: var(--fs-6); font-weight: 700; }
h3 { font-size: var(--fs-4); font-weight: 700; }
h4 { font-size: var(--fs-3); font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
::selection { background: var(--bronce-2); color: var(--verde-ink); }
code, .mono { font-family: var(--f-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: min(100% - 2.5rem, var(--w-max)); margin-inline: auto; }
.eyebrow { font-family: var(--f-display); font-size: var(--fs-0); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-text); }
.lede { font-size: var(--fs-3); color: var(--ink-2); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-1); }

/* ── barra superior ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px) saturate(1.2); -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar__in { display: flex; align-items: center; gap: 1.25rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); font-family: var(--f-display); font-weight: 800; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 38px; height: 38px; border-radius: 50%; background: var(--verde); display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 2px var(--bronce-2); }
.brand__mark img { width: 34px; height: 34px; object-fit: cover; }
.brand__name { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name small { font-family: var(--f-body); font-weight: 600; font-size: var(--fs-0); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.brand__ver { font-family: var(--f-mono); font-size: .7rem; color: var(--gold-text); border: 1px solid var(--line-strong); padding: .1rem .4rem; border-radius: var(--r-pill); margin-left: .35rem; }
.nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.nav a { color: var(--ink-2); font-weight: 600; font-size: var(--fs-1); padding: .5rem .8rem; border-radius: var(--r-pill); }
.nav a:hover, .nav a[aria-current="page"] { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--gold); border-radius: var(--r-1); }
@media (max-width: 760px) { .nav a:not(.nav__keep) { display: none; } }

/* ── botones ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem; border-radius: var(--r-2); border: 1px solid transparent;
  font-family: var(--f-display); font-weight: 700; font-size: var(--fs-1); line-height: 1;
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--sh-1); }
.btn--primary:hover { box-shadow: var(--sh-2); }
.btn--gold { background: var(--gold); color: var(--gold-ink); }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--bg-2); }
.btn--quiet { background: var(--bg-2); color: var(--ink); }
.btn--sm { padding: .45rem .8rem; font-size: var(--fs-0); border-radius: var(--r-1); }
.btn--icon { padding: .55rem; width: 40px; height: 40px; border-radius: var(--r-2); }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

/* ── código documental: el objeto tipográfico del SIG ─────────────── */
.code { font-family: var(--f-mono); font-weight: 500; letter-spacing: .01em; white-space: nowrap; display: inline-flex; align-items: baseline; }
.code .c-tipo { color: var(--gold); font-weight: 600; }
.code .c-sep  { color: var(--muted-2); }
.code .c-proc { color: var(--ink); }
.code .c-num  { color: var(--ink); }
.code .c-ver  { color: var(--accent); font-weight: 600; }
.code--lg { font-size: var(--fs-4); }
.code--xl { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 600; letter-spacing: 0; }

/* ── chips / pills ────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: var(--r-pill); font-family: var(--f-display); font-size: var(--fs-0); font-weight: 700; letter-spacing: .02em; line-height: 1.3; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.chip--tipo { color: var(--surface); border-color: transparent; }
.chip--tipo[data-tipo="FR"]  { background: var(--t-FR); }  .chip--tipo[data-tipo="PR"] { background: var(--t-PR); }
.chip--tipo[data-tipo="CP"]  { background: var(--t-CP); color: var(--verde-ink); }  .chip--tipo[data-tipo="IN"] { background: var(--t-IN); color: var(--verde-ink); }
.chip--tipo[data-tipo="GU"]  { background: var(--t-GU); }  .chip--tipo[data-tipo="MN"] { background: var(--t-MN); }
.chip--tipo[data-tipo="PT"]  { background: var(--t-PT); color: var(--verde-ink); }  .chip--tipo[data-tipo="PLL"] { background: var(--t-PLL); }
.chip--ok   { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip--warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip--bad  { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip--info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip--gold { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--bronce-deep); border-color: transparent; }
:root[data-theme="dark"] .chip--gold { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip--gold { color: var(--gold); } }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* estado del documento: forma + color */
.estado { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--f-display); font-weight: 700; font-size: var(--fs-0); letter-spacing: .04em; text-transform: uppercase; }
.estado::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.estado--vigente { color: var(--ok); }
.estado--obsoleto, .estado--retirada { color: var(--bad); }
.estado--borrador, .estado--en_revision { color: var(--warn); }
.estado--reemplazada { color: var(--muted); }

/* ── campos ───────────────────────────────────────────────────────── */
.field { display: grid; gap: .35rem; }
.field label { font-family: var(--f-display); font-weight: 700; font-size: var(--fs-0); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: .7rem .85rem; border-radius: var(--r-2); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
.hint { font-size: var(--fs-0); color: var(--muted); }

/* ── superficies ──────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--sh-1); }
.panel__hd { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.panel__hd h3 { font-size: var(--fs-2); }
.panel__bd { padding: 1.25rem; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* fichas de resultado */
.doc-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: .9rem 1rem; align-items: center;
  padding: .85rem 1rem; border-radius: var(--r-2); color: inherit; text-decoration: none;
  border: 1px solid transparent; transition: background .12s, border-color .12s, transform .12s var(--ease);
}
.doc-row:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; transform: translateX(2px); }
.doc-row__code { font-family: var(--f-mono); font-size: var(--fs-1); min-width: 8.5em; }
.doc-row__title { font-weight: 600; color: var(--ink); line-height: 1.3; }
.doc-row__meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: var(--fs-0); color: var(--muted); margin-top: .15rem; }
.doc-row__right { display: flex; align-items: center; gap: .5rem; }
.fmt { font-family: var(--f-mono); font-size: .7rem; font-weight: 600; letter-spacing: .06em; padding: .15rem .45rem; border-radius: var(--r-1); border: 1px solid var(--line-strong); color: var(--ink-2); }

/* ── toasts ───────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 120; display: grid; gap: .5rem; max-width: min(92vw, 380px); }
.toast { background: var(--verde-deep); color: var(--on-verde); padding: .8rem 1rem; border-radius: var(--r-2); box-shadow: var(--sh-3); font-size: var(--fs-1); border-left: 4px solid var(--gold); animation: toast-in .25s var(--ease); }
.toast--bad { border-left-color: #F08A8A; }
.toast--ok { border-left-color: #6CCB94; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── modal ────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal[open], .modal.is-open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(7, 31, 27, .55); backdrop-filter: blur(3px); }
.modal__dialog { position: relative; width: min(100%, 560px); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: var(--r-3); box-shadow: var(--sh-3); border: 1px solid var(--line); animation: modal-in .2s var(--ease); }
.modal__hd { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem; }
.modal__hd h3 { font-size: var(--fs-3); flex: 1; }
.modal__bd { padding: 1.25rem; display: grid; gap: 1rem; }
.modal__ft { padding: 1rem 1.25rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── skeleton ─────────────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface-2) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: skel 1.2s linear infinite; border-radius: var(--r-1); min-height: 1em; }
@keyframes skel { to { background-position: -200% 0; } }

/* ── pie ──────────────────────────────────────────────────────────── */
.footer { margin-top: 5rem; padding: 2.5rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-1); }
.footer__in { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between; }
.footer strong { color: var(--ink); font-family: var(--f-display); }

/* ── móvil: la barra superior no puede desbordar ──────────────────── */
@media (max-width: 560px) {
  .topbar__in { gap: .5rem; }
  .brand__ver { display: none; }
  .brand__name small { display: none; }
  .nav { gap: .15rem; }
  .nav a.nav__keep { padding: .5rem .55rem; }
  #session [data-login] span { display: none; }
}

/* estados añadidos en el sprint 2 */
.estado--eliminado, .estado--colision { color: var(--bad); }
/* el Oso vive abajo a la derecha: los avisos van a la izquierda */
.toasts { left: 1rem; right: auto; }
@media (max-width: 360px) {
  .brand__name { display: none; }
  .nav a.nav__keep { padding: .5rem .45rem; }
}
/* pantallas estrechas: la fila de documento se reorganiza en dos líneas */
@media (max-width: 560px) {
  .doc-row { grid-template-columns: auto minmax(0, 1fr); }
  .doc-row__right { grid-column: 1 / -1; justify-content: flex-start; }
  .doc-row__code { min-width: 0; }
  .search__hints { max-width: 100%; }
}

/* ── sesión en la barra (compartido por todas las vistas) ─────────── */
.session { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-1); font-weight: 600; }
.session__pic { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.session__name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .session__name { display: none; } }
@media (max-width: 420px) { .session .chip { display: none; } .nav { gap: .05rem; } .topbar__in { gap: .35rem; } }

/* ── menú compacto en móvil: los enlaces que no caben van a un desplegable ── */
.nav__more { display: none; }
.nav__drop { display: none; position: absolute; right: 1rem; top: calc(100% + .25rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-2); box-shadow: var(--sh-2); padding: .35rem; min-width: 190px; z-index: 60; }
.nav__drop.is-open { display: grid; gap: .1rem; }
.nav__drop a { display: block; padding: .6rem .8rem; border-radius: var(--r-1); color: var(--ink); font-weight: 600; font-size: var(--fs-1); }
.nav__drop a:hover { background: var(--bg-2); text-decoration: none; }
@media (max-width: 640px) {
  .topbar__in { position: relative; }
  .nav a.nav__hide-sm { display: none; }
  .nav__more { display: inline-flex; }
}
