/* cursor.css — AI cursor and mic button */

/* Mic button */
.chat-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--chat-text-muted);
  cursor: pointer;
  padding: 0;
  transition:
    color 0.2s,
    background 0.2s;
}

.chat-mic-btn:hover {
  color: var(--chat-text);
  background: var(--chat-surface-hover);
}


.chat-mic-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Listening state: rounded pill with "End" label + red pulse */
.chat-mic-btn.listening {
  width: auto;
  padding: 0 var(--space-3);
  gap: 0.375rem;
  border-radius: 100px;
  background: color-mix(in srgb, var(--color-listening) 10%, transparent);
  border: var(--border-width-1) solid color-mix(in srgb, var(--color-listening) 40%, transparent);
  color: var(--color-listening);
  animation: mic-btn-pulse 1.5s ease-in-out infinite;
}

.chat-mic-btn.listening::after {
  content: "End";
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
}

@keyframes mic-btn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-listening) 30%, transparent);
  }
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--color-listening) 0%, transparent);
  }
}

/* Tooltip wrapper */
.chat-mic-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-mic-tooltip {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* In multiline mode, mic wrap pushes right (margin-left:auto set in chat.css) */
.chat-input-container.multiline .chat-mic-wrap {
  order: 2;
  margin-left: auto;
}

/* In context mode: chip row order 2, mic order 3, send order 4 */
.chat-input-container.has-context .chat-mic-wrap {
  order: 3;
  margin-left: auto;
}

/* Session-active state: subtle accent breathe */
.chat-mic-btn.session-active {
  color: var(--chat-accent);
  animation: mic-session-breathe 2.5s ease-in-out infinite;
}

@keyframes mic-session-breathe {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Processing state: dimmed, not clickable feel */
.chat-mic-btn.processing {
  color: var(--chat-text-muted);
  opacity: 0.5;
  cursor: default;
}

/* End state: red pill with "End" label — same visual as old listening pill */
.chat-mic-btn.session-end {
  width: auto;
  padding: 0 var(--space-3);
  gap: 0.375rem;
  border-radius: 100px;
  background: color-mix(in srgb, var(--color-listening) 10%, transparent);
  border: var(--border-width-1) solid color-mix(in srgb, var(--color-listening) 40%, transparent);
  color: var(--color-listening);
  transition: background 0.2s, border-color 0.2s;
}

.chat-mic-btn.session-end::after {
  content: "End";
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.chat-mic-btn.session-end:hover {
  background: color-mix(in srgb, var(--color-listening) 18%, transparent);
  border-color: color-mix(in srgb, var(--color-listening) 70%, transparent);
}

.chat-mic-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chat-mic-btn:disabled:hover {
  color: var(--chat-text-muted);
  background: transparent;
}

/* Dark mode hover — matches plus button */
html[data-theme="dark"] .chat-mic-btn:hover {
  background: var(--chat-surface);
}

html[data-theme="dark"] .chat-mic-btn.session-end:hover {
  background: color-mix(in srgb, var(--color-listening) 18%, transparent);
}

/* Idle hint text inside bubble */
.cursor-idle-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--chat-text-muted);
  margin-top: var(--space-1);
}

/* Keyboard hint inside bubble */
.cursor-kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  background: var(--chat-surface-hover);
  border: var(--border-width-1) solid var(--chat-border);
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 600;
  line-height: 1.4;
  color: var(--chat-text);
  vertical-align: baseline;
}

/* Simulated cursor */
.ai-cursor {
  position: fixed;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 99999;
  opacity: 0;
  transition:
    left 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    top 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s;
}

.ai-cursor.visible {
  opacity: 1;
}

.ai-cursor svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

/* Click ripple */
.ai-cursor-ripple {
  position: fixed;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: var(--border-width-2) solid var(--chat-accent);
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.ai-cursor-ripple.pop {
  animation: cursor-ripple 0.45s ease-out forwards;
}

@keyframes cursor-ripple {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* Floating speech bubble */
.ai-cursor-bubble {
  position: fixed;
  z-index: 99997;
  max-width: 260px;
  min-width: 120px;
  background: var(--chat-surface);
  border: var(--border-width-1) solid var(--chat-border);
  border-radius: var(--radius-lg);
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--chat-text);
  pointer-events: none;
  box-shadow: var(--shadow-bubble);
  opacity: 0;
  transform: scale(0.9) translateY(4px);
  transition:
    opacity 0.2s,
    transform 0.2s;
  word-break: break-word;
}

.ai-cursor-bubble.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Listening indicator in bubble */
.ai-cursor-listening-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ai-cursor-listening-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  animation: cursor-dot-bounce 1.2s infinite ease-in-out;
}

.ai-cursor-listening-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.ai-cursor-listening-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cursor-dot-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Not-supported notice */
.cursor-unsupported-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--chat-error-bg);
  border: var(--border-width-1) solid var(--chat-error-border);
  color: var(--chat-error-text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.cursor-unsupported-toast.visible {
  opacity: 1;
}
