/* SGS Generador — Viollier y Asociados */
/* Paleta corporativa: azul marino #1F3864, celeste #BDD7EE, blanco */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

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

:root {
  --navy:      #1F3864;
  --navy-mid:  #2d4f8a;
  --blue-lt:   #BDD7EE;
  --blue-xlt:  #e8f2fb;
  --white:     #ffffff;
  --gray-100:  #f4f6f9;
  --gray-200:  #e8edf3;
  --gray-400:  #9aaabf;
  --gray-600:  #5a6a80;
  --gray-800:  #2c3848;
  --green:     #1a7a3c;
  --green-lt:  #e6f5ec;
  --red:       #8b1a1a;
  --red-lt:    #fdf0f0;
  --amber:     #7a5a1a;
  --amber-lt:  #fdf7e6;
  --font:      'IBM Plex Sans', sans-serif;
  --mono:      'IBM Plex Mono', monospace;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(31,56,100,0.10), 0 4px 16px rgba(31,56,100,0.06);
  --shadow-lg: 0 4px 24px rgba(31,56,100,0.14);
}

html, body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  height: 100%;
}

/* ── LOGIN PAGE ───────────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #3a6ba8 100%);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.login-logo-img {
  max-width: 220px;
  width: 100%;
  height: auto;
  display: block;
}

.login-logo-subtitle {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.login-desc {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 24px;
  line-height: 1.5;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  cursor: pointer;
}

.btn-google:hover {
  border-color: var(--navy);
  box-shadow: 0 2px 8px rgba(31,56,100,0.12);
  background: var(--blue-xlt);
}

.login-footer {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--gray-400);
  line-height: 1.6;
}

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; text-align: left; }
.alert-error { background: var(--red-lt); color: var(--red); border: 1px solid #f0c0c0; }

/* ── APP PAGE ─────────────────────────────────────────────────────── */
body.app-page { background: var(--gray-100); }

.topbar {
  height: 52px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-logo {
  display: flex;
  align-items: center;
  height: 40px;
  text-decoration: none;
}
.topbar-logo img {
  height: 36px;
  width: auto;
  display: block;
}

.topbar-title {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  font-weight: 400;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-user {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.btn-logout {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  transition: all 0.15s;
}
.btn-logout:hover { color: var(--white); border-color: rgba(255,255,255,0.6); }

/* ── App layout ───────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 52px);
  max-width: 1200px;
  margin: 0 auto;
  gap: 0;
}

/* ── Panel izquierdo (formulario) ─────────────────────────────────── */
.panel-form {
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  padding: 24px;
  overflow-y: auto;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.creds-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
}
.creds-ok   { background: var(--green-lt); color: var(--green); }
.creds-warn { background: var(--amber-lt); color: var(--amber); }
.status-icon { font-size: 13px; }

.btn-link {
  background: none;
  border: none;
  color: var(--navy-mid);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 12px;
  display: block;
}
.btn-link:hover { color: var(--navy); }

.creds-form { margin-bottom: 12px; }
.creds-form label { display: block; font-size: 12px; color: var(--gray-600); margin-bottom: 4px; margin-top: 10px; font-weight: 500; }
.creds-form input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s;
}
.creds-form input:focus { border-color: var(--navy); }
.form-msg { font-size: 12px; margin-top: 8px; min-height: 16px; }

.divider { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }

.form-label { display: block; font-size: 12px; color: var(--gray-600); font-weight: 500; margin-bottom: 6px; margin-top: 14px; }
.form-input {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s;
  letter-spacing: 0.04em;
}
.form-input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31,56,100,0.08); }

/* Radio groups */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-option { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 9px 11px; border: 1.5px solid var(--gray-200); border-radius: var(--radius); transition: all 0.15s; }
.radio-option:hover { border-color: var(--blue-lt); background: var(--blue-xlt); }
.radio-option input[type="radio"] { margin-top: 3px; accent-color: var(--navy); flex-shrink: 0; }
.radio-option input[type="radio"]:checked ~ .radio-label strong { color: var(--navy); }
.radio-option:has(input:checked) { border-color: var(--navy); background: var(--blue-xlt); }
.radio-label { display: flex; flex-direction: column; gap: 1px; }
.radio-label strong { font-size: 13px; color: var(--gray-800); }
.radio-label small { font-size: 11.5px; color: var(--gray-600); }

/* Botones */
.btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--navy-mid); box-shadow: 0 2px 8px rgba(31,56,100,0.25); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
  padding: 7px 14px;
  background: var(--gray-100);
  color: var(--gray-800);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 10px;
}
.btn-secondary:hover { background: var(--blue-xlt); border-color: var(--navy); }

/* ── Panel derecho (progreso + historial) ─────────────────────────── */
.panel-main { padding: 24px; overflow-y: auto; }

/* Job activo */
.job-active {
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.job-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-100);
}

.job-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.job-badge.running { background: #e6f0fd; color: #1a4fa0; }
.job-badge.done    { background: var(--green-lt); color: var(--green); }
.job-badge.error   { background: var(--red-lt); color: var(--red); }

.job-title { font-size: 13px; font-weight: 500; color: var(--gray-800); flex: 1; }

/* Barra de progreso */
.progress-bar-wrap {
  height: 3px;
  background: var(--gray-200);
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: var(--navy-mid);
  width: 5%;
  transition: width 0.4s ease;
}
.progress-bar-inner.done {
  width: 100%;
  background: var(--green);
}
.progress-bar-inner.error {
  background: var(--red);
}
/* Animación indeterminada para el lapso entre creación del job y el primer
   marcador [N/3] del worker — evita que se vea estancada en 5%. */
.progress-bar-inner.indeterminate {
  width: 35%;
  animation: progress-slide 1.8s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* Log box */
.log-box {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--gray-800);
  background: #f8fafc;
  padding: 14px 16px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Botón descarga */
.download-wrap { padding: 14px 16px; border-top: 1px solid var(--gray-200); }
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-download:hover { background: var(--navy-mid); }
.download-hint { margin-top: 8px; font-size: 11.5px; color: var(--gray-600); }

/* ── Historial ─────────────────────────────────────────────────────── */
.historial { background: var(--white); border-radius: 8px; border: 1px solid var(--gray-200); box-shadow: var(--shadow); padding: 20px; }

.job-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 7px;
  transition: border-color 0.15s;
}
.job-item:hover { border-color: var(--blue-lt); }
.job-item.done    { border-left: 3px solid var(--green); }
.job-item.error   { border-left: 3px solid var(--red); }
.job-item.running { border-left: 3px solid var(--navy-mid); }

.job-item-left { display: flex; align-items: center; gap: 10px; }
.job-item-folio { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--navy); }
.job-item-tipo  { font-size: 11px; font-weight: 600; color: var(--gray-600); background: var(--gray-100); padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.job-item-right { display: flex; align-items: center; gap: 10px; }
.job-item-status { font-size: 12px; font-weight: 500; }
.job-item-status.done  { color: var(--green); }
.job-item-status.error { color: var(--red); }
.job-item-status.running { color: var(--navy-mid); }
.job-item-fecha { font-size: 11.5px; color: var(--gray-400); font-family: var(--mono); }

.btn-dl-small {
  font-size: 11.5px;
  padding: 4px 10px;
  background: var(--blue-xlt);
  color: var(--navy);
  border: 1px solid var(--blue-lt);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-dl-small:hover { background: var(--blue-lt); }
.btn-link.small { font-size: 11.5px; margin-bottom: 0; margin-left: auto; }
.empty-msg { font-size: 13px; color: var(--gray-400); text-align: center; padding: 20px 0; }

/* ── Modal: casos encontrados ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 50, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: modal-fade-in 150ms ease-out;
}
.modal-overlay[hidden] { display: none; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-container {
  background: var(--white);
  border-radius: 10px;
  width: 100%;
  max-width: 1100px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-100);
}
.modal-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  color: var(--gray-600);
  padding: 0 6px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--navy); }

.modal-body {
  overflow: auto;
  padding: 0;
}

.tabla-casos {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tabla-casos thead {
  background: var(--gray-100);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tabla-casos thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.tabla-casos tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.tabla-casos tbody tr:hover,
.tabla-casos tbody tr:focus {
  background: var(--blue-xlt);
  outline: none;
}
.tabla-casos tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
  color: var(--gray-800);
}
.tabla-casos tbody tr:last-child td { border-bottom: none; }
.tabla-casos .col-folio,
.tabla-casos .col-siniestro {
  font-family: var(--mono);
  color: var(--navy);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Toast: sesión expirada (Commit 4.C.2) ──────────────────────────────────── */
/* Centrado superior, mismo amber que `.creds-warn` para coherencia visual.
   z-index 2000 queda por encima de `.modal-overlay` (1000) por si el toast
   cae mientras un modal está abierto. Visible 3s y luego la página redirige
   a /auth/login — sin animación de salida porque la redirección reemplaza
   la vista entera. */
.toast-sesion-expirada {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--amber-lt);
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-fade-in 200ms ease-out;
}
.toast-sesion-expirada .toast-icon {
  margin-right: 8px;
  font-size: 16px;
}
@keyframes toast-fade-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
