/**
 * Estilos para Foliador y numerador de expedientes en PDF
 * Cumple con estándares canónicos de Fijate Tools
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #151d2a;
  --bg-card-alt: #1c2637;
  --border-color: #273549;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.panel-title,
.doc-info-filename {
  font-family: var(--font-heading);
}

.mono,
.doc-info-pages,
.preview-page-info {
  font-family: var(--font-mono);
}

/* Layout canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Hero introductorio */
.tool-intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.tool-intro-title {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
}

.tool-intro-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Zona de subida Drag & Drop */
.uploader-card {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.uploader-card:hover,
.uploader-card.drag-active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.uploader-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 1rem;
}

.uploader-title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.uploader-subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.uploader-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.btn-file-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  min-height: 40px;
}

.btn-file-select:hover {
  background: var(--primary-hover);
}

.btn-sample {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.25);
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 40px;
}

.btn-sample:hover {
  background: rgba(22, 163, 74, 0.18);
}

/* Barra del documento activo */
.doc-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
}

.doc-info-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.doc-info-filename {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.doc-info-pages {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-change-doc {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.btn-change-doc:hover {
  background: var(--primary-light);
}

/* Área de trabajo de foliación */
.foliation-workspace {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: start;
}

/* Panel de controles izquierdo */
.foliation-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.panel-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.control-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px dashed var(--border-color);
}

.control-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.control-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  min-height: 38px;
  background: var(--bg-card-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

/* Selector de posición en cuadrante 3x2 */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.btn-pos-quadrant {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-pos-quadrant:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

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

/* Paleta de colores */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.color-swatch-text {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease;
}

.color-swatch-text.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: var(--text-main);
  cursor: pointer;
  margin-top: 0.4rem;
}

/* Panel de visualización derecho */
.preview-viewer-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewer-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.viewer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

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

.btn-page-nav {
  background: var(--bg-card-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.btn-page-nav:hover {
  background: var(--border-color);
}

.preview-page-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Canvas del visor */
.canvas-wrapper {
  background: #cbd5e1;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  justify-content: center;
  width: 100%;
  overflow-x: auto;
}

.preview-canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  background: #ffffff;
  display: block;
}

/* Barra de acción principal de descarga */
.action-process-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.btn-process {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s ease;
}

.btn-process:hover {
  background: var(--primary-hover);
}

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

/* Barra de progreso */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-card-alt);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* Estado vacío */
.empty-state-card {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.spin-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Modal */
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.app-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-body {
  padding: 1.25rem;
  color: var(--text-main);
  font-size: 0.92rem;
  line-height: 1.55;
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-card-alt);
}

.hidden {
  display: none !important;
}

/* Responsive móvil */
@media (max-width: 900px) {
  .foliation-workspace {
    grid-template-columns: 1fr;
  }

  .action-process-card {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-process {
    width: 100%;
    justify-content: center;
  }
}
