/**
 * Estilos para Conversor de JSON a TypeScript
 * Fijate Tools
 */

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

  /* Paleta base (Tema oscuro por defecto) */
  --bg-app: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #182232;
  --bg-input: #090d14;
  --bg-surface: #1e293b;
  --border-color: #243247;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --ts-blue: #3178c6;
  --ts-blue-hover: #235a97;
  --ts-blue-light: rgba(49, 120, 198, 0.15);

  --accent-success: #10b981;
  --accent-success-bg: rgba(16, 185, 129, 0.12);
  --accent-danger: #ef4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.12);
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-surface: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;

  --ts-blue: #0284c7;
  --ts-blue-hover: #0369a1;
  --ts-blue-light: rgba(2, 132, 199, 0.1);

  --shadow-card: 0 4px 16px -2px rgba(0, 0, 0, 0.08);
}

/* Reset y estructura canónica */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  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,
.card-header-title {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  margin: 0;
}

.mono, code, pre, textarea.editor-box {
  font-family: var(--font-mono);
}

/* Layout canónico */
.main-wrapper.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%;
}

/* Tarjeta contenedora de la herramienta */
.converter-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* Barra superior de configuración */
.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-text, .input-select {
  height: 40px;
  min-height: 40px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-main);
  transition: var(--transition);
  width: 100%;
}

.input-text:focus, .input-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Conmutador de segmento (interface vs type) */
.segmented-control {
  display: flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  height: 40px;
  box-sizing: border-box;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.segment-btn.active {
  background-color: var(--ts-blue);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(49, 120, 198, 0.4);
}

/* Fila de switches / checkboxes */
.switches-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.switch-input {
  appearance: none;
  width: 36px;
  height: 20px;
  background-color: var(--bg-surface);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.switch-input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: var(--transition);
}

.switch-input:checked {
  background-color: var(--ts-blue);
  border-color: var(--ts-blue);
}

.switch-input:checked::after {
  transform: translateX(16px);
}

/* Fila de acciones y presets */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.presets-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.presets-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
}

.btn-chip {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-chip:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--ts-blue);
}

.btn-chip.active {
  background-color: var(--ts-blue-light);
  border-color: var(--ts-blue);
  color: var(--ts-blue);
  font-weight: 600;
}

.quick-tools-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-secondary {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  height: 36px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

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

.btn-primary {
  background-color: var(--ts-blue);
  border: none;
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  height: 36px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(49, 120, 198, 0.3);
}

.btn-primary:hover {
  background-color: var(--ts-blue-hover);
  box-shadow: 0 4px 12px rgba(49, 120, 198, 0.4);
}

/* Editor dual (Grid 2 columnas) */
.dual-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .dual-editor-grid {
    grid-template-columns: 1fr;
  }
}

.editor-pane {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 480px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.editor-status-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-valid {
  background-color: var(--accent-success-bg);
  color: var(--accent-success);
}

.badge-error {
  background-color: var(--accent-danger-bg);
  color: var(--accent-danger);
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-stat-pill {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background-color: var(--bg-surface);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.btn-pane-action {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition);
}

.btn-pane-action:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Área de texto / código */
.editor-body {
  position: relative;
  flex: 1 1 0%;
  display: flex;
  overflow: hidden;
}

textarea.editor-box {
  width: 100%;
  height: 100%;
  padding: 0.85rem;
  background: transparent;
  color: var(--text-main);
  border: none;
  outline: none;
  resize: none;
  font-size: 0.875rem;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

pre.code-display {
  margin: 0;
  padding: 0.85rem;
  width: 100%;
  height: 100%;
  overflow: auto;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #38bdf8;
  white-space: pre;
  background-color: transparent;
}

[data-theme="light"] pre.code-display {
  color: #0369a1;
}

/* Banner de error sintáctico */
.error-banner {
  display: none;
  background-color: var(--accent-danger-bg);
  border-top: 1px solid var(--accent-danger);
  padding: 0.6rem 0.85rem;
  font-size: 0.75rem;
  color: var(--accent-danger);
  align-items: center;
  gap: 0.5rem;
}

.error-banner.active {
  display: flex;
}

/* Barra inferior de métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.metric-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.metric-hint {
  font-size: 0.6875rem;
  color: var(--text-subtle);
}

/* Notificación flotante (toast) */
.toast-notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #10b981;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: var(--transition);
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* Modal accesible */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

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

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

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-close-modal:hover {
  color: var(--text-main);
  background-color: var(--bg-surface);
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-body h4 {
  color: var(--text-main);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.modal-body ul {
  margin: 0;
  padding-left: 1.25rem;
}

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

/* Responsividad en móvil */
@media (max-width: 768px) {
  .converter-card {
    padding: 1rem;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .editor-pane {
    height: 380px;
  }

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

  .presets-group, .quick-tools-group {
    justify-content: flex-start;
  }

  .toast-notification {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    justify-content: center;
  }
}
