/* ==========================================================================
   Jessica Live Calls — Impeccable Telegram Mini App UI
   ========================================================================== */

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #131722;
  --card-bg: rgba(26, 31, 46, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);

  --accent-pink: #ec4899;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --danger: #ef4444;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
  background: radial-gradient(circle at 50% 25%, #1e1b4b 0%, #0a0d14 75%);
}

/* Фоновые декоративные сферы свечения */
.glow-backdrop {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.22) 0%, rgba(139, 92, 246, 0.12) 50%, transparent 70%);
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
  transition: all 0.6s ease;
}

.glow-backdrop.speaking {
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.35) 0%, rgba(139, 92, 246, 0.2) 60%, transparent 75%);
}

/* ==========================================================================
   Header (Статус и таймер)
   ========================================================================== */
.call-header {
  width: 100%;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-rose);
  animation: pulse-dot 1.8s infinite;
}

.connection-badge.connected .connection-dot {
  background-color: var(--accent-green);
  animation: none;
  box-shadow: 0 0 10px var(--accent-green);
}

.connection-badge.reconnecting .connection-dot {
  background-color: #f59e0b;
  animation: pulse-dot 0.8s infinite;
  box-shadow: 0 0 8px #f59e0b;
}

.btn-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 8px 20px;
  border-radius: 9999px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-retry:active {
  transform: scale(0.96);
  background: rgba(239, 68, 68, 0.25);
}

.call-timer {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 1px;
}

/* ==========================================================================
   Центральный блок (Аватар + Аудио-волны)
   ========================================================================== */
.call-main {
  flex: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 20px;
  z-index: 10;
}

.avatar-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}

/* Пульсирующие кольца вокруг аватара */
.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(236, 72, 153, 0.3);
  opacity: 0;
  pointer-events: none;
}

.speaking .pulse-ring-1 {
  animation: ring-pulse 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
.speaking .pulse-ring-2 {
  animation: ring-pulse 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite 0.7s;
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #8b5cf6);
  padding: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 35px rgba(236, 72, 153, 0.3);
  position: relative;
  z-index: 2;
  transition: transform 0.3s ease;
}

.avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
}

.avatar-svg {
  width: 80%;
  height: 80%;
}

.contact-name {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  text-align: center;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.call-status-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 24px;
  transition: color 0.3s ease;
}

/* Canvas аудио-визуализатора */
.visualizer-container {
  width: 100%;
  height: 70px;
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#audioCanvas {
  width: 100%;
  max-width: 320px;
  height: 100%;
}

/* ==========================================================================
   Субтитры реального времени (Live Captions)
   ========================================================================== */
.captions-box {
  width: 100%;
  max-width: 360px;
  min-height: 50px;
  max-height: 90px;
  overflow-y: auto;
  margin-top: 12px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

.captions-box:empty {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Панель кнопок (Control Bar)
   ========================================================================== */
.call-controls {
  width: 100%;
  max-width: 380px;
  padding: 20px 24px 34px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.btn-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  transition: transform 0.15s ease;
}

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

.btn-icon-wrapper {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.25s ease;
}

.btn-control.active .btn-icon-wrapper {
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
}

.btn-control.muted .btn-icon-wrapper {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

/* Большая кнопка отбоя */
.btn-end-call .btn-icon-wrapper {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4);
}

.btn-end-call:active .btn-icon-wrapper {
  transform: scale(0.92);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* ==========================================================================
   Анимации
   ========================================================================== */
@keyframes ring-pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.7);
    opacity: 0;
  }
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

/* ==========================================================================
   Starter Overlay (User Interaction Gate для iOS и мобильных браузеров)
   ========================================================================== */
.call-starter-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 13, 20, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.call-starter-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.starter-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 320px;
}

.starter-avatar-ring {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.4);
  animation: pulse-ring-glow 2s infinite ease-in-out;
}

@keyframes pulse-ring-glow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 45px rgba(16, 185, 129, 0.7);
  }
}

.starter-icon {
  width: 44px;
  height: 44px;
  color: #ffffff;
}

.starter-title {
  font-size: 24px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.starter-desc {
  font-size: 14px;
  line-height: 1.5;
  color: #94a3b8;
  margin-bottom: 32px;
}

.starter-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  padding: 16px 36px;
  border-radius: 9999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.starter-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* ==========================================================================
   PT-26: Стили для демонстрации экрана, тостов и визуальных подсказок
   ========================================================================== */

/* Кнопка "Экран" в активном состоянии */
.btn-control.active-screen .btn-icon-wrapper {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(16, 185, 129, 0.3));
  border-color: #06b6d4;
  color: #38bdf8;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.5);
  animation: screen-btn-pulse 2.5s infinite ease-in-out;
}

.btn-control.active-screen .btn-label {
  color: #38bdf8;
  font-weight: 600;
}

@keyframes screen-btn-pulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
  }
  50% {
    box-shadow: 0 0 22px rgba(6, 182, 212, 0.7);
  }
}

/* Всплывающий стильный тост уведомлений */
.toast-notification {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(19, 23, 34, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 500;
  color: #f8fafc;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-notification.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

/* Оверлей визуальных подсказок на экране от Джессики */
.screen-hint-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 20, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.screen-hint-card {
  background: #131722;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
}

.screen-hint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.screen-hint-title {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-close-hint {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-close-hint:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.screen-canvas-wrapper {
  position: relative;
  width: 100%;
  max-height: 52vh;
  background: #0a0d14;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-canvas-wrapper canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* Рамка подсветки элемента (Bounding Box) */
.hint-bounding-box {
  position: absolute;
  border: 2px solid #06b6d4;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.7), inset 0 0 16px rgba(6, 182, 212, 0.3);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hint-pulse-ring {
  position: absolute;
  inset: -6px;
  border: 2px solid #ec4899;
  border-radius: 12px;
  animation: hint-box-pulse 1.4s infinite ease-out;
}

@keyframes hint-box-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.hint-badge {
  position: absolute;
  top: -26px;
  left: 0;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

/* Модалка обхода ограничений Telegram WebView для показа экрана */
.screen-fallback-card {
  max-width: 380px;
}

.screen-fallback-body {
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-fallback-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #cbd5e1;
}

.screen-fallback-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-fallback-primary {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(6, 182, 212, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-fallback-primary:active {
  transform: scale(0.98);
}

.btn-fallback-secondary {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-fallback-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.btn-fallback-danger {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-fallback-danger:hover {
  background: rgba(239, 68, 68, 0.24);
}

.btn-fallback-danger:active {
  transform: scale(0.98);
}
