/* Dividir PDF Fácil — estilos propios de la herramienta.
   Se apoya en las variables y componentes ya definidos en styles.css
   (--accent, --surface, --border, .card, .chip, .btn, .faq-item, etc.) */

.split-tool { max-width: 900px; margin-inline: auto; }

/* ---------- Zona de carga (falta en el styles.css compartido: se define aquí) ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: .6rem;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-muted); padding: clamp(1.9rem, 6vw, 3rem) 1.25rem;
  cursor: pointer; transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out);
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 38px; height: 38px; color: var(--accent); flex: none; }
.dropzone .dz-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.dropzone .dz-hint { font-size: .85rem; color: var(--text-muted); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Estados del panel (idle · ready · working · done · error) ---------- */
.tool-panel { display: none; }
.split-tool[data-state="idle"] .dropzone { display: flex; }
.split-tool:not([data-state="idle"]) .dropzone { display: none; }

.split-tool[data-state="working"] .panel-progress,
.split-tool[data-state="done"] .panel-done,
.split-tool[data-state="error"] .panel-error { display: block; }

.split-tool[data-state="ready"] .panel-ready { display: block; }
.split-tool:not([data-state="ready"]) .panel-ready { display: none; }

/* ---------- Ficha del archivo cargado ---------- */
.file-summary-card {
  display: flex; align-items: center; gap: .8rem; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: .9rem 1rem;
  background: var(--surface-muted); margin-bottom: 1.1rem;
}
.file-summary-card .file-icon {
  width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong);
  display: grid; place-items: center; flex: none; font-size: 1.3rem;
}
.file-summary-card .file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.file-summary-card .file-meta strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-summary-card .file-meta span { font-size: .8rem; color: var(--text-muted); }
.file-summary-card .file-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; color: var(--success); }
.file-summary-card .file-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }
.file-summary-card .btn { flex: none; }

/* ---------- Barra de herramientas ---------- */
.split-toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.split-toolbar .toolbar-group { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.split-field { display: flex; flex-direction: column; gap: .35rem; flex: 1; min-width: 220px; }
.split-field label { font-size: .8rem; font-weight: 700; color: var(--text-muted); }
.split-field input[type="text"] {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .92rem;
  font-family: inherit;
}
.split-field input[type="text"]:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.split-field input.is-invalid { border-color: var(--danger); }
.split-field-error { font-size: .8rem; color: var(--danger); font-weight: 600; min-height: 1.1em; }
.split-field-hint { font-size: .78rem; color: var(--text-faint); }

/* ---------- Selector de modo ---------- */
.mode-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem; }
.mode-tab {
  flex: 1; min-width: 175px; text-align: left; display: flex; flex-direction: column; gap: .15rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: .7rem .9rem;
  background: var(--surface); cursor: pointer; transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.mode-tab:hover { border-color: var(--accent); }
.mode-tab strong { font-size: .88rem; }
.mode-tab span { font-size: .76rem; color: var(--text-muted); }
.mode-tab.is-active { border-color: var(--accent); background: var(--accent-soft); }
.mode-tab.is-active strong { color: var(--accent-strong); }
.mode-tab input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- Cuadrícula de páginas ---------- */
.pages-toolbar-note { font-size: .82rem; color: var(--text-muted); margin-bottom: .7rem; }
.pages-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem;
  max-height: 560px; overflow-y: auto; padding: .3rem; margin: 0 -0.3rem 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elevated);
}
@media (min-width: 720px) {
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 620px; }
}
.page-thumb {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .4rem; border: 2px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.page-thumb:hover { background: var(--surface-muted); }
.page-thumb:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.page-thumb.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.page-thumb.is-disabled { cursor: default; }
.page-thumb.is-disabled:hover { background: var(--surface); }
.page-thumb-frame {
  position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden;
  background: var(--surface-muted); border: 1px solid var(--border); display: grid; place-items: center;
}
.page-thumb-frame img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.page-thumb-frame .thumb-loading { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: split-spin .8s linear infinite; }
.page-thumb-num { font-size: .74rem; font-weight: 700; color: var(--text-muted); }
.page-thumb.is-selected .page-thumb-num { color: var(--accent-strong); }
.page-thumb-check {
  position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 1.5px solid var(--border-strong); display: grid; place-items: center;
  transition: all .15s var(--ease-out); pointer-events: none;
}
.page-thumb.is-selected .page-thumb-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-thumb-check svg { width: 12px; height: 12px; opacity: 0; transition: opacity .1s; }
.page-thumb.is-selected .page-thumb-check svg { opacity: 1; }
.page-thumb-order {
  position: absolute; top: 5px; left: 5px; min-width: 20px; height: 20px; padding: 0 .3rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 800; display: none; place-items: center;
}
.page-thumb.is-selected.has-order .page-thumb-order { display: grid; }
.page-thumb.is-selected.has-order .page-thumb-check { display: none; }
.page-thumb-zoom {
  position: absolute; bottom: 5px; right: 5px; width: 24px; height: 24px; border-radius: 7px;
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent); color: var(--text);
  display: grid; place-items: center; opacity: 0; transition: opacity .15s var(--ease-out);
}
.page-thumb:hover .page-thumb-zoom, .page-thumb:focus-visible .page-thumb-zoom { opacity: 1; }
.page-thumb-zoom svg { width: 13px; height: 13px; }
@keyframes split-spin { to { transform: rotate(360deg); } }

/* ---------- Tira de reordenación (páginas seleccionadas) ---------- */
.order-block { margin-bottom: 1.1rem; }
.order-block-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .55rem; }
.order-block-head h3 { font-size: .85rem; color: var(--text-muted); font-weight: 700; }
.order-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.order-chip {
  display: flex; align-items: center; gap: .4rem; padding: .35rem .4rem .35rem .6rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface);
  font-size: .82rem; font-weight: 700; cursor: grab;
}
.order-chip:active { cursor: grabbing; }
.order-chip.is-dragging { opacity: .4; }
.order-chip .chip-pos { color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.order-chip .chip-btns { display: flex; gap: 1px; }
.order-chip button {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--text-muted);
}
.order-chip button:hover { background: var(--surface-muted); color: var(--text); }
.order-chip button svg { width: 12px; height: 12px; }
.order-chip .chip-remove:hover { color: var(--danger); }

/* ---------- Modo: dividir por rangos ---------- */
.ranges-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.range-row { display: flex; align-items: center; gap: .5rem; }
.range-row input[type="text"] {
  flex: 1; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .92rem; font-family: inherit;
}
.range-row input.is-invalid { border-color: var(--danger); }
.range-row .range-label { font-size: .78rem; font-weight: 700; color: var(--text-faint); min-width: 4.2em; }
.range-row-error { font-size: .78rem; color: var(--danger); font-weight: 600; margin: -.2rem 0 0 4.7em; }

/* ---------- Modo: separar todas las páginas ---------- */
.each-mode-note {
  display: flex; gap: .7rem; align-items: flex-start; background: var(--accent-soft); color: var(--accent-strong);
  border-radius: var(--radius-sm); padding: .8rem 1rem; font-size: .88rem; font-weight: 600; margin-bottom: .8rem;
}
.each-mode-note svg { width: 19px; height: 19px; flex: none; margin-top: .1rem; }

/* ---------- Acciones principales ---------- */
.split-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.split-actions .btn-generate { min-width: 220px; }
.split-clear-row { text-align: center; margin-top: .6rem; }
.split-tool[data-state="working"] .split-clear-row,
.split-tool[data-state="done"] .split-clear-row,
.split-tool[data-state="error"] .split-clear-row { display: none; }

/* ---------- Progreso ---------- */
.panel-progress { text-align: center; padding: 1rem 0; }
.panel-progress .progress { max-width: 380px; margin: 0 auto .9rem; }

/* ---------- Resultado ---------- */
.panel-done { text-align: center; }
.done-icon { font-size: 2.2rem; margin-bottom: .4rem; }
.done-title { font-weight: 800; font-size: 1.15rem; margin-bottom: .3rem; }
.done-note { color: var(--text-muted); font-size: .92rem; margin-bottom: 1.1rem; }
.result-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .55rem; text-align: left; margin-bottom: 1.1rem; }
.result-row {
  display: flex; align-items: center; gap: .7rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: .65rem .8rem; background: var(--bg-elevated);
}
.result-row .file-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; flex: none; font-size: 1rem; }
.result-row .file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.result-row .file-meta strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .file-meta span { font-size: .76rem; color: var(--text-muted); }
.done-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; margin-bottom: .6rem; }

/* ---------- Error ---------- */
.panel-error { text-align: center; }
.error-icon { font-size: 2.2rem; margin-bottom: .4rem; }
.error-title { font-weight: 800; font-size: 1.1rem; margin-bottom: .3rem; }
.error-note { color: var(--text-muted); font-size: .92rem; margin-bottom: 1.1rem; }

/* ---------- Lightbox (ampliar página) ---------- */
dialog.page-lightbox { border: none; border-radius: var(--radius-lg); padding: 0; max-width: 92vw; width: 560px; background: var(--surface); color: var(--text); }
dialog.page-lightbox::backdrop { background: rgba(15, 17, 25, .6); }
.lightbox-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.lightbox-head strong { font-size: .92rem; }
.lightbox-close { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-muted); }
.lightbox-close:hover { background: var(--surface-muted); }
.lightbox-body { padding: 1.1rem; display: grid; place-items: center; min-height: 260px; }
.lightbox-body img { max-width: 100%; max-height: 70vh; border-radius: 6px; box-shadow: var(--shadow-md); background: #fff; }
.lightbox-nav { display: flex; justify-content: space-between; padding: .7rem 1rem 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 539.98px) {
  .mode-tab { min-width: 100%; }
  .split-field { min-width: 100%; }
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 460px; }
  /* El botón del cierre de página ("← Ver todas las herramientas de VivaFacilito")
     hereda white-space:nowrap de .btn en el styles.css compartido, lo que provoca
     desbordamiento horizontal con textos largos en pantallas muy estrechas. Se
     corrige aquí, sin tocar el CSS compartido con el resto de herramientas. */
  #closingCta .btn { white-space: normal; max-width: 100%; text-align: center; }
}
