/* ============================================================
   COMPARADOR VISUAL DE TEXTO Y CÓDIGO (DIFF) - FIJATE TOOLS
   Diseño moderno, fluido, accesible y 100 % local
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-body: #0c0f17;
  --bg-surface: #141824;
  --bg-card: rgba(26, 32, 48, 0.7);
  --bg-card-hover: rgba(32, 40, 60, 0.85);
  --bg-input: #101420;
  --bg-editor: #090c13;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #ff8507;
  --primary: #ff8507;
  --primary-hover: #ff9924;
  --primary-glow: rgba(255, 133, 7, 0.25);
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --diff-added-bg: rgba(16, 185, 129, 0.16);
  --diff-added-border: rgba(16, 185, 129, 0.4);
  --diff-added-text: #34d399;
  --diff-added-inline: rgba(16, 185, 129, 0.35);
  --diff-removed-bg: rgba(244, 63, 94, 0.16);
  --diff-removed-border: rgba(244, 63, 94, 0.4);
  --diff-removed-text: #fb7185;
  --diff-removed-inline: rgba(244, 63, 94, 0.35);
  --diff-changed-bg: rgba(245, 158, 11, 0.14);
  --diff-changed-border: rgba(245, 158, 11, 0.35);
  --diff-changed-text: #fbbf24;
  --diff-lineno-bg: rgba(0, 0, 0, 0.25);
  --diff-lineno-color: #64748b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.25);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-editor: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #ff8507;
  --diff-added-bg: #e6f9f0;
  --diff-added-border: #a7f3d0;
  --diff-added-text: #047857;
  --diff-added-inline: #bbf7d0;
  --diff-removed-bg: #ffe4e6;
  --diff-removed-border: #fecdd3;
  --diff-removed-text: #be123c;
  --diff-removed-inline: #fecdd3;
  --diff-changed-bg: #fef3c7;
  --diff-changed-border: #fde68a;
  --diff-changed-text: #b45309;
  --diff-lineno-bg: #e2e8f0;
  --diff-lineno-color: #64748b;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   CABECERA
   ============================================================ */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 133, 7, 0.2), rgba(255, 153, 36, 0.2));
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

.badge-local {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

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

/* ============================================================
   CONTENEDOR PRINCIPAL
   ============================================================ */
.main-wrapper {
  flex: 1;
  max-width: 1500px;
  width: 100%;
  margin: 1.5rem auto 4rem auto;
  padding: 0 1.5rem;
}

@media (min-width: 1440px) {
  .main-wrapper {
    max-width: 1680px;
  }
}

.tool-hero {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.tool-hero-text h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tool-hero-text p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 780px;
}

.hero-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* ============================================================
   BARRA DE CONTROLES Y OPCIONES
   ============================================================ */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--primary);
  color: #0b0f17 !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 133, 7, 0.35);
}

.options-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  accent-color: var(--primary);
}

.granularity-select {
  padding: 0.4rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}

/* ============================================================
   ESTADÍSTICAS DEL DIFF
   ============================================================ */
.stats-banner {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 600;
}

.stat-chip.added {
  color: var(--diff-added-text);
  border-color: var(--diff-added-border);
  background: var(--diff-added-bg);
}

.stat-chip.removed {
  color: var(--diff-removed-text);
  border-color: var(--diff-removed-border);
  background: var(--diff-removed-bg);
}

.stat-chip.changed {
  color: var(--diff-changed-text);
  border-color: var(--diff-changed-border);
  background: var(--diff-changed-bg);
}

.stat-chip.similarity {
  color: var(--accent-cyan);
  margin-left: auto;
}

/* ============================================================
   ÁREAS DE ENTRADA (ORIGINAL Y MODIFICADO)
   ============================================================ */
.editors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.editor-header {
  padding: 0.75rem 1.1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.editor-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.editor-actions {
  display: flex;
  gap: 0.4rem;
}

.editor-btn-small {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition);
}

.editor-btn-small:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.editor-textarea {
  width: 100%;
  height: 260px;
  padding: 1rem;
  background: var(--bg-editor);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.5;
  border: none;
  resize: vertical;
  outline: none;
  white-space: pre;
  tab-size: 2;
}

.editor-footer {
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Botón central de intercambiar */
.swap-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.btn-swap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-swap:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
  border-color: var(--primary);
  transform: scale(1.03);
}

/* ============================================================
   VISOR DE DIFERENCIAS (RENDERIZADO DEL DIFF)
   ============================================================ */
.diff-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 2.5rem;
}

.diff-header {
  padding: 1rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.diff-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.diff-actions {
  display: flex;
  gap: 0.6rem;
}

.btn-diff-action {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-diff-action:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #0b0f17 !important;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(255, 133, 7, 0.35);
}

.diff-content-wrapper {
  background: var(--bg-editor);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Tabla Side-by-Side */
.diff-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.diff-row {
  display: table-row;
}

.diff-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.diff-cell {
  display: table-cell;
  padding: 0.15rem 0.5rem;
  white-space: pre-wrap;
  word-break: break-all;
  vertical-align: top;
}

.diff-lineno {
  width: 45px;
  min-width: 45px;
  max-width: 45px;
  background: var(--diff-lineno-bg);
  color: var(--diff-lineno-color);
  text-align: right;
  padding-right: 0.6rem;
  user-select: none;
  font-size: 0.78rem;
  border-right: 1px solid var(--border-color);
}

.diff-text {
  width: calc(50% - 45px);
  padding-left: 0.75rem;
}

/* Colores de estado */
.diff-row.added .diff-text,
.diff-row.added {
  background-color: var(--diff-added-bg);
  color: var(--diff-added-text);
}

.diff-row.removed .diff-text,
.diff-row.removed {
  background-color: var(--diff-removed-bg);
  color: var(--diff-removed-text);
}

.diff-row.changed .diff-text,
.diff-row.changed {
  background-color: var(--diff-changed-bg);
  color: var(--diff-changed-text);
}

.diff-cell.empty {
  background: rgba(0, 0, 0, 0.15);
}

.inline-del {
  background-color: var(--diff-removed-inline);
  border-radius: 3px;
  text-decoration: line-through;
  padding: 0 2px;
}

.inline-ins {
  background-color: var(--diff-added-inline);
  border-radius: 3px;
  font-weight: bold;
  padding: 0 2px;
}

/* Vista Unificada */
.diff-unified-row {
  display: flex;
  width: 100%;
}

.diff-unified-linenos {
  display: flex;
  width: 80px;
  min-width: 80px;
  background: var(--diff-lineno-bg);
  border-right: 1px solid var(--border-color);
  user-select: none;
}

.diff-unified-lineno {
  width: 40px;
  text-align: right;
  padding-right: 0.4rem;
  color: var(--diff-lineno-color);
  font-size: 0.78rem;
}

.diff-unified-prefix {
  width: 25px;
  text-align: center;
  font-weight: 700;
  user-select: none;
}

.diff-unified-code {
  flex: 1;
  padding-left: 0.6rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Estado sin diferencias */
.no-diff-banner {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.no-diff-banner svg {
  color: var(--accent-emerald);
  margin-bottom: 0.75rem;
}

.no-diff-banner h4 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

/* ============================================================
   MODAL Y TOAST
   ============================================================ */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

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

.custom-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 460px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.custom-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.custom-modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.custom-modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.custom-modal-body p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.custom-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-modal-secondary {
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
}

.btn-modal-danger {
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-rose);
  border: none;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.toast-notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
}

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

.toast-notification svg {
  color: var(--accent-emerald);
}

/* FAQ y sección educativa */
.edu-section {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border-color);
}

.edu-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.faq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}

.faq-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.faq-card h4 svg {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.faq-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.55;
}
