/* =========================================================================
   AcusePDF — ESTILOS DE LA APLICACIÓN
   Usa solo las variables de theme.css. Para cambiar colores o fuentes,
   edita theme.css, no este archivo.
   ========================================================================= */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--text-2xl); line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: var(--text-xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); }
a { color: var(--color-accent); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.icon { width: 1.1em; height: 1.1em; flex: none; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.spacer { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Cabecera y pie ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem max(16px, calc((100% - var(--container)) / 2));
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 650; }
.brand__mark {
  display: grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  background: var(--color-primary); color: var(--color-primary-text);
}
.brand__mark svg { width: 1.1rem; height: 1.1rem; }
.role-badge {
  font-size: var(--text-xs); font-weight: 500;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--color-surface-2); color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.footer {
  margin-top: auto;
  padding: 1.25rem max(16px, calc((100% - var(--container)) / 2));
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted); font-size: var(--text-xs);
}
.container {
  width: 100%; max-width: var(--container);
  margin: 0 auto; padding: 1.5rem 16px 3rem;
}
@media (min-width: 768px) { .container { padding-top: 2.5rem; } }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
@media (min-width: 768px) { .card { padding: 1.5rem; } }
.card__head { display: flex; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card__head > div { flex: 1; min-width: 12rem; }
.card__head p { color: var(--color-text-muted); font-size: var(--text-sm); }
.eyebrow {
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--color-accent);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 2.5rem; padding: 0.5rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  font-size: var(--text-sm); font-weight: 550; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--color-surface-2); }
.btn:focus-visible, .field input:focus-visible, .icon-btn:focus-visible, .check input:focus-visible {
  outline: none; box-shadow: var(--focus-ring);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--color-primary); color: var(--color-primary-text); border-color: var(--color-primary); }
.btn--primary:hover { background: var(--color-primary); opacity: 0.88; }
.btn--success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn--success:hover { background: var(--color-success); opacity: 0.9; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--danger { color: var(--color-danger); }
.btn--block { width: 100%; }
.btn--lg { min-height: 3rem; font-size: var(--text-base); }
.btn--sm { min-height: 2rem; padding: 0.3rem 0.65rem; font-size: var(--text-xs); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--color-text-muted);
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field__label { font-size: var(--text-sm); font-weight: 550; }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.field__error { font-size: var(--text-xs); color: var(--color-danger); }
.field input[type="email"], .field input[type="text"], .field input[type="date"],
.field input[type="number"], .field input[type="password"], .input {
  width: 100%; min-height: 2.75rem; padding: 0.55rem 0.8rem;
  border-radius: var(--radius); border: 1px solid var(--color-border);
  background: var(--color-surface); font-size: var(--text-base);
}
.field input[aria-invalid="true"] { border-color: var(--color-danger); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-size: var(--text-sm); cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; margin: 0.15rem 0 0; accent-color: var(--color-primary); flex: none; }
.check strong { display: block; }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 560px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Avisos, insignias, estados ---------- */
.notice {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.85rem 1rem; border-radius: var(--radius);
  font-size: var(--text-sm); border: 1px solid transparent;
}
.notice .icon { margin-top: 0.15rem; }
.notice--success { background: var(--color-success-bg); color: var(--color-success); }
.notice--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.notice--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.notice--info { background: var(--color-surface-2); color: var(--color-text-muted); border-color: var(--color-border); }
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: var(--text-xs); font-weight: 550;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--danger { background: var(--color-danger-bg); color: var(--color-danger); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }
.empty .icon { width: 2rem; height: 2rem; margin-bottom: 0.5rem; }
.spinner {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 2px solid var(--color-border); border-top-color: var(--color-text);
  animation: spin 0.8s linear infinite;
}
.loading { display: grid; place-items: center; gap: 0.75rem; padding: 4rem 1rem; color: var(--color-text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; border-radius: 999px; background: var(--color-surface-2); overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--color-primary); transition: width 0.2s; }

/* ---------- Notificaciones flotantes ---------- */
.toasts {
  position: fixed; z-index: 100; left: 16px; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; pointer-events: none;
}
.toast {
  max-width: 28rem; padding: 0.7rem 1rem; border-radius: var(--radius);
  background: var(--color-primary); color: var(--color-primary-text);
  box-shadow: var(--shadow); font-size: var(--text-sm);
  animation: toast-in 0.2s ease-out;
}
.toast--error { background: var(--color-danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Página sin acceso ---------- */
.gate { max-width: 30rem; margin: 2rem auto; text-align: center; }
.gate .icon { width: 2.5rem; height: 2.5rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.gate p { color: var(--color-text-muted); margin-top: 0.5rem; }
.gate form { margin-top: 1.25rem; text-align: left; }

/* ---------- Vista lector ---------- */
.reader { max-width: 40rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
.reader__intro { display: flex; flex-direction: column; gap: 0.5rem; }
.reader__intro p { color: var(--color-text-muted); }
.doc-card { display: flex; gap: 0.9rem; align-items: center; }
.doc-card__icon {
  display: grid; place-items: center; flex: none;
  width: 2.75rem; height: 2.75rem; border-radius: var(--radius);
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.doc-card__icon .icon { width: 1.4rem; height: 1.4rem; }
.doc-card__body { min-width: 0; flex: 1; }
.doc-card__title { font-weight: 600; overflow-wrap: anywhere; }
.doc-card__meta { font-size: var(--text-sm); color: var(--color-text-muted); display: flex; gap: 0.35rem 0.75rem; flex-wrap: wrap; }

/* ---------- Visor de PDF ---------- */
.viewer {
  display: flex; flex-direction: column;
  height: calc(100dvh - 9rem); min-height: 26rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.viewer:fullscreen { height: 100%; border-radius: 0; border: 0; }
.viewer.is-pseudo-fullscreen {
  position: fixed; inset: 0; z-index: 50; height: 100%; border-radius: 0; border: 0;
}
.viewer__bar {
  display: flex; align-items: center; gap: 0.25rem 0.5rem; flex-wrap: wrap;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.viewer__title {
  flex: 1 1 0; min-width: 0; font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viewer__group { display: flex; align-items: center; gap: 0.15rem; }
.viewer__page { font-size: var(--text-xs); font-family: var(--font-mono); min-width: 4.5rem; text-align: center; }
.viewer__pages {
  position: relative; flex: 1; overflow: auto; overscroll-behavior: contain;
  background: var(--viewer-bg);
  padding: 1rem 0.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.viewer__pages.is-zoomed { align-items: flex-start; }
.pdf-page {
  position: relative; flex: none; margin: 0 auto;
  background: #fff; box-shadow: var(--shadow-sm);
}
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page__num {
  position: absolute; bottom: 0.4rem; right: 0.5rem;
  font: 500 var(--text-xs) var(--font-mono); color: #8a8f99;
}
.viewer__foot {
  display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap;
  padding: 0.6rem 0.75rem; border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.viewer__status { flex: 1 1 12rem; font-size: var(--text-xs); color: var(--color-text-muted); }
.viewer__foot .btn { flex: 1 1 auto; }
@media (min-width: 560px) { .viewer__foot .btn { flex: 0 0 auto; } }
.viewer__error { margin: auto; max-width: 24rem; padding: 1rem; }
@media (max-width: 559px) {
  .hide-mobile { display: none !important; }
  .viewer { height: calc(100dvh - 7.5rem); }
}

/* ---------- Vista administrador ---------- */
.admin { display: flex; flex-direction: column; gap: 1.5rem; }
.admin__head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.admin__head > div { flex: 1; min-width: 14rem; }
.admin__head p { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: 0.25rem; }
.stats { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 1rem 1.1rem; }
.stat__label { font-size: var(--text-xs); color: var(--color-text-muted); }
.stat__value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__note { font-size: var(--text-xs); color: var(--color-text-muted); }
.admin-grid { display: grid; gap: 1.5rem; }
@media (min-width: 1000px) { .admin-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; } }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.35rem; padding: 1.75rem 1rem; text-align: center;
  border: 2px dashed var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-surface-2); cursor: pointer; transition: border-color 0.15s;
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--color-accent); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .icon { width: 1.75rem; height: 1.75rem; color: var(--color-text-muted); }
.dropzone__name { font-weight: 600; overflow-wrap: anywhere; }
.link-box { display: flex; gap: 0.5rem; }
.link-box input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: var(--text-xs); }

.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.doc-item {
  display: grid; gap: 0.5rem; padding: 0.9rem 0.25rem;
  border-top: 1px solid var(--color-border);
}
.doc-item:first-child { border-top: 0; }
.doc-item.is-selected { background: var(--color-surface-2); border-radius: var(--radius); padding-inline: 0.75rem; }
.doc-item__top { display: flex; gap: 0.5rem; align-items: flex-start; }
.doc-item__title {
  flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere;
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
}
.doc-item__title:hover { color: var(--color-accent); }
.doc-item__meta { display: flex; gap: 0.25rem 0.75rem; flex-wrap: wrap; font-size: var(--text-xs); color: var(--color-text-muted); }
.doc-item__actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
@media (min-width: 768px) { .table-wrap { margin: 0 -1.5rem; padding: 0 1.5rem; } }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.table td.nowrap { white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .email { font-weight: 550; overflow-wrap: anywhere; min-width: 12rem; }
.doc-card__badges { margin-top: 0.4rem; }
.doc-card__badges:empty { display: none; }
