/* ==========================================
   Voice AI Widget — Горбунов
   ========================================== */

.vg-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

/* FAB toggle */
.vg-toggle {
  pointer-events: auto;
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #7a2840, #4e1828, #2a0f18);
  background-size: 200% 200%;
  animation: vgBtnGradient 4s ease infinite;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(122, 40, 64, 0.5), 0 0 40px rgba(122, 40, 64, 0.2);
  transition: opacity 0.6s ease, transform 0.6s ease, box-shadow 0.3s;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}
.vg-toggle.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.vg-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(122, 40, 64, 0.6), 0 0 60px rgba(122, 40, 64, 0.25);
}
.vg-toggle:active { transform: scale(0.95); }

@keyframes vgBtnGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.vg-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(122, 40, 64, 0.4), rgba(78, 24, 40, 0.4));
  animation: vgPulseRing 2.5s ease-in-out infinite;
  z-index: -1;
}
@keyframes vgPulseRing {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.25); opacity: 0; }
}

.vg-widget.attention-pulse .vg-toggle {
  animation: vgAttentionPulse 1.4s cubic-bezier(0.36, 0.07, 0.19, 0.97), vgBtnGradient 4s ease infinite;
}
@keyframes vgAttentionPulse {
  0%   { transform: scale(1)    rotate(0deg); }
  8%   { transform: scale(1.12) rotate(-4deg); }
  16%  { transform: scale(1.12) rotate(4deg); }
  24%  { transform: scale(1.12) rotate(-3deg); }
  32%  { transform: scale(1.12) rotate(3deg); }
  40%  { transform: scale(1.08) rotate(-2deg); }
  48%  { transform: scale(1.08) rotate(2deg); }
  60%  { transform: scale(1.04) rotate(-1deg); }
  72%  { transform: scale(1.02) rotate(1deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

.vg-widget.open .vg-toggle::before { display: none; }
.vg-toggle-close { display: none; }
.vg-widget.open .vg-toggle-mic { display: none; }
.vg-widget.open .vg-toggle-close { display: block; }

/* Status dot on FAB */
.vg-toggle-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid #1a0a0f;
  z-index: 1;
  transition: background 0.3s;
}
.vg-widget.vg-listening .vg-toggle-dot { background: #f9a8d4; }
.vg-widget.vg-speaking .vg-toggle-dot { background: #c084fc; }

/* Tooltip */
.vg-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  background: rgba(15, 2, 7, 0.97);
  border: 1px solid rgba(122, 40, 64, 0.4);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.vg-toggle:hover .vg-tooltip { opacity: 1; }
.vg-widget.open .vg-tooltip { display: none; }

/* Panel */
.vg-panel {
  pointer-events: auto;
  width: 360px;
  max-height: 530px;
  margin-bottom: 12px;
  background: rgba(12, 4, 8, 0.97);
  border: 1px solid rgba(122, 40, 64, 0.3);
  border-radius: 16px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(122, 40, 64, 0.1);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9) translateY(16px);
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.vg-widget.open .vg-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.vg-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(122, 40, 64, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 1;
}
.vg-panel-close:hover { background: rgba(122, 40, 64, 0.2); color: #fff; }

/* Header */
.vg-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.75rem;
  padding-right: 2rem;
}
.vg-panel-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7a2840, #4e1828);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.vg-panel-title {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  line-height: 1.2;
}
.vg-panel-sub {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
}

/* Status badge */
.vg-status-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.2);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s;
  white-space: nowrap;
}
.vg-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  transition: background 0.3s;
}
.vg-widget.vg-listening .vg-status-badge {
  background: rgba(249, 168, 212, 0.1);
  border-color: rgba(249, 168, 212, 0.3);
  color: #f9a8d4;
}
.vg-widget.vg-listening .vg-status-dot { background: #f9a8d4; }
.vg-widget.vg-speaking .vg-status-badge {
  background: rgba(192, 132, 252, 0.1);
  border-color: rgba(192, 132, 252, 0.3);
  color: #c084fc;
}
.vg-widget.vg-speaking .vg-status-dot { background: #c084fc; }

/* Chat messages */
.vg-chat {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
  max-height: 280px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 40, 64, 0.3) transparent;
  scroll-behavior: smooth;
}
.vg-chat::-webkit-scrollbar { width: 3px; }
.vg-chat::-webkit-scrollbar-track { background: transparent; }
.vg-chat::-webkit-scrollbar-thumb { background: rgba(122, 40, 64, 0.4); border-radius: 2px; }

.vg-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  animation: vgMsgIn 0.25s ease;
}
@keyframes vgMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.vg-msg.user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-right-radius: 4px;
}
.vg-msg.ai {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(122, 40, 64, 0.18), rgba(78, 24, 40, 0.15));
  border: 1px solid rgba(122, 40, 64, 0.25);
  color: rgba(255, 255, 255, 0.88);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.vg-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(122, 40, 64, 0.12), rgba(78, 24, 40, 0.1));
  border: 1px solid rgba(122, 40, 64, 0.2);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.vg-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(180, 80, 110, 0.8);
  animation: vgTypingBounce 1.4s ease-in-out infinite;
}
.vg-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.vg-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes vgTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Orb */
.vg-orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}
.vg-orb-canvas { width: 80px; height: 80px; }
.vg-orb-label {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(200, 100, 130, 0.8);
  transition: color 0.3s;
}
.vg-widget.vg-speaking .vg-orb-label { color: #c084fc; }

/* Chips */
.vg-chips {
  display: flex;
  gap: 6px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.vg-chip {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid rgba(122, 40, 64, 0.35);
  background: rgba(122, 40, 64, 0.08);
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.vg-chip:hover {
  background: rgba(122, 40, 64, 0.2);
  border-color: rgba(180, 80, 110, 0.5);
  color: rgba(255, 200, 210, 0.9);
}

/* Input row */
.vg-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(122, 40, 64, 0.2);
}
.vg-text-input {
  flex: 1;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid rgba(122, 40, 64, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.9);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.vg-text-input::placeholder { color: rgba(255, 255, 255, 0.25); }
.vg-text-input:focus { border-color: rgba(180, 80, 110, 0.5); }

.vg-send-btn,
.vg-mic-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.vg-send-btn {
  background: linear-gradient(135deg, #7a2840, #4e1828);
  color: #fff;
}
.vg-send-btn:hover { box-shadow: 0 2px 14px rgba(122, 40, 64, 0.5); transform: scale(1.05); }
.vg-send-btn:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }
.vg-mic-btn {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(122, 40, 64, 0.3);
}
.vg-mic-btn:hover { background: rgba(122, 40, 64, 0.15); color: rgba(255, 200, 210, 0.9); border-color: rgba(180, 80, 110, 0.4); }
.vg-mic-btn.active {
  background: linear-gradient(135deg, #7a2840, #4e1828);
  color: #fff;
  border-color: transparent;
  animation: vgMicPulse 2s ease-in-out infinite;
}
@keyframes vgMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(122, 40, 64, 0.4); }
  50% { box-shadow: 0 0 0 7px rgba(122, 40, 64, 0); }
}

/* Stop button */
.vg-active-controls {
  display: flex;
  gap: 8px;
  padding-top: 6px;
}
.vg-btn-stop {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 10px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  transition: all 0.2s;
}
.vg-btn-stop:hover { background: #ef4444; box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35); }

/* Mobile */
@media (max-width: 480px) {
  .vg-widget { bottom: 4.5rem; right: 0.75rem; }
  .vg-panel { width: calc(100vw - 1.5rem); }
}
