/* Estilos para el Examen de Inglés Básico */
:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #dc2626;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Encabezado */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #b91c1c 100%);
  color: #ffffff;
  padding: 1.25rem 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-header .logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header .logo-icon {
  font-size: 2rem;
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.header-btn {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

/* Contenedor Principal */
.main-container {
  max-width: 920px;
  width: 95%;
  margin: 2rem auto;
  flex: 1;
}

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

/* Badges de Temas */
.badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-present { background: #dbeafe; color: #1e40af; }
.badge-continuous { background: #fef3c7; color: #b45309; }
.badge-modal { background: #dcfce7; color: #15803d; }
.badge-vocab { background: #f3e8ff; color: #7e22ce; }
.badge-default { background: #f1f5f9; color: #475569; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35);
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-dark);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

/* Pantalla de Inicio */
.welcome-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (max-width: 820px) {
  .welcome-grid {
    grid-template-columns: 1fr;
  }
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.35;
}

.rules-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

/* Selector de Avatars */
.avatar-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.avatar-selected-preview-text {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .avatar-picker-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.avatar-option-btn {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 3px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option-btn:hover {
  transform: translateY(-2px) scale(1.08);
}

.avatar-option-btn.active {
  border-color: var(--primary);
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.25);
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}

.avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  user-select: none;
  flex-shrink: 0;
}

/* Interfaz del Examen */
.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.student-info-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.student-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.exam-progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Temporizador */
.timer-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f8fafc;
  border: 2px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.timer-box {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--primary);
  transition: color 0.3s ease;
}

.timer-seconds {
  min-width: 2.5ch;
  text-align: right;
}

.timer-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.timer-warning {
  border-color: #f59e0b !important;
  color: #b45309 !important;
  background: #fffbeb !important;
}

.timer-danger {
  border-color: #ef4444 !important;
  color: #dc2626 !important;
  background: #fef2f2 !important;
  animation: pulse-danger 1s infinite alternate;
}

@keyframes pulse-danger {
  0% { transform: scale(1); }
  100% { transform: scale(1.03); }
}

/* Barra de Progreso */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e40af, #3b82f6);
  width: 2.85%;
  transition: width 0.3s ease;
}

/* Pregunta y Opciones */
.question-topic-badge {
  margin-bottom: 0.75rem;
}

.question-title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-dark);
  margin-bottom: 1.5rem;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.option-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.option-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
  transform: translateX(4px);
}

.option-card.selected {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--primary);
}

.option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.option-card.selected .option-letter {
  background: var(--primary);
  color: #ffffff;
}

.option-text {
  font-size: 1rem;
  line-height: 1.45;
  color: #1e293b;
  flex: 1;
}

.exam-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Pantalla de Resultados */
.result-header {
  text-align: center;
  margin-bottom: 2rem;
}

.result-avatar-display {
  margin: 0 auto 1rem auto;
  display: flex;
  justify-content: center;
}

.result-badge-pos {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #1e40af, #b91c1c);
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: 9999px;
  font-size: 1.25rem;
  font-weight: 800;
  margin: 1rem 0;
  box-shadow: var(--shadow-md);
}

.score-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.score-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
}

.score-box-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.score-box-val {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.score-box-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.topic-breakdown {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.topic-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--border-color);
}

.topic-row:last-child {
  border-bottom: none;
}

/* Pestañas de Grupos */
.group-tabs-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.group-tab-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: #475569;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
}

.group-tab-btn:hover {
  background: #e2e8f0;
  color: var(--text-dark);
}

.group-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(30, 64, 175, 0.25);
}

.group-tab-btn .tab-count {
  background: rgba(0,0,0,0.1);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.group-tab-btn.active .tab-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* Tabla de Ranking */
.ranking-table-wrapper {
  overflow-x: auto;
  margin-top: 1.5rem;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ranking-table th {
  background: #f1f5f9;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
}

.ranking-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  vertical-align: middle;
}

.ranking-table tbody tr:hover {
  background: #f8fafc;
}

.student-table-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pos-tag {
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
}

.pos-1 { background: #fef3c7; color: #b45309; border: 1px solid #f59e0b; }
.pos-2 { background: #e2e8f0; color: #475569; border: 1px solid #94a3b8; }
.pos-3 { background: #ffedd5; color: #c2410c; border: 1px solid #fb923c; }
.pos-other { background: #f8fafc; color: #64748b; }

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1rem;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-md);
  max-width: 750px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  position: relative;
}

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

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text-dark);
}

.tab-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: #ffffff;
}
