/* ==========================================================================
   MATELORA - COMPONENTS, MICROINTERACTIONS & PAYWALL
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. EXPANDABLE SEARCH BAR (MICROINTERACTION)
   -------------------------------------------------------------------------- */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 !important;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: width 320ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast);
  cursor: pointer;
  z-index: 10;
  box-sizing: border-box;
}

.search-container:hover {
  background-color: var(--primary-50);
  border-color: var(--primary-200);
}

.search-container:hover .search-trigger-btn {
  color: var(--primary-600);
}

/* Expanded State */
.search-container.is-expanded {
  width: 380px;
  justify-content: flex-start;
  padding: 0 0.75rem 0 1rem !important;
  background-color: var(--bg-surface);
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), var(--shadow-md);
  cursor: default;
}

/* Hide magnifying glass whenever search is deployed (desktop expanded or mobile overlay) */
.search-container.is-expanded .search-trigger-btn,
.search-container.mobile-overlay-active .search-trigger-btn {
  display: none !important;
}

.search-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  line-height: 1;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.search-trigger-btn svg {
  display: block;
  margin: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.search-trigger-btn:hover {
  color: var(--primary-700);
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.95rem;
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  box-sizing: border-box;
}

/* When search is closed, hide the input so it doesn't displace the icon */
.search-container:not(.is-expanded):not(.mobile-overlay-active) .search-input {
  display: none !important;
  width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* When search is open (desktop expanded OR mobile overlay active), show input clearly */
.search-container.is-expanded .search-input,
.search-container.mobile-overlay-active .search-input {
  display: block !important;
  opacity: 1 !important;
  width: 100% !important;
  pointer-events: auto !important;
}

.search-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  margin-right: 6px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-container.is-expanded.has-value .search-clear-btn {
  display: flex;
}

.search-clear-btn:hover {
  background-color: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.search-overlay-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  margin-right: 6px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-overlay-close-btn:hover {
  background-color: var(--bg-surface-secondary);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   2. BUTTONS & ACTIONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-normal);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  opacity: 0.95;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.btn-outline {
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-surface-hover);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
  border-radius: var(--radius-sm);
}

/* Pro / Payment Simulation Button */
/* Header Plan Indicator Badge (PRO / FREE) */
.btn-pro-action {
  background: var(--pro-gradient);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.75px;
  font-size: 0.85rem;
  padding: 0.38rem 0.95rem;
  border-radius: 99px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-pro-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.45);
}

.btn-free-action {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 800;
  letter-spacing: 0.75px;
  font-size: 0.85rem;
  padding: 0.38rem 0.95rem;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-free-action:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   3. BADGES & LABELS
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-nm {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-ns {
  background-color: #f3e8ff;
  color: #6b21a8;
}

.badge-tema {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.badge-asignatura {
  background-color: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.badge-prueba {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-p1 {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-p2 {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-p3 {
  background-color: #fae8ff;
  color: #86198f;
  border: 1px solid #f0abfc;
}

.badge-facil {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.badge-medio {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-dificil {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.badge-calc-yes {
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-calc-no {
  background-color: #f1f5f9;
  color: #64748b;
}

.badge-pro {
  background: var(--pro-gradient);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

.badge-free {
  background-color: #f1f5f9;
  color: #475569;
}

.badge-points {
  background-color: #fdf4ff;
  color: #86198f;
  border: 1px solid #f0abfc;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   4. QUESTION CARDS
   -------------------------------------------------------------------------- */
.question-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  overflow: hidden;
}

.question-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-top-bar {
  padding: 1.25rem 1.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid #f8fafc;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.card-body {
  padding: 1rem 1.5rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin: 0;
}

.card-latex-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  overflow-x: auto;
  padding: 0.5rem 0;
}

/* MathJax display blocks spacing inside cards */
.card-latex-content mjx-container[jax="CHTML"][display="true"] {
  margin: 0.75em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

.card-snippet {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer-action {
  padding: 1rem 1.5rem 1.25rem;
  background-color: #fafbfc;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.btn-open-exercise {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-open-exercise:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* --------------------------------------------------------------------------
   VISTA DE DETALLE / EJERCICIO EN GRANDE (DENTRO DE LA MISMA WEB)
   -------------------------------------------------------------------------- */
.exercise-detail-view {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  width: 100%;
}

.exercise-detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.exercise-detail-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  padding: 2.25rem 2.25rem 2.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .exercise-detail-card {
    padding: 1.5rem 1.25rem;
  }
}

.exercise-detail-header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
}

.exercise-detail-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.35;
  margin-top: 0.5rem;
}

.exercise-detail-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 2rem;
}

.exercise-detail-actions {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-top: 2rem;
}

.exercise-detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

/* --------------------------------------------------------------------------
   5. INTERACTIVE ANSWER & FEEDBACK AREA
   -------------------------------------------------------------------------- */
.card-action-area {
  padding: 1rem 1.25rem 1.25rem;
  background-color: #fafbfc;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.answer-form {
  display: flex;
  gap: 0.5rem;
}

.answer-input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.answer-input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Feedback alert boxes */
.feedback-box {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.4;
  animation: fadeIn 200ms ease;
}

.feedback-box.is-correct {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.feedback-box.is-incorrect {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Solution toggle */
.solution-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--primary-600);
  align-self: flex-start;
  margin-top: 0.25rem;
  transition: color var(--transition-fast);
}

.solution-toggle-btn:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

.solution-content {
  display: none;
  padding: 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-x: auto;
}

.solution-content.is-visible {
  display: block;
}

/* --------------------------------------------------------------------------
   6. PAYWALL & BLURRED CARDS (PREMIUM LOCK)
   -------------------------------------------------------------------------- */
.question-card.is-locked .card-body {
  filter: blur(5px);
  opacity: 0.45;
  user-select: none;
  pointer-events: none;
}

.question-card.is-locked .card-action-area {
  display: none;
}

.card-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  text-align: center;
  z-index: 5;
  transition: background var(--transition-normal);
}

.lock-icon-container {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  animation: lockPulse 3s infinite ease-in-out;
}

.lock-icon-svg {
  width: 28px;
  height: 28px;
  color: #b45309;
}

@keyframes lockPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.lock-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
}

.lock-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.4;
}

/* ==========================================================================
   NAVIGATION TABS (BANCO DE EJERCICIOS / CURSOS)
   ========================================================================== */
.main-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1.5rem;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: #f1f5f9;
}

.nav-tab-btn.active {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

@media (max-width: 768px) {
  .main-nav-tabs {
    margin-left: 0.5rem;
  }
  .nav-tab-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }
}

/* ==========================================================================
   COURSES SECTION & CARDS
   ========================================================================== */
.courses-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.courses-header {
  text-align: center;
  margin-bottom: 3rem;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.courses-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.courses-header-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.courses-header-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem;
}

.course-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.1);
  border-color: #cbd5e1;
}

.course-banner {
  height: 140px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1.5rem;
}

.course-banner-icon {
  font-size: 3rem;
  color: #ffffff;
  font-family: 'Times New Roman', serif;
  font-weight: 700;
  opacity: 0.9;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.course-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.course-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
  margin-bottom: 0.6rem;
}

.course-desc {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.55;
  margin-bottom: 1.25rem;
  flex: 1;
}

.course-specs {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: #64748b;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.85rem;
  margin-bottom: 1.25rem;
}

.course-spec-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.course-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid #f1f5f9;
  padding-top: 1rem;
}

.course-price-box {
  display: flex;
  flex-direction: column;
}

.course-price-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
}

.course-price-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}

/* ==========================================================================
   PRICING MODAL & TIERS (15€/mes vs 120€/curso)
   ========================================================================== */
.pricing-modal-dialog {
  max-width: 980px !important;
  width: 100% !important;
}

.pricing-plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin: 1.5rem 0;
}

@media (max-width: 860px) {
  .pricing-plans-grid {
    grid-template-columns: 1fr;
  }
}

.pricing-plan-card.active-current {
  border-color: #10b981;
  background: #f0fdf4;
}

.pricing-badge-current {
  position: absolute;
  top: -11px;
  right: 18px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 99px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pricing-plan-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.2s ease;
}

.pricing-plan-card:hover {
  border-color: #3b82f6;
}

.pricing-plan-card.featured {
  border-color: #2563eb;
  background: #fafcff;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.12);
}

.pricing-badge-popular {
  position: absolute;
  top: -11px;
  right: 18px;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 99px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pricing-plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.pricing-plan-desc {
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.pricing-plan-price {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.pricing-plan-period {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.pricing-plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.pricing-plan-features li {
  font-size: 0.85rem;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pricing-plan-features svg {
  color: #16a34a;
  flex-shrink: 0;
}
