/* ============================================================
   assets/css/app.css — v3
   Sin dependencias externas. Fuentes del sistema.
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
  --f:       -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --fm:      'SF Mono', 'Fira Code', 'Consolas', monospace;

  --bg:      #f5f4f0;
  --bg2:     #eeecea;
  --bg3:     #e4e2de;
  --surface: #ffffff;
  --sf2:     #fafaf8;

  --ink:     #1a1a18;
  --ink2:    #3d3d3a;
  --ink3:    #6b6966;
  --ink4:    #9c9a92;
  --ink5:    #c0beb6;

  --bd:      rgba(0,0,0,0.09);
  --bd2:     rgba(0,0,0,0.15);
  --bd3:     rgba(0,0,0,0.22);

  --ok:      #16a34a;
  --ok-bg:   #f0fdf4;
  --ok-bd:   #bbf7d0;

  --err:     #dc2626;
  --err-bg:  #fef2f2;
  --err-bd:  #fecaca;

  --warn:    #d97706;
  --warn-bg: #fffbeb;
  --warn-bd: #fde68a;

  --info:    #2563eb;
  --info-bg: #eff6ff;
  --info-bd: #bfdbfe;

  --r:       7px;
  --r-lg:    11px;
  --r-xl:    14px;
  --sw:      210px;
}

/* --- Reset ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--f);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: var(--f); }

/* --- Layout ---------------------------------------------- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --------------------------------------------- */
.sidebar {
  width: var(--sw);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 1rem 1rem 0.875rem;
  border-bottom: 1px solid var(--bd);
  text-decoration: none;
}
.sidebar__logo:hover { text-decoration: none; }

.sidebar__logo-mark {
  width: 24px;
  height: 24px;
  background: var(--ink);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar__logo-mark svg {
  width: 12px;
  height: 12px;
}
.sidebar__logo-nombre {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.sidebar__nav { padding: 0.75rem 0.6rem; flex: 1; }

.sidebar__grupo { margin-bottom: 1.5rem; }

.sidebar__grupo-titulo {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink5);
  padding: 0 0.5rem;
  margin-bottom: 3px;
}

.sidebar__enlace {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0.38rem 0.5rem;
  border-radius: var(--r);
  font-size: 13px;
  color: var(--ink3);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.sidebar__enlace:hover {
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}
.sidebar__enlace--activo {
  background: var(--bg2);
  color: var(--ink);
  font-weight: 500;
}
.sidebar__enlace-icono {
  font-size: 11px;
  opacity: 0.5;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__usuario {
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--bd);
}
.sidebar__usuario-nombre {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__usuario-rol {
  font-size: 10.5px;
  color: var(--ink5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}
.sidebar__usuario-salir {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 12px;
  color: var(--ink5);
  text-decoration: none;
}
.sidebar__usuario-salir:hover { color: var(--err); text-decoration: none; }

/* --- Contenido principal ---------------------------------- */
.contenido-principal {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 3rem;
  max-width: 900px;
}

/* --- Cabecera -------------------------------------------- */
.pagina-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}
.pagina-titulo {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1.3;
}
.pagina-sub {
  font-size: 12.5px;
  color: var(--ink4);
  margin-top: 3px;
  font-weight: 400;
}

/* --- Card ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
}

/* --- Botones ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.38rem 0.875rem;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--f);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
  line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primario { background: var(--ink); color: #fff; }
.btn--primario:hover { background: #333; }

.btn--secundario {
  background: var(--surface);
  color: var(--ink2);
  border-color: var(--bd2);
}
.btn--secundario:hover { background: var(--bg); }

.btn--peligro {
  background: var(--surface);
  color: var(--err);
  border-color: var(--bd2);
}
.btn--peligro:hover { background: var(--err-bg); border-color: var(--err); }

.btn--bloque { width: 100%; justify-content: center; padding: 0.5rem 1rem; }
.btn--sm { font-size: 12px; padding: 0.28rem 0.7rem; }

/* --- Formularios ----------------------------------------- */
.campo { margin-bottom: 1rem; }

.campo__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  margin-bottom: 5px;
}
.campo__label-link {
  font-weight: 400;
  color: var(--ink4);
  font-size: 12px;
  text-decoration: none;
}
.campo__label-link:hover { color: var(--ink2); }

.campo__input,
.campo__select,
.campo__textarea {
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--sf2);
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
  line-height: 1.5;
}
.campo__input:focus,
.campo__select:focus,
.campo__textarea:focus {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26,26,24,0.07);
}
.campo__input--error { border-color: var(--err); background: var(--err-bg); }
.campo__textarea { resize: vertical; min-height: 90px; }

/* --- LOGIN ----------------------------------------------- */
.body--login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.5rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.75rem;
}
.login-brand__mark {
  width: 28px;
  height: 28px;
  background: var(--ink);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-brand__mark svg { width: 14px; height: 14px; }
.login-brand__nombre {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--r-xl);
  padding: 1.875rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}
.login-card__titulo {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.03em;
  margin-bottom: 3px;
}
.login-card__sub {
  font-size: 12.5px;
  color: var(--ink4);
  margin-bottom: 1.6rem;
}

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--ink5);
  margin-top: 1.25rem;
  letter-spacing: 0.02em;
}

/* --- Alertas --------------------------------------------- */
.alerta, .flash {
  padding: 0.55rem 0.875rem;
  border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.5;
}
.alerta--error, .flash--error   { background: var(--err-bg);  color: #991b1b; border-color: var(--err-bd); }
.alerta--ok,    .flash--ok      { background: var(--ok-bg);   color: #15803d; border-color: var(--ok-bd);  }
.alerta--aviso, .flash--aviso   { background: var(--warn-bg); color: #92400e; border-color: var(--warn-bd);}
.alerta--info,  .flash--info    { background: var(--info-bg); color: #1e40af; border-color: var(--info-bd);}

/* --- Tablas ---------------------------------------------- */
.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink4);
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}
.tabla td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--bd);
  color: var(--ink);
  vertical-align: middle;
}
.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover td { background: var(--bg); }
.tabla .celda-muted { color: var(--ink4); font-size: 12.5px; }

/* --- Badges ---------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge--admin      { background: #eff6ff; color: #1d4ed8; }
.badge--usuario    { background: var(--bg2); color: var(--ink3); }
.badge--pdf        { background: #fff1f2; color: #be123c; }
.badge--imagen     { background: #f0fdf4; color: #15803d; }
.badge--word       { background: #eff6ff; color: #1d4ed8; }
.badge--excel      { background: #f0fdf4; color: #15803d; }
.badge--listo      { background: #f0fdf4; color: #15803d; }
.badge--procesando { background: var(--warn-bg); color: #92400e; }
.badge--error      { background: var(--err-bg); color: #991b1b; }

/* --- Buscador -------------------------------------------- */
.buscador { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.buscador__input {
  flex: 1;
  padding: 0.45rem 0.875rem;
  font-size: 13.5px;
  border: 1px solid var(--bd2);
  border-radius: var(--r);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.buscador__input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26,26,24,0.07);
}

/* --- Resultados búsqueda --------------------------------- */
.resultado { padding: 1rem 0; border-bottom: 1px solid var(--bd); }
.resultado:last-child { border-bottom: none; }
.resultado__titulo { font-size: 13.5px; font-weight: 500; margin-bottom: 3px; }
.resultado__titulo a { color: var(--ink); }
.resultado__titulo a:hover { color: var(--info); }
.resultado__meta { font-size: 11.5px; color: var(--ink4); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.resultado__extracto { font-size: 13px; color: var(--ink3); line-height: 1.65; }
.resultado__extracto mark { background: #fef08a; color: var(--ink); padding: 0 2px; border-radius: 2px; }

/* --- Upload ---------------------------------------------- */
.upload-zona {
  border: 1.5px dashed var(--bd3);
  border-radius: var(--r-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--sf2);
}
.upload-zona:hover, .upload-zona--activa {
  border-color: var(--ink);
  background: var(--bg);
}
.upload-zona__titulo { font-size: 13.5px; font-weight: 500; margin-bottom: 4px; color: var(--ink2); }
.upload-zona__sub { font-size: 12px; color: var(--ink4); }

.progress-wrap { margin-top: 1rem; display: none; }
.progress-wrap--visible { display: block; }
.progress-bar { height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.progress-bar__relleno { height: 100%; background: var(--ink); border-radius: 2px; width: 0%; transition: width 0.3s; }
.progress-label { font-size: 11.5px; color: var(--ink4); margin-top: 0.4rem; }

/* --- Vista documento ------------------------------------- */
.doc-meta {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink4);
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bd);
  align-items: center;
}
.doc-pagina { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid var(--bd); }
.doc-pagina:last-child { border-bottom: none; margin-bottom: 0; }
.doc-pagina__num {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink5);
  margin-bottom: 0.75rem;
}
.doc-pagina__texto {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink2);
  white-space: pre-wrap;
  word-break: break-word;
}
.doc-pagina__imagenes { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.doc-pagina__imagen { max-width: 100%; border: 1px solid var(--bd); border-radius: var(--r); }

/* --- Stats cards ----------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
}
.stat-card__label {
  font-size: 10.5px;
  color: var(--ink4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.stat-card__valor {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.04em;
  line-height: 1;
}
.stat-card__sub { font-size: 11px; color: var(--ink5); margin-top: 0.3rem; }

/* --- Paginación ------------------------------------------ */
.paginacion { display: flex; gap: 3px; margin-top: 1.25rem; }
.paginacion__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.5rem;
  border-radius: var(--r);
  font-size: 12.5px;
  color: var(--ink3);
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.1s;
}
.paginacion__btn:hover { background: var(--bg2); text-decoration: none; }
.paginacion__btn--activo { background: var(--ink); color: #fff; font-weight: 500; }
.paginacion__btn--activo:hover { background: var(--ink); }

/* --- Vacío ----------------------------------------------- */
.vacio { text-align: center; padding: 3rem 1rem; color: var(--ink4); }
.vacio__titulo { font-size: 13.5px; font-weight: 500; margin-bottom: 0.3rem; color: var(--ink3); }
.vacio__sub { font-size: 12.5px; }

/* --- Gráfica barras (admin) ------------------------------ */
.chart-wrap {
  height: 160px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bd);
}
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar { width: 100%; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 3px; opacity: 0.8; transition: opacity 0.15s; }
.chart-bar:hover { opacity: 1; }
.chart-label { font-size: 10px; color: var(--ink5); }

/* --- Utilidades ------------------------------------------ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.texto-muted { color: var(--ink4); }
.texto-sm    { font-size: 12.5px; }
.d-flex      { display: flex; }
.gap-1       { gap: 0.5rem; }
.gap-2       { gap: 1rem; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100       { width: 100%; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
