/**
 * Generador de reglas .htaccess para Apache
 * Estilos específicos de la herramienta
 */

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

  /* Tema claro por defecto */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

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

  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --accent-cyan: #0284c7;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  /* Consola de código */
  --code-bg: #090d16;
  --code-header-bg: #111827;
  --code-border: #1f2937;
  --code-text: #e2e8f0;
  --code-comment: #6b7280;
  --code-keyword: #38bdf8;

  --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.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Modo oscuro corporativo */
[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-subtle: #192438;
  --bg-input: #101622;
  --border-color: #233149;
  --border-focus: #60a5fa;

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

  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.12);

  --code-bg: #070a10;
  --code-header-bg: #0f1522;
  --code-border: #1a2336;
}

/* Reset y contención canónica */
*, *::before, *::after {
  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;
  -webkit-font-smoothing: antialiased;
}

.text-mono {
  font-family: var(--font-mono) !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 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 temático */
.htaccess-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.hero-badge-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text-main);
  line-height: 1.25;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
  max-width: 900px;
}

/* Barra de presets rápidos */
.presets-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.btn-preset:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

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

.btn-preset-reset {
  margin-left: auto;
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.25);
}

.btn-preset-reset:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

/* Barra de navegación de módulos */
.module-nav-bar {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
}

.module-nav-btn {
  white-space: nowrap;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.module-nav-btn.active {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Tarjetas de módulos */
.module-card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.module-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.module-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-title-box h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-main);
}

.module-title-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

/* Opciones dentro del módulo */
.module-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.option-row {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  gap: 0.75rem;
}

.option-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.option-info {
  flex: 1 1 auto;
}

.option-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.option-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.tag-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  background: var(--border-color);
  color: var(--text-muted);
}

.tag-badge.badge-rec {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

/* Switch Toggle personalizado */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  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(--border-color);
  transition: 0.2s;
  border-radius: 24px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 2px var(--border-focus);
}

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

/* Radio buttons estilizados */
.radio-group-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.radio-card:hover {
  border-color: var(--primary-color);
}

.radio-card input[type="radio"] {
  accent-color: var(--primary-color);
  margin: 0;
}

/* Formularios y campos de entrada */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
  min-height: 40px;
  box-sizing: border-box;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-select {
  padding-right: 36px;
}

/* Subpaneles desplegables */
.subpanel-content {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

.inline-form-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.inline-form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 110px;
}

/* Filas dinámicas de redirección */
.dynamic-rows-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dynamic-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
}

.row-col-type {
  width: 130px;
  flex-shrink: 0;
}

.row-col-from, .row-col-to {
  flex: 1 1 0%;
  min-width: 0;
}

.row-col-arrow {
  color: var(--text-subtle);
  font-weight: bold;
}

.row-col-action {
  flex-shrink: 0;
}

.btn-remove-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-row:hover {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px dashed var(--primary-color);
  color: var(--primary-color);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-add-row:hover {
  background: var(--primary-light);
}

.empty-list-notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

/* Grid de páginas de error */
.error-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.error-doc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-doc-item span {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  width: 45px;
  flex-shrink: 0;
}

/* ====================================================================
   Panel de salida de código (.htaccess)
   ==================================================================== */
.code-output-card {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
}

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

.code-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.code-dots {
  display: flex;
  gap: 0.35rem;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.code-dot-red { background-color: #ef4444; }
.code-dot-yellow { background-color: #f59e0b; }
.code-dot-green { background-color: #10b981; }

.code-filename {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: #ffffff;
}

.code-stats-group {
  display: flex;
  gap: 0.5rem;
}

.stat-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
}

.code-actions-group {
  display: flex;
  gap: 0.5rem;
}

.btn-code-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
}

.btn-code-copy {
  background: var(--primary-color);
  border: 1px solid var(--primary-color);
  color: #ffffff;
}

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

.btn-code-download {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

.btn-code-download:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.code-viewport {
  position: relative;
  max-height: 520px;
  overflow-y: auto;
  padding: 1.25rem;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.code-output-pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--code-text);
  white-space: pre;
  tab-size: 2;
  word-break: normal;
  word-wrap: normal;
}

/* Toast flotante */
.app-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  z-index: 99999;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border: 1px solid #334155;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Modal de confirmación accesible */
.app-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

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

.app-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.app-modal-header h4 {
  font-family: var(--font-heading);
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-main);
}

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

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

.app-modal-body {
  padding: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.app-modal-footer {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-modal-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
}

.btn-modal-danger {
  background: var(--accent-rose);
  border: 1px solid var(--accent-rose);
  color: #ffffff;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

.btn-modal-danger:hover {
  background: #e11d48;
}

/* ====================================================================
   Sección SEO, Guía Didáctica y Acordeón FAQ
   ==================================================================== */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.seo-guide-header {
  margin-bottom: 1.5rem;
}

.seo-guide-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.seo-guide-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text-main);
}

.seo-guide-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.seo-content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.seo-article-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.seo-article-card h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: var(--text-main);
}

.seo-article-card p {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.seo-article-card ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.seo-article-card li {
  margin-bottom: 0.35rem;
}

.seo-callout-warning {
  border-left: 4px solid var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}

.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.seo-faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.seo-faq-item[open] {
  border-color: var(--primary-color);
}

.seo-faq-question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

.seo-faq-question::-webkit-details-marker {
  display: none;
}

.seo-faq-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.seo-faq-item[open] .seo-faq-icon {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.seo-faq-answer {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.seo-faq-answer p {
  margin: 0 0 0.5rem;
}

.seo-faq-answer p:last-child {
  margin-bottom: 0;
}

/* ====================================================================
   Media Queries Responsive (Mobile First & Desktop)
   ==================================================================== */
@media (min-width: 768px) {
  .module-options-grid {
    grid-template-columns: 1fr;
  }

  .seo-content-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 767px) {
  .hero-title {
    font-size: 1.45rem;
  }

  .presets-grid {
    flex-direction: column;
  }

  .btn-preset-reset {
    margin-left: 0;
  }

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

  .row-col-type {
    width: 100%;
  }

  .row-col-arrow {
    display: none;
  }

  .btn-remove-row {
    align-self: flex-end;
  }

  .code-header-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .code-actions-group {
    width: 100%;
    justify-content: stretch;
  }

  .btn-code-action {
    flex: 1 1 0%;
    justify-content: center;
  }

  .app-toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    text-align: center;
  }
}
