/**
 * CIAC LAF HUB - Sistema Virtual de Capacitaciones
 * Paleta Oficial:
 * --color1: #260d33 (Púrpura Profundo)
 * --color2: #003f69 (Azul Marino Ejecutivo)
 * --color3: #106b87 (Azul Océano)
 * --color4: #157a8c (Teal Vibrante)
 * --color5: #b3aca4 (Platino Cálido)
 */

:root {
  --color1: #260d33;
  --color2: #003f69;
  --color3: #106b87;
  --color4: #157a8c;
  --color5: #b3aca4;

  --bg-dark-1: #16081e;
  --bg-dark-2: #0a1f33;
  --card-bg: rgba(22, 13, 35, 0.78);
  --card-bg-light: rgba(0, 63, 105, 0.45);
  --glass-border: rgba(179, 172, 164, 0.18);
  --glass-glow: rgba(21, 122, 140, 0.25);
  --accent-glow: 0 0 25px rgba(21, 122, 140, 0.45);
  
  --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font-primary);
  background: radial-gradient(circle at 10% 20%, var(--bg-dark-1) 0%, #0d1e2e 50%, var(--bg-dark-2) 100%);
  color: #f1f3f5;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Tipografía de encabezados */
h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Vidrio Esmerilado (Glassmorphism) */
.glass-panel {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
  border-radius: 16px;
}

.glass-panel-subtle {
  background: rgba(0, 63, 105, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(179, 172, 164, 0.12);
  border-radius: 12px;
}

/* Barra de navegación y cabecera superior */
.ciac-navbar {
  background: rgba(38, 13, 51, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(21, 122, 140, 0.3);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-brand-logo {
  max-height: 46px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  transition: transform 0.25s ease;
}

.navbar-brand-logo:hover {
  transform: scale(1.02);
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, var(--color5) 70%, var(--color4) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.badge-live {
  background: #e63946;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 50rem;
  box-shadow: 0 0 12px rgba(230, 57, 70, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-live-pulse {
  width: 8px;
  height: 8px;
  background-color: white;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  70% { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Temporizador */
.class-timer-badge {
  background: rgba(16, 107, 135, 0.25);
  border: 1px solid var(--color4);
  color: #ffffff;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Botones principales con paleta oficial */
.btn-ciac-primary {
  background: linear-gradient(135deg, var(--color3) 0%, var(--color4) 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(21, 122, 140, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-ciac-primary:hover {
  background: linear-gradient(135deg, var(--color4) 0%, #1995ac 100%);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(21, 122, 140, 0.5);
}

.btn-ciac-outline {
  background: transparent;
  color: var(--color5);
  border: 1px solid rgba(179, 172, 164, 0.35);
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-ciac-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: var(--color4);
}

.btn-ciac-danger {
  background: linear-gradient(135deg, #c1121f 0%, #780000 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.btn-ciac-danger:hover {
  background: linear-gradient(135deg, #df1b2a 0%, #900d0d 100%);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Botón Levantar Mano (Animado) */
.btn-raise-hand {
  background: linear-gradient(135deg, var(--color2) 0%, var(--color3) 100%);
  border: 2px solid var(--color4);
  color: #ffffff;
  padding: 0.65rem 1.3rem;
  border-radius: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 63, 105, 0.4);
}

.btn-raise-hand:hover {
  background: linear-gradient(135deg, var(--color3) 0%, var(--color4) 100%);
  color: white;
  transform: translateY(-2px);
}

.btn-raise-hand.hand-active {
  background: linear-gradient(135deg, #ff9f1c 0%, #f77f00 100%);
  border-color: #ffd166;
  color: #1a0826;
  box-shadow: 0 0 25px rgba(255, 159, 28, 0.6);
  animation: hand-pulse 1.8s infinite;
}

@keyframes hand-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Escenario de Video */
.video-stage-container {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #060e17;
  border: 1px solid rgba(21, 122, 140, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #050d17;
}

.video-overlay-info {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(10, 20, 32, 0.75);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  z-index: 5;
}

.video-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(10, 8, 18, 0.92) 0%, rgba(10, 8, 18, 0.4) 70%, transparent 100%);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
  transition: opacity 0.3s ease;
}

/* Indicador de micrófono de alumno */
.mic-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mic-status-indicator.allowed {
  background: rgba(40, 167, 69, 0.2);
  border-color: #28a745;
  color: #55efc4;
}

.mic-status-indicator.blocked {
  background: rgba(108, 117, 125, 0.2);
  border-color: rgba(179, 172, 164, 0.3);
  color: var(--color5);
}

/* Sala de Espera (Waiting Room) */
.waiting-room-wrapper {
  min-height: calc(100vh - 75px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
}

.waiting-ambient-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.waiting-ambient-1 {
  width: 380px;
  height: 380px;
  background: var(--color1);
  top: 15%;
  left: 10%;
}

.waiting-ambient-2 {
  width: 420px;
  height: 420px;
  background: var(--color2);
  bottom: 10%;
  right: 10%;
}

.waiting-card {
  max-width: 650px;
  width: 100%;
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 3rem 2rem;
}

.waiting-pulse-orb {
  width: 110px;
  height: 110px;
  margin: 0 auto 1.75rem auto;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color4) 0%, var(--color3) 60%, var(--color2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 35px var(--color4);
  animation: orb-breathe 2.5s ease-in-out infinite alternate;
}

.waiting-pulse-orb i {
  font-size: 3rem;
  color: #ffffff;
}

@keyframes orb-breathe {
  0% { transform: scale(0.96); box-shadow: 0 0 20px var(--color4); }
  100% { transform: scale(1.06); box-shadow: 0 0 45px #26d0ce; }
}

/* Chat en Vivo */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 580px;
  max-height: calc(100vh - 180px);
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-message-bubble {
  background: rgba(0, 63, 105, 0.35);
  border: 1px solid rgba(179, 172, 164, 0.12);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  max-width: 90%;
  animation: fadeInMsg 0.25s ease;
}

.chat-message-bubble.mine {
  align-self: flex-end;
  background: rgba(21, 122, 140, 0.28);
  border-color: rgba(21, 122, 140, 0.45);
}

.chat-message-bubble.is-question {
  border-left: 4px solid #ffd166;
  background: rgba(38, 13, 51, 0.75);
}

.chat-message-sender {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color5);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-message-sender.teacher {
  color: #55efc4;
}

.chat-message-text {
  font-size: 0.92rem;
  color: #f8f9fa;
  word-break: break-word;
}

.chat-message-time {
  font-size: 0.7rem;
  color: rgba(179, 172, 164, 0.7);
  margin-top: 4px;
  text-align: right;
}

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

.chat-input-form {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--glass-border);
  background: rgba(15, 8, 22, 0.6);
}

/* Panel de Manos Levantadas para el Profesor */
.hand-raise-card {
  border-left: 4px solid #f77f00;
  background: rgba(38, 13, 51, 0.65);
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.2s ease;
}

.hand-raise-card:hover {
  transform: translateX(4px);
  background: rgba(38, 13, 51, 0.85);
}

/* Alumnos conectados */
.student-badge-item {
  background: rgba(0, 63, 105, 0.22);
  border: 1px solid rgba(179, 172, 164, 0.1);
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modales y SweetAlert2 Overrides */
.swal2-popup.ciac-swal {
  background: #190922 !important;
  color: #f1f3f5 !important;
  border: 1px solid var(--color3) !important;
  border-radius: 18px !important;
  box-shadow: 0 15px 45px rgba(0,0,0,0.8) !important;
}

.swal2-title {
  color: #ffffff !important;
  font-family: var(--font-display) !important;
}

.swal2-html-container {
  color: var(--color5) !important;
}

.swal2-confirm.ciac-swal-btn {
  background: linear-gradient(135deg, var(--color3) 0%, var(--color4) 100%) !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 15px rgba(21, 122, 140, 0.4) !important;
}

/* Barra inferior móvil */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(22, 8, 30, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(21, 122, 140, 0.3);
  padding: 0.5rem 1rem;
  z-index: 1040;
  justify-content: space-around;
  align-items: center;
}

/* Responsividad Mobile First */
@media (max-width: 991.98px) {
  .ciac-navbar {
    padding: 0.5rem 1rem;
  }
  
  .brand-text {
    font-size: 1rem;
  }
  
  .chat-container {
    height: 480px;
  }
  
  .mobile-bottom-bar {
    display: flex;
  }
  
  body {
    padding-bottom: 70px;
  }
}

@media (max-width: 575.98px) {
  .waiting-card {
    padding: 2rem 1.25rem;
  }
  
  .video-stage-container {
    border-radius: 10px;
  }
  
  .btn-ciac-primary, .btn-raise-hand {
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
  }
}
