/* ==========================================================================
   Diccionario de la rima y taller de métrica poética en español
   Estándar de diseño canónico fijate.com (Dark Mode nativo, acentos ámbar pluma y violeta)
   ========================================================================== */

:root {
  --bg-page: #0b0f17;
  --bg-card: #131b28;
  --bg-card-hover: #182335;
  --bg-surface: #1e293b;
  --border-color: #24344d;
  --border-focus: #f59e0b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --amber-gold: #f59e0b;
  --amber-gold-hover: #d97706;
  --amber-light: rgba(245, 158, 11, 0.15);
  --amber-glow: rgba(245, 158, 11, 0.35);
  --poet-purple: #8b5cf6;
  --poet-purple-light: rgba(139, 92, 246, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 10px 30px -4px rgba(0, 0, 0, 0.7);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-surface: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #d97706;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --amber-gold: #d97706;
  --amber-gold-hover: #b45309;
  --amber-light: rgba(217, 119, 6, 0.12);
  --amber-glow: rgba(217, 119, 6, 0.25);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 10px 30px -4px rgba(0, 0, 0, 0.15);
}

/* Reset y contención */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout institucional */
.tool-layout {
  max-width: 1240px;
  width: 100%;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

.tool-ad-sidebar {
  display: none;
  width: 300px;
  flex-shrink: 0;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
  }
}

.ad-sticky-box {
  position: sticky;
  top: 90px;
}

/* Barra de pestañas principal (Buscador de Rimas vs Taller Métrico) */
.tool-mode-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
  gap: 0.5rem;
}

.btn-mode-tab {
  flex: 1;
  height: 48px;
  min-height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: all 0.2s ease;
}

.btn-mode-tab:hover {
  color: var(--text-primary);
}

.btn-mode-tab.active {
  background: var(--amber-gold);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--amber-glow);
}

/* Sección 1: Buscador de rimas */
.rhyme-search-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}

.search-bar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.rhyme-input-wrapper {
  flex: 1 1 280px;
  position: relative;
}

.rhyme-input {
  width: 100%;
  height: 50px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rhyme-input:focus {
  outline: none;
  border-color: var(--amber-gold);
  box-shadow: 0 0 0 3px var(--amber-light);
}

.btn-find-rhymes {
  height: 50px;
  min-height: 40px;
  padding: 0 1.75rem;
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.4);
}

.btn-find-rhymes:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

/* Sugerencias de palabras */
.quick-words-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

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

.btn-quick-word {
  height: 32px;
  padding: 0 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-quick-word:hover {
  border-color: var(--amber-gold);
  color: var(--text-primary);
}

/* Cabecera y filtros de resultados */
.rhyme-results-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.rhyme-phonetic-badge {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.rhyme-phonetic-title {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.rhyme-suffix-tag {
  background: var(--amber-light);
  color: var(--amber-gold);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}

.rhyme-type-selector {
  display: inline-flex;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.btn-rhyme-type {
  height: 36px;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-rhyme-type.active {
  background: var(--bg-card);
  color: var(--amber-gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Cuadrícula de palabras que riman */
.rhyme-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.rhyme-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rhyme-card:hover {
  transform: translateY(-2px);
  border-color: var(--amber-gold);
  background: var(--bg-card-hover);
}

.rhyme-card-word {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rhyme-card-syllables {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Sección 2: Taller de Métrica y Análisis de Estrofas */
.workshop-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}

.workshop-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.workshop-title {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.poem-textarea {
  width: 100%;
  min-height: 180px;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'Outfit', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.poem-textarea:focus {
  outline: none;
  border-color: var(--amber-gold);
  box-shadow: 0 0 0 3px var(--amber-light);
}

/* Tabla de Desglose de Versos */
.verses-analysis-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.verses-analysis-table th,
.verses-analysis-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.verses-analysis-table th {
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.verse-text-col {
  font-family: 'Outfit', Georgia, serif;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.verse-syllables-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--amber-light);
  color: var(--amber-gold);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.9rem;
}

.verse-rhyme-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--poet-purple);
}

.stanza-summary-box {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.stanza-summary-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0;
}

/* Modal Canónico de Métrica Poética (Regla 251: position: fixed; inset: 0; z-index: 9999;) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-dialog {
  transform: scale(1);
}

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

.modal-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.btn-help-modal {
  height: 40px;
  min-height: 40px;
  padding: 0 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-help-modal:hover {
  border-color: var(--amber-gold);
  color: var(--amber-gold);
}

/* Toast */
.toast-rhyme {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--amber-gold);
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
