/* WP Manager — design tokens from design.md (Airtable system) */
:root {
  /* Colors */
  --primary:        #181d26;
  --primary-active: #0d1218;
  --ink:            #181d26;
  --body:           #333840;
  --muted:          #41454d;
  --hairline:       #dddddd;
  --border-strong:  #9297a0;
  --canvas:         #ffffff;
  --surface-soft:   #f8fafc;
  --surface-strong: #e0e2e6;
  --surface-dark:   #181d26;
  --sig-coral:      #aa2d00;
  --sig-forest:     #0a2e0e;
  --sig-cream:      #f5e9d4;
  --sig-peach:      #fcab79;
  --sig-mint:       #a8d8c4;
  --on-primary:     #ffffff;
  --link:           #1b61c9;
  --link-active:    #1a3866;
  --info:           #254fad;
  --info-border:    #458fff;
  --success:        #006400;
  --success-border: #39bf45;

  /* Spacing — 4px base */
  --s-xxs: 4px; --s-xs: 8px; --s-sm: 12px; --s-md: 16px;
  --s-lg: 24px; --s-xl: 32px; --s-xxl: 48px; --s-section: 96px;

  /* Radii */
  --r-xs: 2px; --r-sm: 6px; --r-md: 10px; --r-lg: 12px;

  /* Fonts */
  --font-text:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--body);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-active); text-decoration: underline; }

code, .code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  color: var(--ink);
}

/* --- Top nav ----------------------------------------------------- */
.nav {
  height: 64px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-xxl);
}
.nav__brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.nav__brand:hover { color: var(--ink); text-decoration: none; }
.nav__links { display: flex; gap: var(--s-lg); align-items: center; }
.nav__links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.nav__links a:hover { color: var(--ink); text-decoration: none; }

/* --- Layout ------------------------------------------------------ */
.container { max-width: 1600px; margin: 0 auto; padding: 0 var(--s-xxl); }
.hero { padding: var(--s-section) 0 var(--s-xxl); }
.section { padding: var(--s-xxl) 0; }
.section--tight { padding: var(--s-lg) 0; }
.section--bottom { padding-bottom: var(--s-section); }

/* --- Typography helpers ----------------------------------------- */
.display-lg {
  font-family: var(--font-display);
  font-size: 40px; font-weight: 400; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--ink); margin: 0;
}
.display-md {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 400; line-height: 1.15;
  letter-spacing: -0.01em; color: var(--ink); margin: 0;
}
.title-lg {
  font-size: 24px; font-weight: 400; line-height: 1.35;
  letter-spacing: 0.12px; color: var(--ink); margin: 0;
}
.title-md {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 500; line-height: 1.4;
  color: var(--ink); margin: 0;
}
.caption {
  font-size: 14px; font-weight: 500; line-height: 1.35;
  letter-spacing: 0.16px; color: var(--muted);
}
.muted { color: var(--muted); }
.eyebrow {
  font-size: 13px; font-weight: 500; letter-spacing: 0.16px;
  text-transform: uppercase; color: var(--muted);
}

/* --- Section heading ------------------------------------------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-md);
  margin: var(--s-xxl) 0 var(--s-md);
}
.section-head__title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 400; line-height: 1.35;
  letter-spacing: -0.01em; color: var(--ink); margin: 0;
}
.section-head__count { color: var(--muted); font-weight: 400; }

/* --- Buttons --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-xs);
  padding: 14px 22px;
  border-radius: var(--r-lg);
  font-family: var(--font-text);
  font-size: 16px; font-weight: 500; line-height: 1.4;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.btn--primary:active:not(:disabled) {
  background: var(--primary-active);
  border-color: var(--primary-active);
}
.btn--danger {
  background: var(--canvas);
  color: var(--sig-coral);
  border-color: var(--sig-coral);
}
.btn--danger:active:not(:disabled) {
  background: var(--sig-coral);
  color: var(--on-primary);
}
.btn--sm {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: var(--r-sm);
}
.btn__label { display: inline-flex; align-items: center; gap: 6px; }
.btn__label svg { flex-shrink: 0; }
.btn.is-loading { position: relative; pointer-events: none; }
.btn.is-loading > .btn__label { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: wpm-spin 0.7s linear infinite;
}
@keyframes wpm-spin { to { transform: rotate(360deg); } }
.row-done { animation: wpm-flash 1.2s ease; }
@keyframes wpm-flash {
  0%   { background-color: rgba(0,100,0,0.12); }
  100% { background-color: transparent; }
}
.spinner-inline {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: wpm-spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -1px;
  opacity: 0.6;
}
.row-pending td { background: var(--surface-soft); }
.row-pending .cell-mono { color: var(--ink); }
.row-new { animation: wpm-newrow 1.6s ease; }
@keyframes wpm-newrow {
  0%   { background-color: rgba(0,100,0,0.16); }
  100% { background-color: transparent; }
}

/* --- Inputs ---------------------------------------------------- */
.input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.25;
}
.input:focus { outline: none; border-color: var(--info-border); }
.input--search { max-width: 480px; }

/* --- Stats ----------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-md);
}
.stat {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--s-lg);
}
.stat__n {
  font-family: var(--font-display);
  font-size: 40px; font-weight: 400; line-height: 1.05;
  letter-spacing: -0.02em; color: var(--ink); margin: 0;
}
.stat__l {
  font-size: 14px; font-weight: 500; letter-spacing: 0.16px;
  color: var(--muted); margin-top: var(--s-xs);
}
.stat--accent .stat__n { color: var(--sig-coral); }

/* --- Tables ---------------------------------------------------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
}
.tbl th, .tbl td {
  padding: 14px var(--s-lg);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--hairline);
}
.tbl th {
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.16px;
  color: var(--muted);
  background: var(--canvas);
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-soft); }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl th.is-sortable { cursor: pointer; user-select: none; padding-right: 1.6em; position: relative; }
.tbl th.is-sortable:hover { color: var(--ink); }
.tbl th.is-sortable::after { content: ""; position: absolute; right: 0.6em; top: 50%; transform: translateY(-50%); opacity: 0.25; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid currentColor; }
.tbl th.is-sorted-asc::after { opacity: 1; border-bottom: 5px solid var(--ink); border-top: 0; }
.tbl th.is-sorted-desc::after { opacity: 1; border-top: 5px solid var(--ink); border-bottom: 0; }
.tbl td.is-actions { text-align: right; white-space: nowrap; }
.tbl td.cell-detail { overflow-wrap: anywhere; word-break: break-word; }
.tbl td.cell-detail .badge { white-space: normal; }

.cell-title  { font-weight: 500; color: var(--ink); }
.cell-sub    { font-size: 13px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.cell-mono   { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }

/* --- Badges ---------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; line-height: 1.3;
  letter-spacing: 0.16px; white-space: nowrap;
  margin-right: 4px;
  border: 1px solid transparent;
}
.badge--ok    { background: rgba(0,100,0,0.08);    color: var(--success); }
.badge--warn  { background: rgba(170,45,0,0.08);   color: var(--sig-coral); }
.badge--err   { background: var(--sig-coral);      color: var(--on-primary); }
.badge--off   { background: var(--surface-soft);   color: var(--muted); border-color: var(--hairline); }
.badge--info  { background: rgba(37,79,173,0.08);  color: var(--info); }
.badge--neutral { background: var(--surface-soft); color: var(--ink); border-color: var(--hairline); }

/* --- Alerts ---------------------------------------------------- */
.alert {
  padding: var(--s-md) var(--s-lg);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  font-size: 14px;
  margin-bottom: var(--s-md);
}
.alert--err {
  background: rgba(170,45,0,0.04);
  color: var(--sig-coral);
  border-color: rgba(170,45,0,0.25);
}
.alert--ok {
  background: rgba(0,100,0,0.04);
  color: var(--success);
  border-color: rgba(0,100,0,0.25);
}

/* --- Signature cards ------------------------------------------- */
.sig {
  border-radius: var(--r-lg);
  padding: var(--s-xxl);
}
.sig--coral  { background: var(--sig-coral);  color: var(--on-primary); }
.sig--forest { background: var(--sig-forest); color: var(--on-primary); }
.sig--dark   { background: var(--surface-dark); color: var(--on-primary); }
.sig--cream  { background: var(--sig-cream); color: var(--ink); border-radius: var(--r-md); padding: var(--s-lg); }
.sig h3, .sig .title-md, .sig .display-md { color: inherit; }

/* --- Definition list ------------------------------------------- */
.dl {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s-md) var(--s-lg);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--s-lg) var(--s-xl);
  background: var(--canvas);
}
.dl dt {
  font-size: 13px; font-weight: 500; letter-spacing: 0.16px;
  color: var(--muted); margin: 0;
}
.dl dd { margin: 0; font-size: 14px; color: var(--ink); word-break: break-word; }

/* dl a dos columnas de pares etiqueta/valor (site.php · Información).
   ≤1100px vuelve a una columna de pares; ≤768px hereda el apilado total de .dl */
.dl--2col { grid-template-columns: 170px 1fr 170px 1fr; }
@media (max-width: 1100px) {
  .dl--2col { grid-template-columns: 200px 1fr; }
}

/* --- Action row ------------------------------------------------ */
.actions {
  display: flex; flex-wrap: wrap; gap: var(--s-sm);
  margin: var(--s-md) 0 0;
}

/* --- Login ----------------------------------------------------- */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-xxl);
  background: var(--canvas);
}
.login__form { width: 100%; max-width: 380px; }
.login__title { margin: 0 0 var(--s-xs); }
.login__sub { margin: 0 0 var(--s-xl); }
.login__form .input { margin-bottom: var(--s-sm); }
.login__form .btn  { width: 100%; }

/* --- Progress widget ------------------------------------------ */
.progress {
  position: fixed;
  bottom: var(--s-lg);
  right: var(--s-lg);
  width: 400px;
  max-width: calc(100vw - var(--s-xxl));
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--s-lg);
  box-shadow: 0 12px 28px rgba(24,29,38,0.08), 0 2px 6px rgba(24,29,38,0.04);
  display: none;
  z-index: 100;
}
.progress.is-visible { display: block; }
.progress__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--s-md);
  margin-bottom: var(--s-sm);
}
.progress__title {
  font-size: 14px; font-weight: 500; color: var(--ink);
  margin: 0; word-break: break-word; padding-right: var(--s-lg);
}
.progress__status {
  font-size: 11px; font-weight: 500; letter-spacing: 0.16px;
  color: var(--muted); text-transform: uppercase; white-space: nowrap;
}
.progress__bar {
  height: 4px; background: var(--surface-soft);
  border-radius: var(--r-xs); overflow: hidden;
}
.progress__fill {
  height: 100%; width: 0; background: var(--primary);
  transition: width 0.4s ease, background 0.2s ease;
}
.progress__msg {
  font-size: 13px; color: var(--muted);
  margin-top: var(--s-sm); min-height: 1em; word-break: break-word;
}
.progress__close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: 0; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px; line-height: 1;
}
.progress__close:hover { color: var(--ink); }

/* Stack de widgets — soporta varios auto-flows en paralelo */
.wpm-stack {
  position: fixed;
  bottom: var(--s-lg);
  right: var(--s-lg);
  display: flex;
  flex-direction: column-reverse; /* el más reciente aparece arriba; el resto se acumula hacia abajo */
  gap: var(--s-sm);
  z-index: 100;
  width: 400px;
  max-width: calc(100vw - var(--s-xxl));
  max-height: calc(100vh - var(--s-section));
  overflow-y: auto;
  pointer-events: none;
}
.wpm-stack > * { pointer-events: auto; }
.wpm-stack .progress {
  /* relative (no static) para que el ⏱ timer y el botón × (position:absolute)
     se posicionen dentro de CADA widget y no escapen al contenedor del stack. */
  position: relative;
  width: auto;
  max-width: none;
  bottom: auto;
  right: auto;
}

/* --- Responsive ------------------------------------------------ */
@media (max-width: 768px) {
  .container { padding: 0 var(--s-lg); }
  .nav { padding: 0 var(--s-lg); }
  .hero { padding: var(--s-xxl) 0 var(--s-lg); }
  .display-lg { font-size: 32px; }
  .display-md { font-size: 24px; }
  .dl { grid-template-columns: 1fr; gap: var(--s-xs) 0; }
  .dl dt { padding-top: var(--s-sm); }
  .tbl th, .tbl td { padding: 12px var(--s-md); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat__n { font-size: 28px; }
  .progress { left: var(--s-md); right: var(--s-md); width: auto; bottom: var(--s-md); }
}
