/* VERSION: 1.6 */
/* ============================================================
   Flight Tools — style.css
   Tema: light · Tipografía: Geist (Google Fonts)
   ============================================================ */


/* ── 1. TOKENS DE DISEÑO ────────────────────────────────────
   Cambiá estos valores para actualizar todo el sistema.      */
:root {
  /* Colores base */
  --bg:          #f4f4f5;   /* fondo general */
  --surface:     #ffffff;   /* tarjetas, sidebar, topbar */
  --border:      #e4e4e7;   /* bordes de elementos */

  /* Texto */
  --text:        #09090b;   /* texto principal */
  --muted:       #71717a;   /* texto secundario / labels */

  /* Acento (azul) */
  --accent:      #2563eb;
  --accent-bg:   #eff6ff;   /* fondo suave del acento */
  --accent-hover:#1d4ed8;

  /* Estados */
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;

  /* Comparativa — todo coincide (verde) */
  --ok-sheet:    #d8f6e2;   /* fila Sheet cuando todo coincide */
  --ok-pdf:      #a8e6c0;   /* fila PDF  cuando todo coincide */

  /* Comparativa — diferencias secundarias (amarillo) */
  --warn-sheet:  #ffebd2;   /* fila Sheet cuando hay diferencias secundarias */
  --warn-pdf:    #ffe5b2;   /* fila PDF  cuando hay diferencias secundarias */
  --warn-text:   #ab5900;   /* fila PDF  cuando hay diferencias secundarias */

  /* Comparativa — diferencias de identidad (rojo) */
  --diff-sheet:  #ffdede;   /* fila Sheet cuando hay diferencias de identidad */
  --diff-pdf:    #fafafa;   /* fila PDF  cuando hay diferencias de identidad */
  --diff-cell:   #ffc4c4;   /* celda PDF con el valor diferente */
  --diff-text:   #c0392b;   /* texto en celda diferente + "no encontrado" */
  --notfound-bg: #fff8f8;   /* fila "no encontrado en Sheet" */

  /* Mensajes de error */
  --error-bg:     #fef2f2;  /* fondo de .msg-error */
  --error-border: #fecaca;  /* borde de .msg-error */

  /* Overlays y sombras */
  --overlay:     rgba(0,0,0,.35);  /* fondo detrás de modales */
  --shadow:      rgba(0,0,0,.18);  /* sombra de modales */

  /* Dimensiones */
  --radius:      3px;       /* radio de borde general */
  --radius-md:   4px;       /* modales, cards grandes */
  --sidebar-w:   160px;     /* ancho del sidebar */

  /* Tipografía */
  --font:        'Geist', system-ui, sans-serif;
  --font-size:   14px;
  --line-height: 1.5;
}


/* ── 2. RESET ───────────────────────────────────────────────
   Reset mínimo y consistente entre navegadores.              */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: var(--line-height);
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
button, input, select { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }


/* ── 3. LAYOUT ──────────────────────────────────────────────
   Sidebar fijo a la izquierda + área principal flexible.     */
.app {
  display: flex;
  min-height: 100vh;
}


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

/* Logo / nombre de la app */
.brand {
  padding: 0 16px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;

  & .brand-icon {
    width: 26px;
    height: 26px;
    background: var(--text);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--surface);
    flex-shrink: 0;
  }

  & .brand-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
}

/* Navegación */
.nav {
  padding: 10px 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  border-right: 2px solid transparent;
  transition: color 0.1s;
  user-select: none;

  &:hover { color: var(--text); }

  &.active {
    color: var(--accent);
    font-weight: 500;
    border-right-color: var(--accent);
    background: var(--accent-bg);
  }
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Footer de versiones en el sidebar */
#versionFooter {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
}

/* Cada línea "archivo vX.Y" en el footer */
.ver-row { display: block; }

/* Separador entre archivos principales y parsers */
.ver-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

/* Label "PARSERS" sobre el listado de parsers */
.ver-parser-label {
  display: block;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .5px;
}


/* ── 5. TOPBAR ──────────────────────────────────────────────*/
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-drive-link {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  transition: color .15s;
  margin-left: 4px;
}
.topbar-drive-link:hover { color: var(--primary); }

.toolbar-sheet-link {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  transition: color .15s;
}
.toolbar-sheet-link:hover { color: #1a7f37; }

.cmp-top-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}


/* ── 6. CONTENIDO PRINCIPAL ─────────────────────────────────*/
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  padding: 24px;
  flex: 1;
}


/* ── 7. TOOLBAR DE ACCIONES ─────────────────────────────────
   Fila con selector de carpeta + botones Parsear / Limpiar   */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Área de selección de archivo */
.file-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.file-name {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* Input file nativo oculto — se activa con el label */
input[type="file"] { display: none; }

.btn-file {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* Selector de carpeta Drive */
.folder-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  min-width: 220px;

  &:focus {
    outline: none;
    border-color: var(--accent);
  }
}


/* ── 8. BOTONES ─────────────────────────────────────────────*/
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: opacity 0.1s;

  &:disabled {
    opacity: 0.5;
    cursor: wait;
  }
}

/* Primario (azul) */
.btn-primary {
  background: var(--accent);
  color: var(--surface);

  &:hover:not(:disabled) { background: var(--accent-hover); }
  &:disabled { opacity: 0.45; cursor: not-allowed; }
}

/* Secundario (gris) */
.btn-secondary {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);

  &:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border);
  }
}

/* Éxito (verde) */
.btn-success {
  background: var(--success);
  color: var(--surface);
}


/* ── 9. MENSAJES ────────────────────────────────────────────*/
.msg-error {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
}

.msg-success {
  font-size: 13px;
  color: var(--success);
  margin-top: 14px;

  & a { font-weight: 500; }
}

/* Error inline de Drive (dentro de msg-success) */
.drive-error { color: var(--danger); }


/* ── 10. TABLA DE RESULTADOS ────────────────────────────────*/
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;           /* scroll horizontal en mobile */
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 9px 11px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td {}

/* Código IATA con tooltip en el title */
td[title] {
  cursor: help;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}

/* Badge de código de reserva */
.code-badge {
  font-family: var(--font);
  font-size: 12px;
  background: var(--bg);
  padding: 2px 7px;
  border-radius: var(--radius);
  color: var(--muted);
  border: 1px solid var(--border);
  letter-spacing: 0.03em;
}


/* ── 11. SECTION LABEL ──────────────────────────────────────
   Etiquetas de sección tipo "RECIENTES", "RESULTADOS", etc.  */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}


/* ── 12. TOUR SWITCHER (topbar clickeable) ──────────────────*/
.tour-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 2px 4px;
  margin: -2px -4px;   /* compensa padding para no desplazar layout */
  transition: background 0.1s;

  &:hover {
    background: var(--bg);

    & .tour-caret { color: var(--text); }
  }
}

/* La caretita ↓ */
.tour-caret {
  width: 9px;
  height: 9px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

/* El <select> nativo es invisible y cubre todo el switcher,
   para aprovechar el comportamiento nativo de dropdown. */
.tour-select-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: inherit;
}


/* ── 13. CONFIGURACIÓN — formulario ─────────────────────────*/
.config-wrap {
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 14px;

  /* Separador visual entre secciones */
  & + .config-section {
    padding-top: 32px;
    border-top: 1px solid var(--border);
  }
}

.config-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Fila con dropdown + botón Nueva gira */
.config-row {
  display: flex;
  align-items: center;
  gap: 10px;

  & .folder-select {
    flex: 1;
    min-width: 0;
  }
}

/* Formulario de edición */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 5px;

  & label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
  }

  & input[type="text"] {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    width: 100%;
    transition: border-color 0.1s;

    &:focus {
      outline: none;
      border-color: var(--accent);
    }

    &::placeholder { color: var(--muted); }
  }
}

.config-hint {
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.75;
}

/* Fila input + ícono de abrir */
.config-input-row {
  display: flex;
  align-items: center;
  gap: 6px;

  & input[type="text"] { flex: 1; }
}

.config-open-link {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  transition: color 0.1s, border-color 0.1s;
  visibility: hidden;   /* se muestra solo cuando hay ID */

  &:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
  }

  & svg {
    width: 14px;
    height: 14px;
  }
}

/* Badge de verificación de ID (nombre resuelto desde Drive) */
.config-verify {
  font-size: 11.5px;
  min-height: 16px;
  display: block;
}

.verify-loading { color: var(--muted); }
.verify-ok      { color: var(--success); font-weight: 500; }
.verify-err     { color: var(--danger); }

.config-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

#configSaveMsg {
  font-size: 12.5px;

  &.msg-success {
    color: var(--success);
    margin: 0;
    padding: 0;
    background: none;
    border: none;
  }

  &.msg-error {
    color: var(--danger);
    margin: 0;
    padding: 0;
    background: none;
    border: none;
  }
}


/* ── 14. POST-PARSEO — botones de acción ────────────────────
   Fila con "Comparar con Sheet" y "Procesar reserva"         */
.post-parse-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}


/* ── 15. COMPARATIVA PDF vs Sheet ───────────────────────────*/

/* Columna de control (letra C) */
.cmp-ctrl-col,
.cmp-ctrl-cell {
  width: 28px;
  min-width: 28px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 6px !important;
}

/* Label de fuente: "SHEET" / "PDF" */
.cmp-src-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Colores de filas ── */

/* Todo coincide → fila Sheet verde clarito, fila PDF verde más oscuro */
tr.cmp-row-sheet.cmp-row-ok td { background: var(--ok-sheet); }
tr.cmp-row-pdf.cmp-row-ok   td { background: var(--ok-pdf); }

/* Diferencias en campos secundarios (company, flight_number, class,
   seat, luggage, reservation_code, eticket) → amarillo
   Sheet: fila entera. PDF: solo las celdas que difieren (cmp-cell-warn) */
tr.cmp-row-sheet.cmp-row-warn td { background: var(--warn-sheet); }

/* Celda PDF con diferencia secundaria → amarillo intenso */
td.cmp-cell-warn {
  background: var(--warn-pdf);
  color: var( --warn-text);
  font-weight: 600;
}

/* Diferencias en campos de identidad (name, surname, date, time,
   route) → rojo                                                     */
tr.cmp-row-sheet.cmp-row-diff td { background: var(--diff-sheet); }
tr.cmp-row-pdf.cmp-row-diff   td { background: var(--diff-pdf); }

/* Celda PDF con diferencia de identidad → rojo fuerte */
tr.cmp-row-pdf.cmp-row-diff td.cmp-cell-diff {
  background: var(--diff-cell);
  color: var(--diff-text);
  font-weight: 600;
}

/* No encontrado en Sheet */
tr.cmp-not-found td         { background: var(--notfound-bg); }
.cmp-not-found-msg          { color: var(--diff-text); font-size: 12px; font-style: italic; }

/* Celda vacía */
.cmp-blank { color: var(--border); }

/* Fila espaciadora entre bloques de pasajero */
tr.cmp-spacer td {
  height: 10px;
  border: none !important;
  background: transparent !important;
}

/* Negrita en fila Sheet */
tr.cmp-row-sheet td { font-weight: 700; }

/* Columna checkbox */
.cmp-chk-col {
  width: 28px;
  min-width: 28px;
  padding: 4px 6px !important;
}

.cmp-chk-cell {
  width: 28px;
  min-width: 28px;
  text-align: center;
  padding: 4px 6px !important;
  vertical-align: middle;
}

.cmp-checkbox {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}


/* ── 16. BARRA DE ACCIONES (actualizar sheet / subir PDF) ───*/
.cmp-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.cmp-drive-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: 1;
}

.cmp-filename-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  max-width: 520px;
}

.cmp-filename-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.cmp-filename-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmp-dup-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
}

.cmp-dup-warn {
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.cmp-dup-ok {
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.cmp-dup-validate {
  color: var(--accent);
  background: #eff6ff;
  border: 1px solid var(--accent);
  cursor: pointer;
}

.cmp-dup-validate:hover {
  background: #dbeafe;
}

.cmp-dup-checking {
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
}

.cmp-overwrite-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  cursor: pointer;
  font-weight: 600;
  color: #b45309;
}

.cmp-overwrite-label input[type="checkbox"] {
  cursor: pointer;
}

.cmp-process-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.cmp-folder-path {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  padding: 2px 0;
}

.cmp-filename-input {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);

  &:focus {
    outline: none;
    border-color: var(--accent);
  }
}

.cmp-updating {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}


/* ── 17. MODAL DE CONFIRMACIÓN ──────────────────────────────*/
.cmp-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;

  &[hidden] { display: none; }
}

.cmp-modal {
  background: var(--surface);
  border-radius: 10px;
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px var(--shadow);
}

.cmp-modal-title    { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.cmp-modal-subtitle { font-size: 12px; color: var(--muted); margin: 0 0 16px; }
.cmp-modal-body     { font-size: 12px; margin-bottom: 20px; }

/* Tabla compacta en modal */
.cmp-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;

  & th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 4px 8px 6px;
  }

  & td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
  }

  & tr:last-child td { border-bottom: none; }
}

.cmp-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}


/* ── 18. ENVÍO DE PDF A PASAJEROS ───────────────────────────*/

.drive-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.drive-result-row .msg-success { margin: 0; }

.send-modal { width: 540px; }

.send-no-email {
  color: var(--danger);
  font-style: italic;
  font-size: 12px;
}

.send-status-cell {
  font-size: 12px;
  color: var(--muted);
  min-width: 70px;
}

.send-status-ok  { color: var(--success); font-weight: 600; }
.send-status-err { color: var(--danger);  font-weight: 600; cursor: help; }
.send-status-skip { color: var(--muted);  font-style: italic; }


/* ── 19. RESPONSIVE ─────────────────────────────────────────
   Breakpoint único: < 768px colapsa el sidebar.              */
@media (max-width: 768px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding: 6px 8px;
    gap: 2px;
  }

  .nav-item {
    flex-direction: column;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 2px solid transparent;
    font-size: 11px;
    gap: 4px;
    white-space: nowrap;

    &.active {
      border-right-color: transparent;
      border-bottom-color: var(--accent);
    }
  }

  .content { padding: 16px; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .file-pick {
    flex-direction: column;
    align-items: stretch;
  }

  .file-name  { max-width: 100%; }

  .folder-select {
    min-width: 0;
    width: 100%;
  }

  .btn { justify-content: center; }
}
