/* ============================================
   COMPONENTS.CSS - Componentes Reutilizables
   ============================================ */

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

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

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  color: inherit;
  transition: var(--transition);
}

.btn-icon:hover {
  opacity: 0.7;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.125rem;
}

/* Nav Items */
.nav-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: var(--text-primary);
}

.nav-item:hover {
  background: var(--bg-color);
}

.nav-item.active {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  color: white;
}

.nav-item-icon {
  margin-right: var(--spacing-md);
  font-size: 1.25rem;
}

.nav-item-content {
  flex: 1;
}

.nav-item-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.nav-item-subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
}

.nav-item-badge {
  background: var(--success-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Introducción de asignatura */
.nav-intro {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
  border: 1px dashed var(--primary-color);
  margin-bottom: var(--spacing-md);
}

.nav-intro:hover {
  background: linear-gradient(135deg, #e8f0fe 0%, #dbeafe 100%);
  border-style: solid;
}

.nav-intro.active {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  border: none;
}

.nav-intro .nav-item-icon {
  font-size: 1.1rem;
}

.nav-recurso {
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.nav-recurso:hover {
  background: rgba(102, 126, 234, 0.1);
}

.nav-recurso.active {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  color: white;
}

.nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--spacing-md) 0;
}

.nav-section-title {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--spacing-sm);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Tooltips */
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 2px dotted var(--primary-color);
  cursor: help;
  color: var(--primary-color);
  font-weight: 600;
}

.tooltip-content {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  min-width: 250px;
  max-width: 400px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tooltip:hover .tooltip-content {
  opacity: 1;
  visibility: visible;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--text-primary);
}

/* Cards */
.card {
  background: var(--surface-color);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: var(--spacing-lg);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #e8f5e9;
  color: var(--success-color);
}

.badge-warning {
  background: #fff3e0;
  color: var(--warning-color);
}

.badge-error {
  background: #ffebee;
  color: var(--error-color);
}

.badge-info {
  background: #e3f2fd;
  color: var(--info-color);
}

/* Alerts */
.alert {
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-lg);
  border-left: 4px solid;
}

.alert-success {
  background: #e8f5e9;
  border-color: var(--success-color);
  color: #2e7d32;
}

.alert-warning {
  background: #fff3e0;
  border-color: var(--warning-color);
  color: #e65100;
}

.alert-error {
  background: #ffebee;
  border-color: var(--error-color);
  color: #c62828;
}

.alert-info {
  background: #e3f2fd;
  border-color: var(--info-color);
  color: #1565c0;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-sm {
  margin-top: var(--spacing-sm);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mt-lg {
  margin-top: var(--spacing-lg);
}

.mt-xl {
  margin-top: var(--spacing-xl);
}

.mb-sm {
  margin-bottom: var(--spacing-sm);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

.mb-lg {
  margin-bottom: var(--spacing-lg);
}

.mb-xl {
  margin-bottom: var(--spacing-xl);
}

.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* Survey Modal */
.survey-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99999;
  justify-content: center;
  align-items: center;
}

.survey-modal-overlay.active {
  display: flex !important;
}

.survey-modal-content {
  max-width: 400px;
  width: 90%;
  text-align: center;
  background: white;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.survey-modal-content h3 {
  margin-bottom: 15px;
  color: #333;
}

.survey-modal-content p {
  margin-bottom: 20px;
  color: #666;
}

.survey-mood-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.mood-btn {
  font-size: 2em;
  padding: 10px;
  border: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition:
    transform 0.2s,
    border-color 0.2s;
  border-radius: 12px;
}

.mood-btn:hover {
  transform: scale(1.2);
  border-color: var(--primary-color, #667eea);
  background: #f0f4ff;
}

.btn-skip-survey {
  color: #999;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.btn-skip-survey:hover {
  color: #666;
}

/* Theme Survey Form (inside survey-modal-content) */
.theme-survey-form h3 {
  margin-bottom: 10px;
  color: #333;
}

.theme-survey-form > p {
  margin-bottom: 20px;
  color: #666;
}

.theme-survey-form .survey-question {
  margin-bottom: 16px;
  text-align: left;
}

.theme-survey-form .survey-question label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
  font-size: 0.95em;
}

.theme-survey-form .rating-input {
  display: flex;
  gap: 4px;
}

.theme-survey-form .star {
  font-size: 1.8em;
  cursor: pointer;
  color: #ccc;
  transition:
    color 0.15s,
    transform 0.15s;
}

.theme-survey-form .star:hover {
  transform: scale(1.2);
  color: #ffd700;
}

.theme-survey-form .form-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1em;
  color: #333;
  background: white;
}

.theme-survey-form .form-input:focus {
  outline: none;
  border-color: var(--primary-color, #667eea);
}

.theme-survey-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* ============================================
   TABLAS DE ESTUDIO
   ============================================ */
.tablas-section {
  margin: var(--spacing-xl, 2rem) 0;
}

.tablas-section-inner {
  background: var(--surface-color, #fff);
  border-radius: var(--border-radius-lg, 12px);
  padding: var(--spacing-xl, 2rem);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-top: 4px solid #2e7d32;
}

.tablas-section-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.tablas-section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a3c2d;
  margin: 0 0 0.4rem 0;
}

.tablas-section-header p {
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
  margin: 0;
}

/* Contenedor de cada bloque de tablas */
.tablas-section .tablas-estudio {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tablas-section .tablas-estudio > h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #2e7d32;
  padding: 0.6rem 1rem;
  background: #f1f8f1;
  border-radius: 8px;
  border-left: 4px solid #2e7d32;
  margin: 0;
}

.tablas-section .tablas-estudio > hr {
  border: none;
  border-top: 1px solid var(--border-color, #e5e7eb);
  margin: 0;
}

/* Tabla individual */
.tablas-section .tabla-estudio {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.tablas-section .tabla-estudio caption {
  text-align: left;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a3c2d;
  padding: 0.6rem 0.8rem;
  background: #e8f5e9;
  border-radius: 8px 8px 0 0;
  caption-side: top;
}

.tablas-section .tabla-estudio thead tr {
  background: #2e7d32;
  color: #fff;
}

.tablas-section .tabla-estudio thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border: none;
}

.tablas-section .tabla-estudio tbody tr {
  border-bottom: 1px solid #e8f5e9;
  transition: background 0.15s;
}

.tablas-section .tabla-estudio tbody tr:hover {
  background: #f4fbf4;
}

.tablas-section .tabla-estudio tbody tr:last-child {
  border-bottom: none;
}

.tablas-section .tabla-estudio td {
  padding: 0.65rem 1rem;
  vertical-align: top;
  color: var(--text-primary, #1f2937);
  line-height: 1.5;
}

.tablas-section .tabla-estudio td strong {
  color: #1a3c2d;
}

/* Responsive */
@media (max-width: 700px) {
  .tablas-section .tabla-estudio,
  .tablas-section .tabla-estudio thead,
  .tablas-section .tabla-estudio tbody,
  .tablas-section .tabla-estudio th,
  .tablas-section .tabla-estudio td,
  .tablas-section .tabla-estudio tr {
    display: block;
  }

  .tablas-section .tabla-estudio thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .tablas-section .tabla-estudio tr {
    margin-bottom: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  }

  .tablas-section .tabla-estudio td {
    border-bottom: 1px solid #e8f5e9;
    position: relative;
    padding-left: 45%;
  }

  .tablas-section .tabla-estudio td:before {
    content: attr(data-label);
    position: absolute;
    left: 0.75rem;
    width: 40%;
    font-weight: 600;
    color: #2e7d32;
    font-size: 0.8rem;
  }
}

/* ── Estado "revisar" — tema cambiado desde completado ── */
.nav-item-badge-revisar {
  background: #ff8c00;
  color: #fff;
  font-size: 12px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-revisar 2s infinite;
}

@keyframes pulse-revisar {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}
