/* Voice Widget Styles */
#kv-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 9999;
  padding: 0;
  background: rgba(26, 26, 46, .9);
  box-shadow: 0 4px 20px rgba(167, 139, 250, .35);
  transition: transform .2s, box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#kv-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(167, 139, 250, .5);
}

#kv-fab img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

#kv-fab.active {
  background: #ef4444;
  box-shadow: 0 4px 20px rgba(239, 68, 68, .4);
}

#kv-fab.active img {
  display: none;
}

#kv-fab.active::after {
  content: '\2715';
  color: #fff;
  font-size: 24px;
}

#kv-panel {
  display: none;
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 360px;
  max-height: 520px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 16px;
  z-index: 9998;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  flex-direction: column;
}

#kv-panel.show {
  display: flex;
  animation: kvSlideUp .25s ease-out;
}

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

.kv-header {
  background: linear-gradient(135deg, #16213e, #0f3460);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.kv-header img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.kv-header-text h3 {
  color: #e2e8f0;
  font-size: .95rem;
  margin: 0;
  line-height: 1.2;
}

.kv-header-text p {
  color: #94a3b8;
  font-size: .75rem;
  margin: 0;
}

.kv-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kv-timer {
  color: #94a3b8;
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}

#kv-mic-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
}

#kv-mic-btn.on {
  background: rgba(167, 139, 250, .2);
  color: #a78bfa;
}

#kv-mic-btn.off {
  background: rgba(239, 68, 68, .2);
  color: #ef4444;
}

.kv-body {
  padding: 20px;
  text-align: center;
  flex-shrink: 0;
}

.kv-body p {
  color: #94a3b8;
  font-size: .85rem;
  margin-bottom: 16px;
}

#kv-turnstile {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

#kv-call-btn {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 28px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
  width: 100%;
}

#kv-call-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

#kv-call-btn:hover:not(:disabled) {
  opacity: .9;
}

.kv-connecting {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: #a78bfa;
  font-size: .9rem;
  flex-shrink: 0;
}

.kv-connecting.show {
  display: flex;
}

.kv-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #2a2a4a;
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: kvSpin .8s linear infinite;
}

@keyframes kvSpin {
  to {
    transform: rotate(360deg);
  }
}

#kv-chat {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#kv-chat.show {
  display: flex;
}

#kv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  max-height: 320px;
}

#kv-messages::-webkit-scrollbar {
  width: 4px;
}

#kv-messages::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 2px;
}

.kv-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .85rem;
  line-height: 1.4;
  word-wrap: break-word;
  animation: kvFadeIn .2s ease-out;
}

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

.kv-msg.ai {
  align-self: flex-start;
  background: #16213e;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.kv-msg.user {
  align-self: flex-end;
  background: rgba(167, 139, 250, .15);
  color: #e2e8f0;
  border-bottom-right-radius: 4px;
}

.kv-msg.system {
  align-self: center;
  color: #64748b;
  font-size: .75rem;
  font-style: italic;
  padding: 4px 8px;
}

.kv-msg .kv-msg-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  margin-bottom: 2px;
}

.kv-msg.ai .kv-msg-label {
  color: #a78bfa;
}

.kv-msg.user .kv-msg-label {
  color: #94a3b8;
}

.kv-msg.streaming::after {
  content: '\25CF';
  animation: kvBlink 1s infinite;
  margin-left: 2px;
  color: #a78bfa;
}

@keyframes kvBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .3;
  }
}

.kv-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #2a2a4a;
  flex-shrink: 0;
  align-items: center;
}

#kv-text-input {
  flex: 1;
  background: #0f0f1a;
  border: 1px solid #2a2a4a;
  border-radius: 20px;
  padding: 8px 14px;
  color: #e2e8f0;
  font-size: .85rem;
  outline: none;
  font-family: inherit;
}

#kv-text-input:focus {
  border-color: #a78bfa;
}

#kv-text-input::placeholder {
  color: #475569;
}

#kv-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: opacity .2s;
}

#kv-send-btn:hover {
  opacity: .85;
}

#kv-controls-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #2a2a4a;
  flex-shrink: 0;
}

#kv-stop-btn {
  background: #f59e0b;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .2s;
}

#kv-stop-btn:hover {
  background: #d97706;
}

#kv-end-btn {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 6px 20px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

#kv-end-btn:hover {
  background: #dc2626;
}

@media (max-width: 420px) {
  #kv-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 88px;
    max-height: 70vh;
  }
}
