/* Knowledge Pulse widget -- Grammarly-style floating orb (bottom-right). */

.pulse-orb {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-pulse-orb);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-circle);
  border: none;
  cursor: pointer;
  background: var(--kp-gradient-orb);
  color: var(--surface);
  box-shadow: var(--shadow-pulse-orb);
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform var(--motion-quick) ease, box-shadow var(--motion-quick) ease;
}

.pulse-orb.pulse-visible {
  display: inline-flex;
  animation: pulse-breathe var(--motion-pulse) ease-in-out infinite;
}

.pulse-orb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pulse-orb-hover);
}

.pulse-orb svg {
  width: 26px;
  height: 26px;
}

.pulse-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-1-5);
  border-radius: 11px;
  background: var(--kp-accent-red);
  color: var(--surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 22px;
  text-align: center;
  border: 2px solid var(--surface);
  box-sizing: border-box;
}

@keyframes pulse-breathe {
  0%, 100% { box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35),
                         0 2px 6px rgba(0, 0, 0, 0.15),
                         0 0 0 0 rgba(59, 130, 246, 0.55); }
  50%      { box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35),
                         0 2px 6px rgba(0, 0, 0, 0.15),
                         0 0 0 10px rgba(59, 130, 246, 0); }
}

/* Modal */
.pulse-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-pulse-modal);
  background: rgba(15, 23, 42, 0.55); /* fallback for browsers without color-mix */
  background: color-mix(in srgb, var(--kp-ink) 55%, transparent);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.pulse-modal-overlay.pulse-open {
  display: flex;
}

.pulse-modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  padding: var(--space-6);
  box-shadow: var(--shadow-pulse-modal);
  max-height: 90vh;
  overflow-y: auto;
}

.pulse-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.pulse-modal-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kp-accent-blue-deep);
  margin: 0;
}

.pulse-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--kp-text-muted);
  padding: var(--space-1);
  line-height: 1;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pulse-modal-meta {
  font-size: 13px;
  color: var(--kp-text-muted);
  margin-bottom: var(--space-3);
}

.pulse-modal-meta strong {
  color: var(--kp-ink);
}

.pulse-modal-question {
  background: var(--kp-surface-blue-soft);
  border-left: 3px solid var(--kp-accent-blue);
  padding: var(--space-3) 14px;
  border-radius: var(--radius-sm);
  color: var(--kp-ink);
  font-size: var(--text-base);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pulse-modal-deviation {
  background: var(--kp-surface-amber-soft);
  border-left-color: var(--kp-accent-amber);
}

.pulse-modal textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--kp-border);
  font-family: inherit;
  font-size: var(--text-base);
  resize: vertical;
  box-sizing: border-box;
}

.pulse-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: 14px;
}

.pulse-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.pulse-btn-secondary {
  background: var(--surface);
  color: var(--kp-text-strong);
  border-color: var(--kp-border);
}

.pulse-btn-primary {
  background: var(--kp-accent-blue-deep);
  color: var(--surface);
}

.pulse-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mic button + recording state */
.pulse-btn-mic {
  background: var(--surface);
  color: var(--kp-accent-blue-deep);
  border-color: var(--kp-accent-blue-deep);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
}

.pulse-btn-mic:hover {
  background: var(--kp-surface-blue-soft);
}

.pulse-btn-mic:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pulse-mic-icon {
  font-size: 15px;
  line-height: 1;
}

.pulse-btn-mic.pulse-mic-recording {
  background: var(--kp-accent-red-deep);
  color: var(--surface);
  border-color: var(--kp-accent-red-deep);
  animation: pulse-mic-blink 1.2s ease-in-out infinite;
}

@keyframes pulse-mic-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.pulse-voice-hint {
  font-size: var(--text-xs);
  color: var(--kp-text-muted);
  margin-top: 2px;
  margin-bottom: var(--space-2);
}

.pulse-voice-status {
  font-size: var(--text-xs);
  color: var(--kp-accent-blue-deep);
  margin-top: var(--space-1-5);
  margin-bottom: 4px;
}

/* Toast */
.pulse-toast {
  position: fixed;
  bottom: 96px;
  right: var(--space-6);
  z-index: var(--z-pulse-toast);
  background: var(--kp-success-deep);
  color: var(--surface);
  padding: 10px var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  box-shadow: var(--shadow-pulse-toast);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.pulse-toast.pulse-toast-show {
  opacity: 1;
  transform: translateY(0);
}

.pulse-toast-error {
  background: var(--kp-danger-deep);
}
