:root {
  --primary: #2563eb;
  --secondary: #db2777;
  --bg-dark: #121212; /* Negro suave (Material Dark) sin azul */
  --bg-panel: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #22d3ee;
  --border-light: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow-x: hidden;
  position: relative; /* Necesario para los pseudo-elementos */
}

/* Efectos de destellos ambientales tenues */
body::before,
body::after {
  content: '';
  position: fixed;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15; /* Opacidad baja para que sea tenue */
  z-index: -1;
  animation: float 10s infinite ease-in-out alternate;
  pointer-events: none;
}

body::before {
  background: var(--primary); /* Azul */
  top: -10%;
  left: -10%;
}

body::after {
  background: var(--secondary); /* Magenta */
  bottom: -10%;
  right: -10%;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); opacity: 0.1; }
  100% { transform: translate(30px, 50px) scale(1.1); opacity: 0.2; }
}

/* Grid Layout for Index */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.col {
  padding: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Columna Izquierda: Logo */
.col.left {
  background: transparent;
  align-items: center;
  text-align: center;
}

.logo {
  max-width: 320px;
  margin-bottom: 2rem;
  filter: drop-shadow(0 0 20px rgba(37, 99, 235, 0.5));
}

.tagline {
  font-size: 1rem;
  font-weight: 200;
  font-style: italic;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
  opacity: 0.7;
}

/* Columna Derecha: Interacción */
.col.right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 6rem;
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 10;
}

.content-wrapper {
  max-width: 480px;
  width: 100%;
}

/* Footer */
.main-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  z-index: 50;
  pointer-events: none;
}
.main-footer p {
  margin: 0;
  pointer-events: auto;
}
.main-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.main-footer a:hover {
  color: var(--primary);
}

h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
  line-height: 1.6;
}

.lead a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  transition: opacity 0.2s;
}

.lead a:hover { opacity: 0.8; }

.verify-card {
  background: rgba(30, 41, 59, 0.7);
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
  color: var(--text-main);
}

.input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

input[type="text"] {
  flex: 1;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: rgba(15, 23, 42, 0.6);
  color: white;
  font-size: 1rem;
  transition: all 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.btn-primary {
  padding: 1rem 2rem;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
}

.hint {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Loader */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.loader-text {
  font-size: 1.2rem;
  color: var(--text-main);
  font-weight: 300;
  letter-spacing: 0.5px;
  text-align: center;
  animation: fadeIn 0.5s ease-in-out;
}

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

.loader {
  position: relative;
  width: 100px;
  height: 100px;
}

.loader-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  z-index: 2;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: spin 2s linear infinite;
}

.ring-blue {
  border-top-color: var(--primary);
  animation-duration: 1.5s;
}

.ring-magenta {
  border-right-color: var(--secondary);
  animation-duration: 2s;
  animation-direction: reverse;
}

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

/* Room Styles */
.room-body {
  background: radial-gradient(circle at 50% 10%, #1a1f35 0%, #050505 100%);
}

.room-header {
  background: rgba(10, 10, 10, 0.8);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  padding: 0 2rem;
  height: 80px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.logo-room {
  height: 32px;
  width: auto;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.4));
}

.room-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.room-meta h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  display: block;
  background: none;
  -webkit-text-fill-color: initial;
}

.room-id {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  margin: 2px 0 0 0;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}
.room-id span {
  font-family: monospace;
  color: var(--accent);
}

/* Waiting Room Layout */
.waiting-room {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  padding: 2rem;
  padding-top: 100px;
  max-width: 1400px;
  margin: 0 auto;
  height: 100vh;
}

/* Preview Column */
.preview-col {
  display: flex;
  justify-content: center;
  align-items: center;
}

.video-preview-container {
  width: 100%;
  max-width: 800px;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid var(--border-light);
}

#localVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.media-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  background: rgba(0,0,0,0.6);
  padding: 10px 20px;
  border-radius: 50px;
  backdrop-filter: blur(10px);
}

.control-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: white;
}

.control-btn.active {
  background: rgba(255,255,255,0.2);
}
.control-btn.active:hover {
  background: rgba(255,255,255,0.3);
}

.control-btn.inactive {
  background: #ef4444;
  color: white;
}
.control-btn.inactive:hover {
  background: #dc2626;
}

.video-status {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  backdrop-filter: blur(4px);
}

/* Participants Column */
.participants-col {
  background: var(--bg-panel);
  border-radius: 24px;
  padding: 2rem;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 600px;
}

.participants-col h2 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
}

.sub-text {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.participants-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1.1rem;
}

.info {
  display: flex;
  flex-direction: column;
}

.info .email {
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.host-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.3);
}

.info .status {
    font-size: 0.75rem;
    color: var(--accent);
  }
  
  .info .status.in-call {
    color: #10b981; /* Verde esmeralda */
    font-weight: 600;
  }
  
  .info .status.waiting {
    color: var(--text-muted);
  }

  .action-area {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.status-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.status-msg.ready {
  color: var(--accent);
  font-weight: 600;
}

.full-width {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(15px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Responsive Mobile Styles for Room */
@media (max-width: 768px) {
  .room-body {
    background: #121212; /* Fondo negro plano estilo app */
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .room-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    height: 60px;
    justify-content: space-between;
    background: rgba(10, 10, 10, 0.7);
    z-index: 200; /* Mayor que el meeting-room (100) */
    backdrop-filter: blur(12px);
    border-bottom: none;
  }
  
  /* Mostrar logo pero mantener titulo oculto si se desea */
  .room-header .logo-room {
    display: block; /* Restaurar logo visible */
    height: 32px;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.5));
  }
  
  .room-header h1 {
    display: none;
  }

  .room-meta {
    flex: 1;
    align-items: flex-end;
    text-align: right;
  }

  .room-id {
    font-size: 0.8rem;
    background: rgba(0,0,0,0.6);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    margin: 0;
  }

  /* Main Container Layout */
  .waiting-room {
    display: flex;
    flex-direction: column;
    padding: calc(60px + env(safe-area-inset-top, 0px)) 0 0 0;
    gap: 0;
    height: auto;
    width: 100%;
    min-height: 0;
  }

  /* Video Preview Section (Top 55% - Reduced to allow more scroll space) */
  .preview-col {
    width: 100%;
    height: 65vh;
    border-radius: 0 0 24px 24px;
    overflow: hidden;
    position: relative;
    z-index: 10;
    background: #000;
    flex-shrink: 0; /* Evitar que se encoja */
  }

  .video-preview-container {
    width: 100%;
    height: 100%;
    border-radius: 0 0 24px 24px;
    background: #1a1a1a;
  }
  
  .video-inner-container {
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
  }
  
  #localVideo {
    object-fit: cover;
    width: 100%;
    height: 100%;
  }

  .video-status {
    top: auto; /* Quitar top fijo */
    bottom: 2rem; /* Alinear con controles */
    left: 1rem;
    font-size: 0.75rem;
    padding: 4px 10px;
    z-index: 20;
  }

  /* Controls Overlay on Video */
  .media-controls {
    bottom: 2rem;
    padding: 0;
    gap: 1.5rem;
    background: transparent;
    backdrop-filter: none;
    z-index: 20;
    justify-content: center; /* Centrar controles */
    left: 50%;
    transform: translateX(-50%);
    width: auto;
  }

  .control-btn {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
  }

  /* Bottom Sheet Section (Remaining Space) */
  .participants-col {
    flex: none;
    background: #121212;
    border-radius: 0;
    padding: 1.5rem;
    border: none;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    overflow: visible;
  }

  .participants-col h2 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: var(--text-main);
  }

  .sub-text {
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }

  .participants-list {
    flex: none;
    overflow: visible;
    max-height: none; /* Quitar límite fijo, usar flex */
    margin-bottom: 1rem;
    padding-bottom: 1rem; /* Espacio extra para scroll */
  }

  .participant-item {
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }

  /* Action Area Fixed at Bottom */
  .action-area {
    margin-top: 1rem;
    padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom, 0px));
    background: #121212;
    border-top: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    bottom: 0;
  }

  .status-msg {
    display: block;
    margin-bottom: 1rem;
    color: #e8eaed;
    font-size: 0.9rem;
    text-align: center;
  }

  /* Botón Join Prominente */
  #joinBtn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border-radius: 50px;
    background: #8ab4f8; /* Azul Google Meet */
    color: #202124;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(138, 180, 248, 0.3);
    text-transform: none;
    letter-spacing: normal;
  }
  
  #joinBtn:disabled {
    background: #3c4043;
    color: #80868b;
    box-shadow: none;
  }

  /* Meeting Room Full Screen Mobile */
  .meeting-room {
    position: fixed;
    top: 60px; /* Dejar espacio para el header */
    left: 0;
    right: 0;
    bottom: 0; /* Dejar espacio para el footer si es necesario */
    z-index: 100;
  }
  
  .iframe-container {
    width: 100%;
    height: 100%;
  }
}

.modal-card {
  background: #121826;
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6);
}

.modal-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0 15px rgba(255,47,176,0.3));
}

.modal-card h3 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
}

.modal-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.modal-card input {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: rgba(0,0,0,0.3);
  color: white;
  margin-bottom: 1rem;
  font-size: 1rem;
}
.modal-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.modal-card .btn-primary {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  height: auto; /* Asegurar que la altura sea automática según el padding */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
  .grid {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-bottom: 4rem;
  }
  .col.left, .col.right {
    padding: 3rem 1.5rem;
    min-height: auto;
    justify-content: center;
    align-items: center;
    text-align: center;
  }
  .col.left {
    border-right: none;
    border-bottom: none;
    padding-top: 4rem;
    padding-bottom: 1rem;
  }
  .col.right {
    padding-top: 0;
  }
  .content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .logo { max-width: 280px; margin-bottom: 1.5rem; }
  h1 { display: none; }
  .tagline { font-size: 0.95rem; }
  .desktop-text { display: none; }
  .mobile-text { display: inline; }
  
  .input-group {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }
  .input-group input, .input-group button {
    width: 100%;
    flex: none;
    height: 50px;
  }
  
  .btn-primary {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
  }
  
  .main-footer {
    position: relative;
    padding: 2rem 1rem;
    background: var(--bg-dark);
  }

  .waiting-room {
    grid-template-columns: 1fr;
    padding-top: 90px;
    height: auto;
  }
  .video-preview-container {
    margin-bottom: 2rem;
  }
  .participants-col {
    max-height: none;
  }
}

.mobile-text { display: none; }

/* Meeting Room & Iframe */
.meeting-room {
  position: fixed;
  top: 80px; /* Debajo del header */
  left: 0;
  width: 100%;
  height: calc(100vh - 80px - 50px); /* Restar header y footer */
  z-index: 10;
  background: #000;
}

.iframe-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Timer Display */
.timer-display {
  margin-left: auto;
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0,0,0,0.3);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
