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

  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

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

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;

  --success: #10b981;
  --success-subtle: #ecfdf5;

  --danger: #ef4444;
  --danger-subtle: #fef2f2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html.dark,
[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-card: #131b2e;
  --bg-card-alt: #1a243b;
  --bg-input: #1a243b;
  --border-color: #24324f;
  --border-focus: #60a5fa;

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

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: #1e293b;

  --success: #34d399;
  --success-subtle: #064e3b;

  --danger: #f87171;
  --danger-subtle: #450a0a;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  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,
.column-title,
.tester-title,
.faq-section-title {
  font-family: var(--font-heading);
}

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

/* Layout */
.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%;
}

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

/* Plantillas */
.preset-section {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.preset-header {
  margin-bottom: 0.75rem;
}

.preset-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-right: 0.5rem;
}

.preset-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.preset-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-preset.highlight-preset {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

/* Pestañas */
.tool-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tool-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tool-tab-btn:hover {
  color: var(--text-main);
}

.tool-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Layout 2 columnas en Editor */
.editor-two-columns {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: start;
}

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

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

.column-title {
  font-size: 1.05rem;
  margin: 0;
}

.btn-sm-action {
  background: var(--primary-subtle);
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sm-action:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Grupos de User-agent */
.agent-groups-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.agent-group-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  position: relative;
}

.group-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.group-agent-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.btn-remove-group {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-group:hover {
  background: var(--danger-subtle);
}

.rules-sub-section {
  margin-top: 0.75rem;
}

.rules-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.rules-sub-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.title-disallow {
  color: var(--danger);
}

.title-allow {
  color: var(--success);
}

.rule-path-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.rule-path-input {
  flex: 1;
}

.btn-remove-rule {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-remove-rule:hover {
  color: var(--danger);
}

.crawl-delay-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
}

.crawl-delay-input {
  width: 90px;
}

/* Sitemaps */
.sitemaps-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

.sitemaps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sitemaps-title {
  font-size: 0.95rem;
  margin: 0;
}

.sitemap-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

/* Columna de código */
.code-header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action-icon {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-action-icon:hover {
  background: var(--border-color);
}

.textarea-wrapper {
  margin-bottom: 0.75rem;
}

.robots-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 480px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main);
  resize: vertical;
}

.robots-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.code-footer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-sync-reverse {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sync-reverse:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Simulador RFC 9309 */
.tester-container {
  padding: 0.5rem 0;
}

.tester-title {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.tester-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.tester-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
  .tester-form-grid {
    grid-template-columns: 1fr;
  }
}

.input-with-select {
  display: flex;
  gap: 0.5rem;
}

.select-inline {
  width: auto;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 0.5rem;
}

.tester-actions-row {
  margin-bottom: 1.5rem;
}

.tester-verdict-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.verdict-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.verdict-badge {
  padding: 0.45rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.verdict-badge.badge-allowed {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid var(--success);
}

.verdict-badge.badge-disallowed {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.verdict-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.verdict-details {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* Formularios genéricos */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: border-color 0.2s ease;
}

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

select.form-control,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  -webkit-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='%2364748b' 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 0.85rem center;
  background-size: 16px 16px;
  padding-right: 40px;
  cursor: pointer;
  color-scheme: dark light;
}

select option,
select optgroup {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.btn-link-action {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link-action:hover {
  color: var(--primary-hover);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

/* Toast de notificación */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  z-index: 9999;
}

/* Modal */
.app-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  box-sizing: border-box;
}

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

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

.app-modal-title {
  margin: 0;
  font-size: 1.1rem;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

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

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

/* FAQ */
.faq-section {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

.faq-section-title {
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

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

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.faq-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}

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

.faq-answer p {
  margin: 0;
}
