/* Traductor Familiar — estilo iOS, glassmorphism, móvil primero. */

:root {
  --text: #1c1c1e;
  --text-soft: #5b5b66;
  --accent: #0a84ff;
  --accent-dark: #0066d6;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-border: rgba(255, 255, 255, 0.75);
  --radius: 26px;
  --shadow: 0 10px 35px rgba(60, 60, 120, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  font-size: 18px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Fondo con degradado suave estilo iOS */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 700px at 85% -10%, #ffd9e8 0%, transparent 55%),
    radial-gradient(1000px 800px at -15% 30%, #d3e2ff 0%, transparent 60%),
    radial-gradient(900px 700px at 70% 110%, #d8f5e3 0%, transparent 55%),
    linear-gradient(180deg, #eef1fb 0%, #e9eefa 100%);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

.hidden { display: none !important; }

/* ---------- Inicio ---------- */

.ui-lang-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 4px;
  align-self: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.ui-lang {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.ui-lang.selected {
  background: linear-gradient(180deg, #2196ff, var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
}

.hero {
  text-align: center;
  margin-top: 5vh;
}

.hero-icon { font-size: 56px; }

h1 {
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.5px;
  margin: 10px 0 8px;
  font-weight: 800;
}

.subtitle {
  color: var(--text-soft);
  font-size: 19px;
  margin: 0 0 10px;
}

h2 {
  font-size: 30px;
  margin: 18px 0 0;
  text-align: center;
  letter-spacing: -0.4px;
}

/* ---------- Tarjetas de cristal ---------- */

.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Botones ---------- */

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-big {
  width: 100%;
  padding: 18px;
  font-size: 21px;
}

.btn-primary {
  background: linear-gradient(180deg, #2196ff, var(--accent-dark));
  color: #fff;
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent);
  border: 1px solid rgba(10, 132, 255, 0.25);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-soft);
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.12);
}

.field-label {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-soft);
  margin: 0;
}

.code-input {
  font: inherit;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  padding: 14px;
  border-radius: 18px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  width: 100%;
  -webkit-user-select: text;
  user-select: text;
}
.code-input:focus { border-color: var(--accent); }

.hint {
  text-align: center;
  color: var(--text-soft);
  font-size: 16px;
  margin: 0;
}

/* ---------- Selección de idiomas ---------- */

.screen-header { text-align: center; }

.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lang-chip {
  font: inherit;
  font-size: 19px;
  font-weight: 600;
  padding: 16px 10px;
  border-radius: 16px;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.12s ease;
}

.lang-chip.selected {
  background: linear-gradient(180deg, #2196ff, var(--accent-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(10, 132, 255, 0.35);
}

/* ---------- Sala ---------- */

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-code-pill {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: var(--shadow);
}

.room-code-label { color: var(--text-soft); font-size: 16px; }

.room-code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.btn-exit {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--red);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 69, 58, 0.25);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
}

.status-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 700;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.status-wait .status-dot { background: var(--orange); }
.status-ready .status-dot { background: var(--green); }
.status-talking .status-dot { background: var(--red); animation: blink 1s infinite; }
.status-listening .status-dot { background: var(--accent); animation: blink 1s infinite; }
.status-translating .status-dot { background: var(--orange); animation: blink 0.7s infinite; }
.status-playing .status-dot { background: var(--green); animation: blink 1s infinite; }
.status-error .status-dot { background: var(--red); }

@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- Transcripciones ---------- */

.transcript-card {
  flex: 1;
  min-height: 130px;
  max-height: 38dvh;
  overflow-y: auto;
  padding: 16px 18px;
}

.transcripts { display: flex; flex-direction: column; gap: 14px; }

.transcript-empty {
  color: var(--text-soft);
  text-align: center;
  margin: 14px 0;
}

.bubble { display: flex; flex-direction: column; gap: 3px; }

.bubble .who {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}
.bubble.mine .who { color: var(--accent); }

.bubble .original { font-size: 16px; color: var(--text-soft); margin: 0; }
.bubble .translated { font-size: 20px; font-weight: 600; margin: 0; }

/* ---------- Botón de hablar ---------- */

.talk-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 6px;
}

.talk-btn {
  position: relative;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #2da0ff, var(--accent-dark));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(10, 132, 255, 0.45);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  touch-action: none;
}

.talk-btn:disabled {
  background: linear-gradient(180deg, #b9c3d4, #9aa6bb);
  box-shadow: none;
  cursor: default;
}

.talk-btn.pressed {
  transform: scale(1.06);
  background: linear-gradient(180deg, #ff5f57, #e0352b);
  box-shadow: 0 14px 40px rgba(255, 69, 58, 0.5);
}

.talk-mic { width: 46px; height: 46px; fill: currentColor; }

.talk-label {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.talk-rings {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 3px solid rgba(255, 69, 58, 0.5);
  opacity: 0;
  pointer-events: none;
}

.talk-btn.pressed .talk-rings { animation: ring 1.2s ease-out infinite; }

@keyframes ring {
  0% { transform: scale(0.92); opacity: 0.9; }
  100% { transform: scale(1.25); opacity: 0; }
}

.btn-repeat { padding: 14px 22px; font-size: 18px; border-radius: 999px; }

/* ---------- Avisos ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 90vw;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 22px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 50;
  text-align: center;
}
