/* Sistema de diseño compartido del backoffice — mismos tokens que
   contenidos/assets/styles.css (duplicado a propósito: son dos proyectos
   de Pages independientes, sin paso de build que permita compartirlo),
   más componentes de tabla/dashboard que contenidos no necesita. */

/* ── TOKENS (light) ─────────────────────────── */
:root {
  /* New canonical tokens */
  /* Los mismos tres valores que shell.css y que dashboard.css: marca.md pide que
     las pantallas compartan la rampa para que pasar de una a otra no se lea como
     cambiar de producto. El #f0f0ee de antes ademas era un gris CALIDO --la crema
     que esa misma pasada quito del alumnado-- y dejaba el rojo de marca en 4,45:1
     encima, por debajo del 4,5 que marca.md fija justo para este plano. Con
     #F1F2F5 sale 4,54. */
  --bg:            #f4f5f7;
  --surface:       #ffffff;
  --surface-2:     #f1f2f5;
  --border:        #d0d4da;
  --text-primary:  #16181d;
  --text-muted:    #63656c;   /* el de la plataforma: 5,34:1 sobre el fondo; el #6b7280 anterior se quedaba en 4,43 */
  /* El rojo de marca, el mismo que el resto de la plataforma. `--accent` es el
     tono del tema (texto, bordes); `--accent-solido` es el que va DEBAJO de
     texto blanco y vale #dd0b16 en los dos temas, porque con el tono oscuro el
     blanco se queda en 3,87:1. Blanco sobre #dd0b16 da 5,08:1. */
  --accent:        #dd0b16;
  --accent-solido: #dd0b16;
  --accent-light:  rgba(221, 11, 22, .07);
  --accent-muted:  rgba(221, 11, 22, .13);
  --success-text:  #15803d;
  --success-bg:    #f0fdf4;
  --danger-text:   #b91c1c;
  --danger-bg:     #fef2f2;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Legacy aliases — mantienen compatibilidad con el CSS existente */
  --color-bg:           var(--bg);
  --color-surface:      var(--surface);
  --color-text:         var(--text-primary);
  --color-muted:        var(--text-muted);
  --color-border:       var(--border);
  --color-accent:       var(--accent);
  --color-accent-hover: #a80811;   /* el rojo profundo de marca */
  --color-accent-soft:  var(--accent-light);
  --color-accent-muted: var(--accent-muted);
  --color-success:      var(--success-text);
  --color-success-soft: var(--success-bg);
  --color-danger:       var(--danger-text);
  --color-danger-soft:  var(--danger-bg);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, .10);
  --font-sans: var(--font);
}

/* ── TOKENS (dark) ──────────────────────────── */
html.dark {
  /* Rampa oscura de la plataforma (contenidos/assets/shell.css). La de antes era
     mas clara y calida, y sobre ella el rojo no llegaba al minimo de contraste:
     el #c84b4b daba 3,79 / 3,38 / 3,04 sobre bg / surface / surface-2, cuando
     hacen falta 4,5. Con esta rampa y #f5333d sale 4,95 / 4,70 / 4,52. */
  --bg:            #0f0f10;
  --surface:       #151519;
  --surface-2:     #19191e;
  --border:        #52525a;
  --text-primary:  #f2f2f4;
  --text-muted:    #8e9098;
  --accent:        #f5333d;
  --accent-solido: #dd0b16;
  --accent-light:  rgba(245, 51, 61, .12);
  --accent-muted:  rgba(245, 51, 61, .20);
  --success-text:  #4ade80;
  --success-bg:    #1a2e20;
  --danger-text:   #f87171;
  --danger-bg:     #2a1515;
  --color-accent-hover: #dd0b16;   /* el solido: sigue dando 5,08:1 al blanco */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .4);
}

*, *::before, *::after {
  box-sizing: border-box;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}
.site-header .brand-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.site-header .brand-logo img {
  height: 20px;
  width: auto;
  border-radius: 4px;
  display: block;
}
.site-header .brand {
  font-weight: 700;
  font-size: 0.93rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Site nav ── */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.site-header a.nav-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.site-header a.nav-link:hover,
.site-header a.nav-link.active {
  color: var(--text-primary);
  background: var(--surface-2);
}
.site-header a.nav-link.active {
  font-weight: 600;
}

/* ── Theme toggle ── */
.theme-toggle {
  flex-shrink: 0;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--accent-solido); color: white; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-ghost:hover { background: var(--surface-2); }

/* ── Inputs ── */
.input, select.input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
}
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ── Typography ── */
.page-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 24px; }
.section-title { font-size: 0.95rem; font-weight: 600; margin: 0 0 14px; }

/* ── Data table ── */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data-table th, table.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface-2);
}
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-success { background: var(--success-bg); border-color: #bbf7d0; color: var(--success-text); }
.badge-pending { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }

.empty-state { color: var(--text-muted); font-size: 0.88rem; padding: 8px 0; }

/* ==================== Campanita de avisos (backoffice) ==================== */
/* Se integra con la cabecera que ya existe: mismos tokens, mismo acento
   (--accent). Lo unico propio es --notif-muted, porque el --text-muted global
   se queda en 2.70:1 sobre --surface en tema oscuro y aqui hay texto pequeno
   (cabeceras de grupo, linea de detalle) que tiene que llegar a 4.5:1. */
.notif-bell-wrap {
  --notif-muted: #5b6270;              /* 6.13:1 sobre --surface, 5.37:1 sobre --surface-2 */
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
html.dark .notif-bell-wrap { --notif-muted: #a8a6a2; }  /* 6.40:1 sobre --surface */

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--notif-muted);
  padding: 5px 8px;
  line-height: 1;
  cursor: pointer;
}
.notif-bell:hover { border-color: var(--accent); color: var(--text-primary); }
.notif-bell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-solido);
  color: #fff;                         /* 5.08:1 en los dos temas: el solido no cambia */
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-sizing: border-box;
}
.notif-badge[hidden] { display: none; }
/* El aviso de "no se ha podido cargar la cola" no puede parecer un pendiente
   mas: cambia de color y de texto (!), para no confundirlo con un numero. */
.notif-badge.notif-badge-error { background: var(--danger-text); color: #fff; }
html.dark .notif-badge.notif-badge-error { color: #16181d; }  /* 6.42:1 sobre #f87171 */

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 20;                         /* por encima de .site-header (z-index: 10) */
}
.notif-dropdown[hidden] { display: none; }

.notif-head {
  padding: 11px 14px 5px;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--notif-muted);
}
.notif-empty {
  padding: 22px 14px;
  font-size: .85rem;
  color: var(--notif-muted);
  text-align: center;
}
.notif-item {
  display: block;
  padding: 9px 14px 11px;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.notif-head + .notif-item { border-top: none; }
a.notif-item:hover { background: var(--surface-2); }
a.notif-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.notif-item-title {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}
.notif-item-sub {
  display: block;
  margin-top: 2px;
  font-size: .8rem;
  color: var(--notif-muted);
  line-height: 1.35;
  word-break: break-word;
}
