/* =========================================================
   EMOKIDS - Semáforo de Emociones Micro:bit
   Estilos CSS Modernos, Responsivos y Amigables para Niños
   ========================================================= */

:root {
  --font-title: 'Fredoka', cursive, sans-serif;
  --font-body: 'Nunito', sans-serif;

  /* Paleta Emocional del Semáforo */
  --color-red: #ff3366;
  --color-red-light: #ffe5ec;
  --color-red-glow: rgba(255, 51, 102, 0.6);

  --color-yellow: #f59e0b;
  --color-yellow-light: #fef3c7;
  --color-yellow-glow: rgba(245, 158, 11, 0.6);

  --color-green: #10b981;
  --color-green-light: #d1fae5;
  --color-green-glow: rgba(16, 185, 129, 0.6);

  /* Micro:bit Hardware */
  --mb-board: #16181e;
  --mb-board-accent: #232733;
  --mb-gold: #e5b342;
  --mb-led-off: #201318;
  --mb-led-on: #ff2a44;
  --mb-led-glow: #ff1e38;

  --bg-gradient: linear-gradient(135deg, #fdf2f8 0%, #f3e8ff 50%, #e0f2fe 100%);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 12px 30px rgba(124, 58, 237, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  user-select: none;
}

/* =========================================================
   PANTALLA DE BIENVENIDA / PORTADA (SPLASH SCREEN)
   ========================================================= */

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(243, 232, 255, 0.96);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  transition: opacity 0.6s ease, visibility 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  pointer-events: none;
}

.splash-card {
  background: #ffffff;
  border-radius: 28px;
  max-width: 460px;
  width: 100%;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.18);
  border: 3px solid #e9d5ff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.splash-badge {
  background: #fdf2f8;
  color: #ec4899;
  border: 1.5px solid #fbcfe8;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.splash-cover-container {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  border: 2px solid #f3e8ff;
  background: #fff;
  margin-bottom: 1rem;
}

.splash-cover-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.splash-title {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 900;
  color: #6b21a8;
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.splash-subtitle {
  font-size: 1rem;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.chip {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.chip-pink   { background: #fce7f3; color: #be185d; }
.chip-purple { background: #ede9fe; color: #6d28d9; }
.chip-blue   { background: #e0f2fe; color: #0369a1; }
.chip-yellow { background: #fef3c7; color: #b45309; }
.chip-green  { background: #dcfce7; color: #15803d; }

.splash-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  color: #ffffff;
  border: none;
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.pulse-btn {
  animation: heartPulse 1.8s infinite;
}

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

.auto-advance-bar {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  transition: width 0.1s linear;
}

.auto-advance-text {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 700;
}

/* =========================================================
   APLICACIÓN PRINCIPAL
   ========================================================= */

.app-container {
  width: 100%;
  max-width: 480px;
  padding: 0.75rem 1rem 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: opacity 0.4s ease;
}

.app-container.hidden {
  display: none;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.25rem;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-chip-btn {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 800;
  font-family: var(--font-body);
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
  transition: all 0.15s ease;
}

.icon-chip-btn:active {
  transform: scale(0.95);
  background: #f8fafc;
}

.icon-round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
  transition: all 0.15s ease;
}

.icon-round-btn.active {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.icon-round-btn:active {
  transform: scale(0.92);
}

.app-logo-badge {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 800;
  color: #581c87;
  letter-spacing: -0.3px;
}

/* Banner de Estado Emocional */
.status-banner {
  display: flex;
  justify-content: center;
}

.status-pill {
  background: #ffffff;
  border-radius: 999px;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  border: 2px solid #e2e8f0;
  transition: all 0.3s ease;
  max-width: 100%;
}

.status-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.status-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Estados temáticos del banner */
.status-pill.state-red {
  background: var(--color-red-light);
  border-color: var(--color-red);
  color: #9f1239;
}
.status-pill.state-red .status-text { color: #9f1239; }

.status-pill.state-yellow {
  background: var(--color-yellow-light);
  border-color: var(--color-yellow);
  color: #92400e;
}
.status-pill.state-yellow .status-text { color: #92400e; }

.status-pill.state-green {
  background: var(--color-green-light);
  border-color: var(--color-green);
  color: #065f46;
}
.status-pill.state-green .status-text { color: #065f46; }

/* =========================================================
   HARDWARE VIRTUAL: MICRO:BIT
   ========================================================= */

.microbit-stage {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0;
}

.microbit-board {
  width: 320px;
  height: 250px;
  background: var(--mb-board);
  border-radius: 20px;
  position: relative;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.12);
  border: 3px solid #2d323f;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem 0.8rem 0 0.8rem;
  transition: box-shadow 0.3s ease;
}

/* Efectos de resplandor ambiental en la placa según emoción */
.microbit-board.glow-red {
  box-shadow: 0 16px 36px rgba(255, 51, 102, 0.35), 0 0 20px rgba(255, 51, 102, 0.2);
}
.microbit-board.glow-yellow {
  box-shadow: 0 16px 36px rgba(245, 158, 11, 0.35), 0 0 20px rgba(245, 158, 11, 0.2);
}
.microbit-board.glow-green {
  box-shadow: 0 16px 36px rgba(16, 185, 129, 0.35), 0 0 20px rgba(16, 185, 129, 0.2);
}

/* Parte superior de la placa */
.board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
}

.usb-port {
  width: 38px;
  height: 12px;
  background: #cbd5e1;
  border-radius: 3px;
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.5);
  border: 1px solid #94a3b8;
}

.logo-microbit {
  background: #facc15;
  color: #1e293b;
  padding: 0.15rem 0.7rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 2px;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.3);
}

.activity-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #334155;
  transition: all 0.2s ease;
}

.activity-led.active {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

/* Parte media: Botones A, B y Matriz 5x5 */
.board-middle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
}

.board-button-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.board-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #475569, #0f172a);
  border: 2px solid #334155;
  box-shadow: 0 4px 8px rgba(0,0,0,0.6), inset 0 2px 2px rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.board-button:active, .board-button.pressed {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 2px 4px rgba(0,0,0,0.8), inset 0 1px 1px rgba(255,255,255,0.1);
  background: radial-gradient(circle at 50% 50%, #334155, #020617);
}

.btn-cap {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.1rem;
  color: #e2e8f0;
  pointer-events: none;
}

.btn-label {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 800;
  color: #94a3b8;
}

/* Matriz 5x5 */
.led-matrix-wrapper {
  background: #090a0d;
  padding: 0.45rem;
  border-radius: 10px;
  border: 1.5px solid #262a36;
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.8);
  position: relative;
}

.led-matrix {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
}

.led {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--mb-led-off);
  transition: background 0.08s ease, box-shadow 0.08s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.7);
}

.led.lit {
  background: var(--mb-led-on);
  box-shadow: 0 0 10px var(--mb-led-glow), 0 0 18px var(--mb-led-glow), inset 0 1px 2px #fff;
}

/* Botón A+B integrado en la placa */
.board-ab-container {
  display: flex;
  justify-content: center;
  margin-top: -0.25rem;
}

.board-ab-button {
  background: #1e293b;
  border: 1.5px solid #475569;
  border-radius: 999px;
  padding: 0.25rem 1rem;
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 800;
  color: #cbd5e1;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  transition: all 0.1s ease;
}

.board-ab-button:active, .board-ab-button.pressed {
  transform: translateY(1.5px);
  background: #0f172a;
  border-color: #38bdf8;
  color: #38bdf8;
}

/* Pines dorados inferiores */
.board-bottom-pins {
  display: flex;
  align-items: flex-end;
  height: 38px;
  background: transparent;
  gap: 2px;
  border-top: 1px solid #334155;
  padding: 0 0.2rem;
}

.large-pin {
  flex: 1.2;
  height: 100%;
  background: var(--mb-gold);
  border-radius: 2px 2px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 900;
  color: #451a03;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4);
}

.pin-stripes {
  flex: 0.8;
  height: 70%;
  background: repeating-linear-gradient(
    90deg,
    var(--mb-gold) 0,
    var(--mb-gold) 3px,
    #16181e 3px,
    #16181e 6px
  );
}

/* =========================================================
   TARJETAS TÁCTILES DE EMOCIONES (TOUCH CONTROLS)
   ========================================================= */

.touch-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.touch-controls-guide {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: #64748b;
  text-align: center;
}

.action-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-card {
  width: 100%;
  background: #ffffff;
  border-radius: 20px;
  padding: 0.9rem 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.9rem;
  row-gap: 0.4rem;
  align-items: center;
  border: 2px solid transparent;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.action-card:active {
  transform: scale(0.97);
}

.card-tag {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}

.card-icon-wrap {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.card-info {
  grid-column: 2;
  grid-row: 1;
  padding-right: 4.5rem;
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
}

.card-desc {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 700;
}

.card-action-badge {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.8rem;
  color: #475569;
  background: #f8fafc;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  display: inline-block;
  width: fit-content;
}

/* Colores específicos de cada emoción */
.card-red {
  border-color: #fecdd3;
}
.card-red:hover, .card-red.active-card {
  border-color: var(--color-red);
  background: #fff5f7;
  box-shadow: 0 8px 22px var(--color-red-glow);
}
.card-red .card-icon-wrap { background: #ffe4e6; }
.card-red .card-title { color: #e11d48; }
.card-red .card-tag { background: #ffe4e6; color: #be123c; }

.card-yellow {
  border-color: #fef08a;
}
.card-yellow:hover, .card-yellow.active-card {
  border-color: var(--color-yellow);
  background: #fffbeb;
  box-shadow: 0 8px 22px var(--color-yellow-glow);
}
.card-yellow .card-icon-wrap { background: #fef3c7; }
.card-yellow .card-title { color: #d97706; }
.card-yellow .card-tag { background: #fef3c7; color: #b45309; }

.card-green {
  border-color: #a7f3d0;
}
.card-green:hover, .card-green.active-card {
  border-color: var(--color-green);
  background: #ecfdf5;
  box-shadow: 0 8px 22px var(--color-green-glow);
}
.card-green .card-icon-wrap { background: #d1fae5; }
.card-green .card-title { color: #059669; }
.card-green .card-tag { background: #d1fae5; color: #047857; }

/* =========================================================
   FOOTER
   ========================================================= */

.app-footer {
  text-align: center;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-expo {
  font-size: 0.85rem;
  color: #475569;
}

.footer-names {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 800;
}

/* =========================================================
   MODAL CÓDIGO QR
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: #ffffff;
  border-radius: 28px;
  max-width: 420px;
  width: 100%;
  padding: 1.75rem 1.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  position: relative;
  text-align: center;
  animation: modalScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: #f1f5f9;
  border: none;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.qr-title {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 0.4rem;
}

.qr-desc {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 1.2rem;
}

.qr-image-wrapper {
  background: #ffffff;
  border: 3px dashed #cbd5e1;
  border-radius: 20px;
  padding: 1rem;
  display: inline-block;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.qr-code-img {
  width: 220px;
  height: 220px;
  display: block;
  image-rendering: pixelated;
}

.qr-url-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 1.2rem;
  overflow: hidden;
}

.qr-url-text {
  font-family: monospace;
  font-size: 0.8rem;
  color: #475569;
  word-break: break-all;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.btn-secondary {
  background: #7c3aed;
  color: #ffffff;
  text-decoration: none;
  border: none;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  display: block;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  transition: all 0.15s ease;
}

.btn-secondary:active {
  transform: scale(0.96);
}

.btn-outline {
  background: transparent;
  border: 2px solid #e2e8f0;
  color: #475569;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-outline:active {
  background: #f8fafc;
}
