/**
 * Estilos Principales - Limpiador y Optimizador de Código SVG
 * Fijate Tools - SVG Surgeon
 */

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

:root {
  /* Paleta Base Oscura (Predeterminada) */
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #334155;
  --bg-input: #0b1120;
  --bg-code: #070b12;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -5px rgba(59, 130, 246, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  --header-height: 68px;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-hover: #e2e8f0;
  --bg-input: #ffffff;
  --bg-code: #f8fafc;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: #2563eb;
  --border-strong: rgba(0, 0, 0, 0.16);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 25px -5px rgba(37, 99, 235, 0.2);
}

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

html {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 60%), var(--bg-app);
}

/* Cabecera Principal */
.app-header {
  height: var(--header-height);
  background-color: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

[data-theme="light"] .app-header {
  background-color: rgba(255, 255, 255, 0.88);
}

.header-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.brand-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
}

.btn-pill {
  border-radius: var(--radius-full);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-primary-hover), #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

/* Formularios y Controles */
.form-group {
  margin-bottom: 1rem;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

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

.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-control, .form-select, .form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus, .form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-select {
  cursor: pointer;
  appearance: auto;
}

/* Layout Principal de la Aplicación */
.app-main {
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem;
  flex: 1;
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1200px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* Paneles */
.panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.9rem 1.2rem;
  background-color: rgba(30, 41, 59, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

[data-theme="light"] .panel-header {
  background-color: rgba(241, 245, 249, 0.8);
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  margin: 0;
}

.panel-title svg {
  color: var(--accent-primary);
}

.panel-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Área de Carga e Ingesta */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  background-color: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

[data-theme="light"] .dropzone {
  background-color: rgba(248, 250, 252, 0.8);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-text h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.dropzone-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Barra de Ejemplos Rápidos */
.preset-pills-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.preset-pill {
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-pill:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Acordeones y Secciones de Configuración */
.config-accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-input);
}

.accordion-header {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  background-color: rgba(30, 41, 59, 0.3);
  transition: background-color 0.15s ease;
}

.accordion-header:hover {
  background-color: var(--bg-surface-hover);
}

.accordion-icon {
  transition: transform 0.2s ease;
}

.config-accordion.collapsed .accordion-icon {
  transform: rotate(-90deg);
}

.config-accordion.collapsed .accordion-content {
  display: none;
}

.accordion-content {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Checkbox Switch Toggle */
.switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
}

.switch-item .switch-label {
  display: flex;
  flex-direction: column;
}

.switch-item .switch-label small {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface-hover);
  transition: 0.2s;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* Control deslizante de precisión */
.precision-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.precision-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.precision-slider {
  flex: 1;
  height: 6px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.precision-val-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  min-width: 24px;
  text-align: center;
}

/* Tarjeta de Métricas y Ahorro */
.savings-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.savings-pct-group {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.savings-number {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-emerald);
  line-height: 1;
}

.savings-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.savings-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.savings-details strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Pie de página */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Utilidades */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: none;
}

.badge-emerald {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-blue {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-purple {
  background-color: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}
