/* ============================================================
   Leermas — Estilos personalizados
   ============================================================ */

/* ── Tipografía Inter (self-hosted) ──────────────────────── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../vendor/fonts/inter-variable.woff2') format('woff2');
}

/* ── Variables ───────────────────────────────────────────── */
:root {
  --nivel-inicial:    #dc3545;
  --nivel-elemental:  #fd7e14;
  --nivel-adecuado:   #198754;
  --nivel-destacado:  #0d6efd;

  /* Marca Leermas */
  --brand-primary:       #3B5BDB;
  --brand-primary-dark:  #2F4AC7;
  --brand-primary-light: #EEF2FF;
  --brand-primary-rgb:   59, 91, 219;
  --body-bg:             #F7F8FC;
  --border-color:        #E5E7F0;
  --text-primary:        #1A1D2E;
  --text-muted:          #6B7280;
}

/* ── Texto de evaluación ─────────────────────────────────── */
.eval-text {
  font-size: 1.4rem;
  line-height: 2.4rem;
  font-family: 'Georgia', serif;
  color: #1a1a1a;
  user-select: none;
}

.eval-text-resultado {
  font-size: 1.2rem;
  line-height: 2rem;
  font-family: 'Georgia', serif;
}

/* ── Palabras clickeables ────────────────────────────────── */
.palabra {
  cursor: default;
  border-radius: 4px;
  padding: 2px 3px;
  transition: background-color 0.12s, color 0.12s;
  display: inline;
}

.eval-activa .palabra {
  cursor: pointer;
}

.eval-activa .palabra:hover {
  background-color: #fff3cd;
  outline: 2px solid #ffc107;
}

.palabra.error {
  border-radius: 4px;
  position: relative;
  background-color: #f8d7da;
  color: #842029;
  text-decoration: line-through;
}

/* Sustitución: tachado rojo */
.palabra.error-sustitucion {
  background-color: #f8d7da;
  color: #842029;
  text-decoration: line-through;
}

/* Omisión: subrayado naranja con guiones */
.palabra.error-omision {
  background-color: #fff3cd;
  color: #664d03;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: #fd7e14;
}

/* Vacilación: borde punteado azul */
.palabra.error-vacilacion {
  background-color: #cff4fc;
  color: #055160;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #0dcaf0;
}

/* Etiqueta de tipo sobre la palabra */
.palabra.error::after {
  content: attr(data-tipo-label);
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  background: #212529;
  color: white;
  padding: 0px 3px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.85;
}

/* En resultado */
.palabra-error-S {
  background-color: #f8d7da;
  color: #842029;
  text-decoration: line-through;
  border-radius: 4px;
  padding: 1px 3px;
}
.palabra-error-O {
  background-color: #fff3cd;
  color: #664d03;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: #fd7e14;
  border-radius: 4px;
  padding: 1px 3px;
}
.palabra-error-V {
  background-color: #cff4fc;
  color: #055160;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #0dcaf0;
  border-radius: 4px;
  padding: 1px 3px;
}

.palabra.ultima {
  background-color: #d1e7dd;
  border-bottom: 3px solid #198754;
}

.signo { color: #555; }

/* ── Resultado con errores ───────────────────────────────── */
.palabra-error {
  background-color: #f8d7da;
  color: #842029;
  text-decoration: line-through;
  border-radius: 4px;
  padding: 1px 3px;
}

/* ── Panel de evaluación ─────────────────────────────────── */
.eval-container {
  margin: -1rem -1rem 0;
}

.eval-topbar {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  padding: 0.6rem 1.2rem;
  position: sticky;
  top: 56px;
  z-index: 100;
}

.eval-sidebar {
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 100px;
}

.eval-text-panel {
  background: #fff;
  overflow-y: auto;
}

/* ── Indicador de grabación ──────────────────────────────── */
.grabando-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #dc3545;
  opacity: 0;
  transition: opacity 0.3s;
}

.grabando-indicator.visible { opacity: 1; }

.grabando-dot {
  width: 10px;
  height: 10px;
  background: #dc3545;
  border-radius: 50%;
  animation: pulso 1s infinite;
}

@keyframes pulso {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Indicador de pasos de evaluación ───────────────────── */
.eval-steps {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 0.75rem;
}

.eval-step {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  color: #adb5bd;
  transition: all 0.3s;
  white-space: nowrap;
}

.eval-step.active {
  background: #e7f1ff;
  color: #0d6efd;
  font-weight: 600;
}

.eval-step.done {
  color: #198754;
}

.eval-step-sep {
  color: #dee2e6;
  font-size: 0.9rem;
}

/* ── Rúbrica ─────────────────────────────────────────────── */
.rubrica-btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.1rem;
  line-height: 1.3;
}

/* Colores por nivel al seleccionar */
#entonacion-1:checked + .rubrica-btn,
#pausas-1:checked + .rubrica-btn,
#prosodia-1:checked + .rubrica-btn {
  background-color: var(--nivel-inicial);
  border-color: var(--nivel-inicial);
  color: white;
}

#entonacion-2:checked + .rubrica-btn,
#pausas-2:checked + .rubrica-btn,
#prosodia-2:checked + .rubrica-btn {
  background-color: var(--nivel-elemental);
  border-color: var(--nivel-elemental);
  color: white;
}

#entonacion-3:checked + .rubrica-btn,
#pausas-3:checked + .rubrica-btn,
#prosodia-3:checked + .rubrica-btn {
  background-color: var(--nivel-adecuado);
  border-color: var(--nivel-adecuado);
  color: white;
}

#entonacion-4:checked + .rubrica-btn,
#pausas-4:checked + .rubrica-btn,
#prosodia-4:checked + .rubrica-btn {
  background-color: var(--nivel-destacado);
  border-color: var(--nivel-destacado);
  color: white;
}

/* Hover por nivel */
.rubrica-opc-1:hover { border-color: var(--nivel-inicial) !important; color: var(--nivel-inicial) !important; }
.rubrica-opc-2:hover { border-color: var(--nivel-elemental) !important; color: var(--nivel-elemental) !important; }
.rubrica-opc-3:hover { border-color: var(--nivel-adecuado) !important; color: var(--nivel-adecuado) !important; }
.rubrica-opc-4:hover { border-color: var(--nivel-destacado) !important; color: var(--nivel-destacado) !important; }

/* ── Badges de nivel ─────────────────────────────────────── */
.nivel-badge {
  font-size: 1.1rem;
  padding: 0.4em 0.8em;
}

.badge-nivel-inicial    { background-color: var(--nivel-inicial) !important; }
.badge-nivel-elemental  { background-color: var(--nivel-elemental) !important; }
.badge-nivel-adecuado   { background-color: var(--nivel-adecuado) !important; }
.badge-nivel-destacado  { background-color: var(--nivel-destacado) !important; }

/* ── Badges de grado ─────────────────────────────────────── */
.badge-grado-2B { background-color: #6f42c1 !important; }
.badge-grado-3B { background-color: #0d6efd !important; }
.badge-grado-4B { background-color: #0dcaf0 !important; color: #000 !important; }
.badge-grado-5B { background-color: #198754 !important; }
.badge-grado-6B { background-color: #fd7e14 !important; }
.badge-grado-7B { background-color: #dc3545 !important; }
.badge-grado-8B { background-color: #212529 !important; }

/* ── PPM contexto barra ──────────────────────────────────── */
.ppm-contexto-bar {
  height: 8px;
  border-radius: 4px;
  background: #e9ecef;
  position: relative;
  overflow: visible;
}

.ppm-contexto-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.ppm-contexto-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  background: #198754;
  border-radius: 2px;
  transform: translateX(-50%);
}

/* ── Flechas de tendencia ────────────────────────────────── */
.tendencia-sube   { color: #198754; font-weight: 700; }
.tendencia-baja   { color: #dc3545; font-weight: 700; }
.tendencia-igual  { color: #6c757d; }

/* ── Dashboard cards ─────────────────────────────────────── */
.card {
  border-radius: 12px;
}

.stat-card {
  border-left: 4px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1) !important;
}

.stat-card-primary  { border-left-color: #0d6efd; }
.stat-card-success  { border-left-color: #198754; }
.stat-card-warning  { border-left-color: #ffc107; }
.stat-card-info     { border-left-color: #0dcaf0; }

/* ── Tabla hover suave ───────────────────────────────────── */
.table-hover > tbody > tr:hover > td {
  background-color: #f0f4ff;
}

/* ── Botones de acción en tablas ─────────────────────────── */
.btn-accion {
  min-width: 34px;
  min-height: 34px;
}

/* ── Modal de confirmación ───────────────────────────────── */
.modal-confirm-icon {
  font-size: 3rem;
  color: #dc3545;
}

/* ── Búsqueda live ───────────────────────────────────────── */
.highlight-match {
  background-color: #fff3cd;
  border-radius: 2px;
}

/* ── Alerta de estado vacío ──────────────────────────────── */
.estado-vacio {
  padding: 3rem 1rem;
  text-align: center;
  color: #adb5bd;
}

.estado-vacio i {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
}

/* ── Flash messages mejorados ────────────────────────────── */
.alert {
  border-radius: 8px;
}

/* ── Design System ───────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background-color: var(--body-bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Color primario de marca */
.bg-primary                            { background-color: var(--brand-primary) !important; }
.text-primary                          { color: var(--brand-primary) !important; }
.btn-primary                           { background-color: var(--brand-primary) !important; border-color: var(--brand-primary) !important; }
.btn-primary:hover, .btn-primary:focus { background-color: var(--brand-primary-dark) !important; border-color: var(--brand-primary-dark) !important; }
.btn-outline-primary                   { color: var(--brand-primary) !important; border-color: var(--brand-primary) !important; }
.btn-outline-primary:hover             { background-color: var(--brand-primary) !important; color: #fff !important; }
.badge.bg-primary                      { background-color: var(--brand-primary) !important; }
.eval-step.active                      { background: var(--brand-primary-light); color: var(--brand-primary); }

/* Navbar */
.navbar {
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}
.navbar .nav-link {
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  border-radius: 6px;
  transition: background-color 0.15s;
}
.navbar .nav-link:hover,
.navbar .nav-link.active               { background-color: rgba(255,255,255,.12); }

/* Cards */
.card.shadow-sm {
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05) !important;
  border: 1px solid var(--border-color) !important;
}
.card-header {
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  padding: 0.85rem 1.25rem;
}
.card-header.bg-primary                { background-color: var(--brand-primary) !important; }

/* Table headers */
.table thead th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
  background-color: var(--brand-primary-light) !important;
  border-bottom: 2px solid var(--brand-primary) !important;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  white-space: nowrap;
}
.table-light > :not(caption) > * > *   { background-color: var(--brand-primary-light) !important; }
.table-hover > tbody > tr:hover > td   { background-color: var(--brand-primary-light); }

/* Forms */
.form-control, .form-select {
  border-color: var(--border-color);
  border-radius: 8px;
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .15);
  outline: none;
}
.input-group-text {
  background-color: #F3F4F8;
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* Buttons */
.btn {
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 8px;
}
.btn-lg                                { border-radius: 10px; font-weight: 600; }
.btn:active                            { transform: translateY(1px); }

/* Dropdown menus */
.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.10);
  padding: 0.4rem;
}
.dropdown-item {
  border-radius: 6px;
  font-size: 0.875rem;
  padding: 0.45rem 0.75rem;
}
.dropdown-item:hover, .dropdown-item:focus {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
}

/* Stat cards */
.stat-card-primary                     { border-left-color: var(--brand-primary); }

/* Footer */
footer.border-top                      { border-top-color: var(--border-color) !important; }

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .no-print, nav, footer, .navbar, .btn, .alert, form { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
  body { font-size: 12pt; }
  .eval-text-resultado { font-size: 11pt; line-height: 1.8; }
  .container-fluid { padding: 0; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .eval-sidebar {
    max-height: none;
    position: static;
    border-right: none;
    border-bottom: 2px solid #dee2e6;
  }
  .eval-text { font-size: 1.15rem; line-height: 2rem; }
  .eval-steps { display: none; }
  .btn-accion { min-width: 38px; min-height: 38px; }
}
