/* ==========================================================================
   BONDI v2 — DASHBOARD
   Estética heredada del proyecto anterior (v1): tema claro profesional de
   herramienta de control de rutas, estilo Linear / Stripe / GitHub.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Fondo y superficies */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfdfe;
  --bg-surface: #f1f5f9;
  --bg-surface-hover: #e2e8f0;

  /* Bordes nítidos */
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Tipografía de alto contraste */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Acción y estado */
  --primary: #0f172a;
  --primary-hover: #1e293b;

  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-subtle: #eff6ff;
  --blue-border: #bfdbfe;

  --green: #059669;
  --green-subtle: #ecfdf5;
  --green-border: #a7f3d0;
  --green-text: #065f46;

  --amber: #d97706;
  --amber-subtle: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;

  --red: #dc2626;
  --red-hover: #b91c1c;
  --red-subtle: #fef2f2;
  --red-border: #fecaca;
  --red-text: #991b1b;

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Sombras técnicas */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: 0.15s ease-in-out;
}

/* ─── Reset y Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

/* ─── Layout general ──────────────────────────────────────────────────────── */
.app-layout { min-height: 100vh; display: flex; flex-direction: column; }

.main-content {
  flex: 1;
  max-width: 90%;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── Barra superior ──────────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar__inner {
  max-width: 90%;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--text-primary); }
.brand:hover { opacity: 0.9; }

.brand__icon {
  background: var(--primary);
  color: #ffffff;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.brand__text { display: flex; align-items: center; gap: 0.5rem; }

.brand__name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand__badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ─── Navegación (pestañas) ───────────────────────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-link:hover { color: var(--text-primary); }
.nav-link--active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.nav-link__icon { color: var(--text-secondary); }
.nav-link--active .nav-link__icon { color: var(--primary); }

/* ─── Métricas generales ──────────────────────────────────────────────────── */
.stat-strip { display: flex; gap: 0.75rem; flex-wrap: wrap; }

#resumen span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.95rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
#resumen b { color: var(--text-primary); font-size: 1.05rem; font-weight: 700; }

/* ─── Paneles ─────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.panel__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  margin: 0 0 0.25rem;
}

.panel__desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.45;
  margin: 0;
}

.action-bar-right { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }

/* ─── Barra de controles / filtros ────────────────────────────────────────── */
.controles {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.msg { color: var(--text-muted); font-size: 0.85rem; align-self: center; }
.msg--bar { margin: 0 0 1rem; min-height: 1.1em; }

/* ─── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all var(--transition);
}

.btn--primary { background: var(--primary); color: #ffffff; border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn--secondary { background: #ffffff; color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn--secondary:hover { background: var(--bg-app); border-color: var(--text-secondary); }

.btn--sm { font-size: 0.82rem; padding: 0.42rem 0.8rem; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Botones sueltos creados por el JS (tablas y acciones) */
.acciones { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.acciones button, .acciones a, .controles button:not(.btn) {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
}
.acciones button:hover, .acciones a:hover, .controles button:not(.btn):hover { background: var(--bg-app); border-color: var(--text-secondary); }
.acciones button:disabled { opacity: 0.55; cursor: not-allowed; }

button.peligro { background: #ffffff; color: var(--red-text); border-color: var(--red-border); }
button.peligro:hover { background: var(--red-subtle); border-color: var(--red); color: var(--red-text); }

/* ─── Grilla de contenido (tabla + detalle) ───────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.25rem;
  align-items: start;
}

/* La tabla de actualizadores tiene 7 columnas: no entra junto al panel de
   últimas capturas sin scroll horizontal. La apilamos (tabla arriba, log
   abajo a todo el ancho) para que la columna de acciones quede siempre visible
   y nada se superponga. */
#vista-actualizadores .content-grid { grid-template-columns: minmax(0, 1fr); }
#vista-actualizadores .detalle { max-width: 720px; }
#trayectos th:first-child,
#trayectos td:first-child { white-space: normal; min-width: 200px; }

@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
}

.tabla-wrap {
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ─── Tablas ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr { transition: background var(--transition); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--blue-subtle); cursor: pointer; }

#trayectos tbody tr:hover { background: var(--bg-surface); }

/* ─── Panel de detalle ────────────────────────────────────────────────────── */
.detalle {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
}

.detalle__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.6rem;
}

.detalle > .detalle__title:not(:first-child),
.detalle > h2:not(.detalle__title):not(:first-child) { margin-top: 1.25rem; }

.log-titulo {
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.hint { color: var(--text-muted); font-size: 0.85rem; line-height: 1.45; margin: 0 0 0.6rem; }

/* ─── Deltas y ocupación ──────────────────────────────────────────────────── */
td.delta-up { color: var(--green); font-weight: 600; }
td.delta-down { color: var(--red); font-weight: 600; }

.ocup-alta { color: var(--green); font-weight: 700; }
.ocup-media { color: var(--blue); font-weight: 600; }
.ocup-baja { color: var(--text-muted); }

/* ─── Chips / hitos ───────────────────────────────────────────────────────── */
.hitos-celda { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.chip-lleno { background: var(--green-subtle); color: var(--green-text); border-color: var(--green-border); }
.chip-medio { background: var(--blue-subtle); color: var(--blue); border-color: var(--blue-border); }
.chip-bajo { background: var(--bg-surface); color: var(--text-muted); border-color: var(--border-subtle); }

/* ─── Serie temporal (sparkline) ──────────────────────────────────────────── */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 90px;
  margin: 0.75rem 0;
  padding: 0.4rem;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.spark .bar {
  flex: 1;
  background: var(--blue);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background var(--transition);
}
.spark .bar:hover { background: var(--blue-hover); }

/* ─── Listas de observaciones / capturas ──────────────────────────────────── */
.obs-list { font-size: 0.82rem; color: var(--text-secondary); max-height: 240px; overflow: auto; }
.obs-list div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px dashed var(--border-subtle);
  padding: 0.35rem 0;
}
.obs-list div:last-child { border-bottom: none; }
.obs-list b { color: var(--text-primary); white-space: nowrap; }
.obs-list b.ok { color: var(--green); }
.obs-list b.err { color: var(--red); }

/* ─── Formularios e inputs ────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 0.75rem; }

.field-group { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

.input-box, .select-box {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 400;
  outline: none;
  transition: all var(--transition);
}
.input-box:focus, .select-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}
.input-box::placeholder { color: var(--text-light); }

label.check, .toggle-control { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--text-primary); cursor: pointer; }
.toggle-control input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

.form-acciones { display: flex; gap: 0.6rem; margin-top: 0.35rem; }

/* ─── Pantalla de edición (URL propia) ────────────────────────────────────── */
.panel-back-header { margin-bottom: 1.25rem; }
.btn-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.btn-back-link:hover { color: var(--text-primary); }
.form-editar { max-width: 560px; }

/* ─── Utilidades ──────────────────────────────────────────────────────────── */
.oculto { display: none !important; }

/* ─── Bloqueador de Autenticación ─────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
  animation: fadeInOverlay 0.25s ease-out;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 2.25rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  position: relative;
  animation: slideUpCard 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpCard {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card__icon {
  width: 56px;
  height: 56px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-subtle);
}

.auth-card__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.auth-card__desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.auth-card__form {
  text-align: left;
}

.auth-card__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  display: block;
}

.auth-card__input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
}

.auth-card__error {
  background: var(--red-subtle);
  color: var(--red-text);
  border: 1px solid var(--red-border);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.auth-card__submit {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  justify-content: center;
}

.btn-logout:hover {
  color: var(--red) !important;
  background: var(--red-subtle) !important;
}
