@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* Reset & variables*/
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --cream:     #f5f0e8;
  --cream2:    #ede8df;
  --cream3:    #e5ddd0;
  --brown:     #c17f3a;
  --brown-d:   #a06828;
  --text:      #2c2416;
  --text2:     #6b5a42;
  --text3:     #9c8870;
  --white:     #ffffff;
  --border:    rgba(44, 36, 22, 0.1);
  --shadow:    0 1px 3px rgba(44, 36, 22, 0.08);
  --shadow-md: 0 4px 16px rgba(44, 36, 22, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.24);
  --green:     #22c55e;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: #1a1a1a;
  color: var(--text);
}

/* Avatar fullscreen stage */
#avStage {
  position: fixed;
  inset: 0;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

/* Placeholder animado */
.av-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 220px;
  height: 220px;
}

.av-circles {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.av-circle {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(193, 127, 58, 0.25);
}

.av-circle:nth-child(1) { width: 220px; height: 220px; }
.av-circle:nth-child(2) { width: 166px; height: 166px; }
.av-circle:nth-child(3) { width: 112px; height: 112px; }

.av-icon {
  position: relative;
  z-index: 1;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  margin-bottom: 14px;
}

.av-icon svg {
  color: var(--brown);
}

/* HUD: estado */
.hud-status {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 7px 14px;
  z-index: 50;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b6b6b;
  transition: background 0.3s;
  flex-shrink: 0;
}

.status-dot.active  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.loading { background: var(--brown); animation: blink 1s ease-in-out infinite; }
.status-dot.error   { background: #ef4444; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* HUD: nombre del avatar */
.hud-name {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 7px 16px;
  z-index: 50;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.hud-name-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brown);
  flex-shrink: 0;
}

/* HUD: temporizador */
.hud-timer {
  position: fixed;
  top: 20px;
  right: 20px;
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 7px 14px;
  z-index: 50;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.hud-timer.active {
  display: flex;
}

.timer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* HUD: onda de audio */
.hud-wave {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s;
}

.hud-wave.speaking {
  opacity: 1;
}

.hud-wave span {
  display: block;
  width: 4px;
  background: var(--brown);
  border-radius: 3px;
  opacity: 0.9;
}

.hud-wave.speaking span                { animation: wave 0.8s ease-in-out infinite; }
.hud-wave.speaking span:nth-child(1)   { animation-delay: 0s;     height: 6px; }
.hud-wave.speaking span:nth-child(2)   { animation-delay: 0.15s;  height: 14px; }
.hud-wave.speaking span:nth-child(3)   { animation-delay: 0.3s;   height: 9px; }
.hud-wave.speaking span:nth-child(4)   { animation-delay: 0.45s;  height: 16px; }
.hud-wave.speaking span:nth-child(5)   { animation-delay: 0.6s;   height: 7px; }

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(1.7); }
}

/* Barra de controles flotante */
.ctrl-bar {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  padding: 10px 18px;
  z-index: 60;
  box-shadow: var(--shadow-lg);
}

.ctrl-divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

/* Botón base */
.ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
}

/* Conectar */
.ctrl-btn.connect {
  background: var(--brown);
  color: white;
}
.ctrl-btn.connect:hover    { background: var(--brown-d); transform: scale(1.07); }
.ctrl-btn.connect:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Micrófono */
.ctrl-btn.mic {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}
.ctrl-btn.mic:hover { background: rgba(255, 255, 255, 0.2); }
.ctrl-btn.mic.active {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ef4444;
  animation: mic-ring 1.2s ease-in-out infinite;
}
.ctrl-btn.mic:disabled { opacity: 0.35; cursor: not-allowed; }

@keyframes mic-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50%       { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Pausar / Interrumpir */
.ctrl-btn.pause {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}
.ctrl-btn.pause:hover  { background: rgba(255, 255, 255, 0.2); }
.ctrl-btn.pause:disabled { opacity: 0.35; cursor: not-allowed; }

/* Terminar sesión */
.ctrl-btn.end {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #ef4444;
}
.ctrl-btn.end:hover  { background: rgba(239, 68, 68, 0.35); }
.ctrl-btn.end:disabled { opacity: 0.35; cursor: not-allowed; }

/* Toggle transcripción */
.ctrl-btn.chat-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
}
.ctrl-btn.chat-toggle:hover  { background: rgba(255, 255, 255, 0.2); color: white; }
.ctrl-btn.chat-toggle.active {
  background: rgba(193, 127, 58, 0.3);
  border-color: var(--brown);
  color: var(--brown);
}

/* Panel de transcripción */
.chat-drawer {
  position: fixed;
  right: 20px;
  top: 70px;
  bottom: 100px;
  width: 340px;
  background: rgba(245, 240, 232, 0.97);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 55;
  overflow: hidden;
  transform: translateX(380px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  pointer-events: none;
}

.chat-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border-radius: 20px 20px 0 0;
}

.drawer-av-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d0c8bc;
  transition: background 0.3s;
  flex-shrink: 0;
}
.drawer-av-dot.active { background: var(--green); box-shadow: 0 0 5px var(--green); }

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.drawer-timer {
  font-size: 11px;
  color: var(--text3);
  display: none;
  align-items: center;
  gap: 4px;
}
.drawer-timer.active { display: flex; }

/* Mensajes */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--cream3) transparent;
}

.msg-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.msg-group.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  background: var(--brown);
  color: white;
}
.msg-avatar.user-av { background: var(--cream3); color: var(--text2); }

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 78%;
}
.msg-group.user .msg-content { align-items: flex-end; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  animation: bubble-in 0.2s ease;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-group:not(.user) .msg-bubble {
  background: var(--white);
  color: var(--text);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-group.user .msg-bubble {
  background: var(--brown);
  color: white;
  border-top-right-radius: 4px;
}

.msg-time {
  font-size: 10px;
  color: var(--text3);
  padding: 0 3px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text3);
  font-size: 12px;
  text-align: center;
  padding: 30px;
}

.empty-icon { font-size: 28px; }

/*Input de texto en el drawer */
.drawer-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--white);
  border-radius: 0 0 20px 20px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 7px 7px 7px 16px;
  transition: border-color 0.2s;
}
.input-row:focus-within { border-color: var(--brown); }

.input-row input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
}
.input-row input::placeholder { color: var(--text3); }
.input-row input:disabled   { opacity: 0.5; cursor: not-allowed; }

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--brown);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.send-btn:hover   { background: var(--brown-d); }
.send-btn:active  { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Overlay de bienvenida */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.72);
  backdrop-filter: blur(6px);
  padding: 20px;
  transition: opacity 0.4s, visibility 0.4s;
}

.welcome-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-card {
  background: rgba(245, 240, 232, 0.97);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brown);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(193, 127, 58, 0.4);
  flex-shrink: 0;
}

.welcome-name-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.welcome-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.welcome-sub {
  font-size: 13px;
  color: var(--text3);
}

.welcome-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.welcome-chip {
  background: var(--cream2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 13px;
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
}

.welcome-start-btn {
  background: var(--brown);
  color: white;
  border: none;
  border-radius: 100px;
  padding: 13px 36px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(193, 127, 58, 0.4);
}
.welcome-start-btn:hover  { background: var(--brown-d); transform: translateY(-1px); }
.welcome-start-btn:active { transform: translateY(0); }

.welcome-note {
  font-size: 11px;
  color: var(--text3);
}

/* Toast de error */
.errlog {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(254, 226, 226, 0.95);
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 12px;
  color: #ef4444;
  max-width: 460px;
  width: 90%;
  display: none;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
