/* ═══════════════════════════════════════════
   COGNIVIA — Gimnasio Cognitivo con IA
   ATD Academia de Transformación Digital
   Paleta: #0f054c · #00ddfd · #ec1f52 · #fff
   ═══════════════════════════════════════════ */

:root {
  --azul-oscuro: #0f054c;
  --azul-profundo: #0a0335;
  --cian: #00ddfd;
  --cian-glow: rgba(0, 221, 253, 0.15);
  --fucsia: #ec1f52;
  --fucsia-soft: rgba(236, 31, 82, 0.12);
  --blanco: #ffffff;
  --gris-100: #f4f6fb;
  --gris-200: #e2e6f0;
  --gris-300: #b0b8cc;
  --gris-700: #3a3f55;
  --negro: #0d0d12;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 30px rgba(0, 221, 253, 0.2);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--azul-profundo);
  color: var(--blanco);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── LAYOUT ──────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ─── HEADER ──────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--azul-oscuro) 0%, var(--azul-profundo) 100%);
  border-bottom: 1px solid rgba(0, 221, 253, 0.15);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--cian);
  letter-spacing: 1px;
}

.logo-sub {
  font-size: 11px;
  color: var(--gris-300);
  letter-spacing: 0.5px;
}

.header-badge {
  background: var(--fucsia);
  color: var(--blanco);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ─── HERO ────────────────────────────────── */
.hero {
  text-align: center;
  padding: 48px 16px 32px;
  background: radial-gradient(ellipse at center top, rgba(0, 221, 253, 0.08) 0%, transparent 60%);
}

.hero h1 {
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero h1 .highlight {
  background: linear-gradient(90deg, var(--cian), var(--fucsia));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--gris-300);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto 24px;
}

.forja-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.forja-pill {
  background: rgba(0, 221, 253, 0.1);
  border: 1px solid rgba(0, 221, 253, 0.25);
  color: var(--cian);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.forja-pill .pill-letter {
  color: var(--fucsia);
  font-weight: 800;
}

.ai-notice {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--gris-300);
  max-width: 500px;
  margin: 0 auto;
  display: inline-block;
}

/* ─── MÓDULOS GRID ────────────────────────── */
.modules-section {
  padding: 32px 0 48px;
}

.section-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--blanco);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.module-card {
  background: linear-gradient(145deg, rgba(15, 5, 76, 0.8), rgba(10, 3, 53, 0.9));
  border: 1px solid rgba(0, 221, 253, 0.12);
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cian), var(--fucsia));
  opacity: 0;
  transition: var(--transition);
}

.module-card:hover {
  border-color: var(--cian);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.module-card:hover::before {
  opacity: 1;
}

.module-card.completed {
  border-color: rgba(0, 221, 253, 0.4);
}

.module-card.completed::after {
  content: '✓';
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--cian);
  color: var(--azul-profundo);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.module-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.module-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--cian);
  margin-bottom: 4px;
}

.module-desc {
  font-size: 13px;
  color: var(--gris-300);
  margin-bottom: 12px;
}

.module-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.module-difficulty {
  font-size: 11px;
  color: var(--gris-300);
  background: rgba(255,255,255,0.06);
  padding: 3px 10px;
  border-radius: 10px;
}

.module-cta {
  font-size: 12px;
  color: var(--fucsia);
  font-weight: 600;
}

/* ─── VISTA ENTRENAMIENTO ─────────────────── */
.training-view {
  display: none;
  padding: 16px 0 100px;
}

.training-view.active {
  display: block;
}

.training-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-back {
  background: none;
  border: 1px solid var(--gris-300);
  color: var(--gris-300);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.btn-back:hover {
  border-color: var(--cian);
  color: var(--cian);
}

.training-module-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--cian);
}

/* ─── PROGRESO FORJA ──────────────────────── */
.forja-progress {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: rgba(0, 221, 253, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 221, 253, 0.1);
  overflow-x: auto;
}

.forja-step {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.forja-step-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
  color: var(--gris-300);
  border: 2px solid transparent;
  transition: var(--transition);
  flex-shrink: 0;
}

.forja-step-letter.active {
  background: var(--cian);
  color: var(--azul-profundo);
  border-color: var(--cian);
  box-shadow: 0 0 12px rgba(0, 221, 253, 0.4);
}

.forja-step-letter.completed {
  background: rgba(0, 221, 253, 0.2);
  color: var(--cian);
  border-color: var(--cian);
}

.forja-step-name {
  font-size: 11px;
  color: var(--gris-300);
  margin-right: 8px;
}

.forja-step-name.active {
  color: var(--cian);
  font-weight: 600;
}

.forja-connector {
  width: 20px;
  height: 2px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.forja-connector.completed {
  background: var(--cian);
}

/* ─── CONTEXTO ────────────────────────────── */
.scenario-context {
  background: linear-gradient(135deg, rgba(15, 5, 76, 0.6), rgba(10, 3, 53, 0.8));
  border: 1px solid rgba(0, 221, 253, 0.15);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.context-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fucsia);
  font-weight: 700;
  margin-bottom: 8px;
}

.context-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--gris-200);
}

/* ─── CHAT ────────────────────────────────── */
.chat-container {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  margin-bottom: 16px;
  scroll-behavior: smooth;
}

.chat-message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

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

.chat-message.assistant {
  flex-direction: row;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-message.assistant .chat-avatar {
  background: linear-gradient(135deg, var(--cian), rgba(0, 221, 253, 0.5));
}

.chat-message.user .chat-avatar {
  background: linear-gradient(135deg, var(--fucsia), rgba(236, 31, 82, 0.5));
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.assistant .chat-bubble {
  background: rgba(0, 221, 253, 0.08);
  border: 1px solid rgba(0, 221, 253, 0.15);
  color: var(--gris-100);
}

.chat-message.user .chat-bubble {
  background: rgba(236, 31, 82, 0.1);
  border: 1px solid rgba(236, 31, 82, 0.2);
  color: var(--gris-100);
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  align-items: center;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cian);
  animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ─── INPUT AREA ──────────────────────────── */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--azul-profundo);
  border-top: 1px solid rgba(0, 221, 253, 0.12);
  padding: 12px 16px;
  z-index: 50;
}

.input-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-area textarea {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: var(--blanco);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.5;
  transition: var(--transition);
}

.input-area textarea:focus {
  outline: none;
  border-color: var(--cian);
  box-shadow: 0 0 0 2px rgba(0, 221, 253, 0.15);
}

.input-area textarea::placeholder {
  color: var(--gris-300);
}

.btn-send {
  background: linear-gradient(135deg, var(--cian), #00b8d4);
  color: var(--azul-profundo);
  border: none;
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(0, 221, 253, 0.4);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── PHASE CONTROLS ──────────────────────── */
.phase-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-phase {
  background: linear-gradient(135deg, var(--fucsia), #c41840);
  color: var(--blanco);
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-phase:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(236, 31, 82, 0.3);
}

.btn-evaluate {
  background: linear-gradient(135deg, var(--cian), #00b8d4);
  color: var(--azul-profundo);
}

.btn-evaluate:hover {
  box-shadow: 0 4px 16px rgba(0, 221, 253, 0.3);
}

/* ─── EVALUACIÓN ──────────────────────────── */
.evaluation-card {
  background: linear-gradient(145deg, rgba(15, 5, 76, 0.6), rgba(10, 3, 53, 0.8));
  border: 1px solid rgba(0, 221, 253, 0.2);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 14px;
}

/* ─── CTA COMERCIAL ───────────────────────── */
.cta-banner {
  background: linear-gradient(135deg, var(--azul-oscuro), rgba(236, 31, 82, 0.15));
  border: 1px solid var(--fucsia);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  margin: 32px 0;
}

.cta-banner h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--blanco);
}

.cta-banner p {
  color: var(--gris-300);
  font-size: 14px;
  margin-bottom: 16px;
}

.cta-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cta-stat {
  text-align: center;
}

.cta-stat-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--cian);
}

.cta-stat-label {
  font-size: 11px;
  color: var(--gris-300);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-cta {
  display: inline-block;
  background: linear-gradient(135deg, var(--fucsia), #c41840);
  color: var(--blanco);
  padding: 14px 36px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  transition: var(--transition);
  border: none;
  cursor: pointer;
}

.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(236, 31, 82, 0.4);
}

/* ─── QUOTA BAR ───────────────────────────── */
.quota-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--gris-300);
}

.quota-fill {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.quota-fill-inner {
  height: 100%;
  background: var(--cian);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.quota-fill-inner.warning {
  background: #ffc107;
}

.quota-fill-inner.danger {
  background: var(--fucsia);
}

/* ─── FOOTER ──────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: var(--gris-300);
  font-size: 12px;
}

.footer a {
  color: var(--cian);
  text-decoration: none;
}

/* ─── ERROR / STATUS ──────────────────────── */
.error-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--fucsia);
  color: var(--blanco);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: calc(100% - 32px);
  text-align: center;
}

.error-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.status-config {
  text-align: center;
  padding: 40px 20px;
  color: var(--gris-300);
}

.status-config .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ─── LOADING ─────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 3, 53, 0.8);
  z-index: 300;
  justify-content: center;
  align-items: center;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(0, 221, 253, 0.2);
  border-top-color: var(--cian);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── RESPONSIVE ──────────────────────────── */
@media (max-width: 600px) {
  .modules-grid {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    max-width: 88%;
  }

  .forja-step-name {
    display: none;
  }

  .forja-progress {
    justify-content: center;
  }

  .cta-stats {
    gap: 16px;
  }

  .header-badge {
    display: none;
  }
}
