/* public/css/rem.css — REM 2.0 — Tema claro */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ─── Variables — Tema claro ────────────────────────────────────── */
:root {
  /* Paleta (claro) */
  --rem-900:  #ffffff;   /* fondo principal */
  --rem-800:  #f6f8fa;   /* fondo cards/sidebar */
  --rem-700:  #eaeef2;   /* fondo hover/filas */
  --rem-600:  #d0d7de;   /* bordes */
  --rem-500:  #8c959f;   /* texto deshabilitado */
  --rem-400:  #57606a;   /* texto secundario */
  --rem-200:  #24292f;   /* texto principal */
  --rem-100:  #1b1f24;   /* texto énfasis */
  --rem-50:   #0d1117;   /* texto muy oscuro */

  --accent:        #0969da;
  --accent-hover:  #0550ae;
  --accent-muted:  #0969da18;

  --success:  #1a7f37;
  --warning:  #9a6700;
  --danger:   #d1242f;
  --info:     #0969da;

  /* Estados remate */
  --estado-estudio:   #57606a;
  --estado-interesa:  #0969da;
  --estado-omitir:    #8c959f;
  --estado-asistir:   #1a7f37;
  --estado-descartar: #d1242f;

  /* Layout */
  --sidebar-w:  240px;
  --header-h:   56px;
  --radius:     6px;
  --radius-lg:  10px;
  --shadow:     0 1px 3px rgba(31,35,40,.12), 0 8px 24px rgba(66,74,83,.12);
  --shadow-sm:  0 1px 2px rgba(31,35,40,.08);

  --font-base: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --transition: 150ms ease;
}

/* ─── Reset / Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: var(--font-base);
  background: #f6f8fa;
  color: var(--rem-200);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hover); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--rem-700); }
::-webkit-scrollbar-thumb { background: var(--rem-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--rem-500); }

/* ─── Layout ────────────────────────────────────────────────────── */
.app-wrapper {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────── */
.app-header {
  grid-column: 1 / -1;
  background: var(--rem-900);
  border-bottom: 1px solid var(--rem-600);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-logo {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--rem-50);
  letter-spacing: -.4px;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.app-logo span {
  font-family: var(--font-mono);
  background: var(--accent);
  color: #fff;
  padding: .1rem .45rem;
  border-radius: var(--radius);
  font-size: .82rem;
}

.header-spacer { flex: 1; }

.header-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--rem-400);
  font-size: .875rem;
}

.header-user strong { color: var(--rem-200); }

.btn-logout {
  padding: .3rem .75rem;
  border: 1px solid var(--rem-600);
  border-radius: var(--radius);
  color: var(--rem-400);
  font-size: .8rem;
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
}

.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ─── Sidebar ───────────────────────────────────────────────────── */
.app-sidebar {
  background: var(--rem-900);
  border-right: 1px solid var(--rem-600);
  overflow-y: auto;
  padding: .75rem 0;
}

.nav-group-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--rem-500);
  padding: 1rem 1rem .3rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .42rem 1rem;
  color: var(--rem-400);
  font-size: .875rem;
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.nav-link:hover {
  color: var(--rem-100);
  background: var(--rem-700);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-muted);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-link .nav-icon { width: 16px; text-align: center; font-size: .88rem; }

/* ─── Main ──────────────────────────────────────────────────────── */
.app-main {
  overflow-y: auto;
  padding: 1.5rem;
  background: #f6f8fa;
}

/* ─── Page header ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--rem-50);
  letter-spacing: -.3px;
}

.page-subtitle { color: var(--rem-400); font-size: .875rem; margin-top: .15rem; }
.page-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--rem-700);
}

.card-title { font-size: .92rem; font-weight: 600; color: var(--rem-100); }

/* ─── Tabla ─────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rem-600);
  background: var(--rem-900);
  box-shadow: var(--shadow-sm);
}

table.rem-table { width: 100%; border-collapse: collapse; font-size: .85rem; }

.rem-table thead th {
  background: var(--rem-800);
  color: var(--rem-400);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .6rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--rem-600);
  white-space: nowrap;
  user-select: none;
}

.rem-table tbody tr { border-bottom: 1px solid var(--rem-700); transition: background var(--transition); }
.rem-table tbody tr:last-child { border-bottom: none; }
.rem-table tbody tr:hover { background: var(--rem-800); }

.rem-table td { padding: .6rem .9rem; vertical-align: middle; color: var(--rem-200); }
.rem-table td.td-mono { font-family: var(--font-mono); font-size: .8rem; color: var(--rem-400); }
.rem-table td.td-monto { font-family: var(--font-mono); font-size: .82rem; text-align: right; }
.rem-table td.td-actions { white-space: nowrap; text-align: right; }

/* ─── Filtros de fecha (tabs) ───────────────────────────────────── */
.fecha-tabs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

.fecha-tab {
  padding: .3rem .75rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  border: 1px solid var(--rem-600);
  color: var(--rem-400);
  background: var(--rem-900);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.fecha-tab:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.fecha-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ─── Badges de estado ──────────────────────────────────────────── */
.badge-estado {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge-ESTUDIO   { background: khaki;        color: #5a4e00; border: 1px solid #c8b800; }
.badge-INTERESA  { background: lightskyblue; color: #0a4a7a; border: 1px solid #5aa8e0; }
.badge-OMITIR    { background: indianred;    color: #fff;    border: 1px solid #b03030; }
.badge-ASISTIR   { background: lightgreen;   color: #1a5c1a; border: 1px solid #4aaa4a; }
.badge-DESISTIR  { background: olive;        color: #fff;    border: 1px solid #556000; }
.badge-DESCARTAR { background: indianred;    color: #fff;    border: 1px solid #b03030; }

/* ─── Formularios ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
.form-group.span-full { grid-column: 1 / -1; }

label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--rem-400);
  text-transform: uppercase;
  letter-spacing: .4px;
}

input, select, textarea {
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius);
  color: var(--rem-200);
  padding: .45rem .7rem;
  font-family: var(--font-base);
  font-size: .875rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

input::placeholder { color: var(--rem-500); }
textarea { resize: vertical; min-height: 80px; }

.input-calculated {
  background: var(--rem-800);
  border-style: dashed;
  color: var(--rem-400);
  cursor: not-allowed;
}

.input-group { display: flex; align-items: stretch; }
.input-addon {
  background: var(--rem-800);
  border: 1px solid var(--rem-600);
  color: var(--rem-400);
  padding: .45rem .65rem;
  font-size: .8rem;
  white-space: nowrap;
}
.input-addon:first-child { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.input-addon:last-child  { border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.input-group input { border-radius: 0; }

/* ─── Botones ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .42rem .95rem;
  border-radius: var(--radius);
  font-family: var(--font-base);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: var(--rem-900); border-color: var(--rem-600); color: var(--rem-200); }
.btn-secondary:hover { background: var(--rem-800); border-color: var(--rem-500); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border-color: var(--rem-600); color: var(--rem-400); }
.btn-ghost:hover { color: var(--rem-200); border-color: var(--rem-500); background: var(--rem-800); }

.btn-sm   { padding: .26rem .65rem; font-size: .8rem; }
.btn-icon { padding: .35rem .5rem; }

/* ─── Filtros bar ───────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filters-bar input, .filters-bar select { width: auto; min-width: 140px; }

/* ─── Alertas ───────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1rem;
  font-size: .875rem;
}

.alert-success { background: #dafbe1; border-color: #4ac26b; color: #1a7f37; }
.alert-danger  { background: #ffebe9; border-color: #ff8182; color: #d1242f; }
.alert-info    { background: #ddf4ff; border-color: #54aeff; color: #0969da; }
.alert-warning { background: #fff8c5; border-color: #d4a72c; color: #9a6700; }

/* ─── Stats cards ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--rem-500); margin-bottom: .3rem; font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--rem-50); line-height: 1; font-family: var(--font-mono); }
.stat-sub   { font-size: .72rem; color: var(--rem-500); margin-top: .25rem; }

/* ─── Valorización ──────────────────────────────────────────────── */
.valor-panel {
  background: var(--rem-800);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.valor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .38rem 0;
  border-bottom: 1px solid var(--rem-700);
  font-size: .875rem;
}

.valor-row:last-child { border-bottom: none; }
.valor-label  { color: var(--rem-400); }
.valor-amount { font-family: var(--font-mono); color: var(--rem-200); }
.valor-row.total .valor-label  { color: var(--rem-200); font-weight: 600; }
.valor-row.total .valor-amount { color: var(--success); font-size: 1rem; font-weight: 600; }
.valor-row.oferta .valor-amount { color: var(--warning); font-size: 1.05rem; font-weight: 700; }

/* ─── Aviso HTML viewer/editor ──────────────────────────────────── */
.aviso-tabs { display: flex; gap: 0; margin-bottom: 0; }
.aviso-tab {
  padding: .35rem .85rem;
  font-size: .8rem;
  font-weight: 500;
  border: 1px solid var(--rem-600);
  background: var(--rem-800);
  color: var(--rem-400);
  cursor: pointer;
  transition: all var(--transition);
}
.aviso-tab:first-child { border-radius: var(--radius) 0 0 0; }
.aviso-tab:last-child  { border-radius: 0 var(--radius) 0 0; border-left: none; }
.aviso-tab.active { background: var(--rem-900); color: var(--rem-200); font-weight: 600; border-bottom-color: var(--rem-900); }

.aviso-panel {
  border: 1px solid var(--rem-600);
  border-top: none;
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  background: var(--rem-900);
}

.aviso-rendered {
  padding: .85rem 1rem;
  font-size: .85rem;
  color: var(--rem-200);
  line-height: 1.7;
  min-height: 80px;
}

.aviso-rendered p  { margin-bottom: .5rem; }
.aviso-rendered br { display: block; margin-bottom: .2rem; }

.aviso-source {
  width: 100%;
  padding: .85rem 1rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--rem-400);
  background: var(--rem-800);
  border: none;
  resize: vertical;
  min-height: 120px;
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  display: none;
}

.aviso-source:focus { outline: none; }

/* ─── Paginación ────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  border-radius: var(--radius);
  font-size: .8rem;
  border: 1px solid var(--rem-600);
  color: var(--rem-400);
  background: var(--rem-900);
  transition: all var(--transition);
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled { opacity: .4; cursor: default; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  width: min(800px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rem-700);
}

.modal-title { font-size: 1rem; font-weight: 600; color: var(--rem-100); }
.modal-body  { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--rem-700); }

/* ─── Login ─────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #f6f8fa;
}

.login-card {
  background: var(--rem-900);
  border: 1px solid var(--rem-600);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 360px;
  box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-box {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  width: 60px; height: 60px;
  border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.05rem; color: var(--rem-400); font-weight: 400; }
.login-logo h1 strong { color: var(--rem-200); font-weight: 600; }

/* ─── Utilidades ────────────────────────────────────────────────── */
.text-muted  { color: var(--rem-400) !important; }
.text-small  { font-size: .8rem; }
.text-mono   { font-family: var(--font-mono); }
.text-right  { text-align: right; }
.text-center { text-align: center; }

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: .5rem; }

.divider { border: none; border-top: 1px solid var(--rem-700); margin: 1.25rem 0; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--rem-600);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--rem-200);
  font-size: 1.3rem;
  cursor: pointer;
  padding: .25rem .4rem;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.45);
  z-index: 149;
}

.sidebar-overlay.active { display: block; }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-wrapper { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .app-sidebar {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 150;
    overflow-y: auto;
    box-shadow: 4px 0 16px rgba(0,0,0,.4);
  }
  .app-sidebar.open { display: block; }
  .app-main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2, .form-group.span-3 { grid-column: 1; }
}
