/* ============================================================
   Command Palette — floating command bar (Cmd+K / Ctrl+K)
   ============================================================ */

/* ── Container ─────────────────────────────────────────────── */
.cmd-palette {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 640px;
  width: calc(100% - 48px);
  z-index: 45;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  flex-direction: column;
  overflow: hidden;
}

.cmd-palette.open {
  display: flex;
  flex-direction: column;
}

/* ── Conversation messages ─────────────────────────────────── */
.cmd-palette-messages {
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  display: none;
}

.cmd-palette-messages:not(:empty) {
  display: block;
}

.cmd-msg {
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.5;
}

.cmd-msg-user {
  color: #374151;
  text-align: end;
}

.cmd-msg-assistant {
  color: #0d9488;
}

.cmd-msg-error {
  color: #dc2626;
}

/* ── Input row ─────────────────────────────────────────────── */
.cmd-palette-input-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}

.cmd-palette-context {
  font-size: 11px;
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #99f6e4;
  border-radius: 9999px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cmd-palette-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  font-family: inherit;
  min-width: 0;
}

.cmd-palette-input::placeholder {
  color: #9ca3af;
}

.cmd-palette-send {
  width: 32px;
  height: 32px;
  background: #14b8a6;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
  flex-shrink: 0;
}

.cmd-palette-send:hover {
  background: #0d9488;
}

.cmd-palette-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cmd-palette-send svg {
  width: 16px;
  height: 16px;
}

/* ── Loading indicator ─────────────────────────────────────── */
.cmd-palette-loading {
  display: none;
  padding: 8px 16px;
  font-size: 12px;
  color: #6b7280;
  align-items: center;
  gap: 8px;
}

.cmd-palette.loading .cmd-palette-loading {
  display: flex;
}

.cmd-palette-dots {
  display: flex;
  gap: 4px;
}

.cmd-palette-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cmd-dot-pulse 1.2s ease-in-out infinite;
}

.cmd-palette-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.cmd-palette-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes cmd-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Keyboard hint ─────────────────────────────────────────── */
.cmd-palette-hint {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  font-size: 11px;
  color: #9ca3af;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  opacity: 0.7;
  transition: opacity 0.2s;
  cursor: pointer;
  z-index: 44;
}

.cmd-palette-hint:hover {
  opacity: 1;
}

.cmd-palette.open ~ .cmd-palette-hint {
  display: none;
}

/* ── Save to library offer ────────────────────────────────────── */
.cmd-save-offer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmd-save-offer button {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.cmd-save-offer .cmd-save-yes {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

.cmd-save-offer .cmd-save-yes:hover {
  background: #ccfbf1;
}

.cmd-save-offer .cmd-save-no:hover {
  background: #f3f4f6;
}

/* ── Pre-formatted plan text ──────────────────────────────────── */
.cmd-msg-assistant {
  white-space: pre-wrap;
}

/* ── Confirm / Cancel buttons ────────────────────────────────── */
.cmd-confirm-buttons {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  white-space: normal;
}

.cmd-confirm-yes,
.cmd-confirm-no {
  font-size: 12px;
  padding: 5px 16px;
  border-radius: 9999px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.cmd-confirm-yes {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
}

.cmd-confirm-yes:hover {
  background: #0f766e;
}

.cmd-confirm-no {
  background: #fff;
  border-color: #d1d5db;
  color: #6b7280;
}

.cmd-confirm-no:hover {
  background: #f3f4f6;
}

/* ── Disambiguation choices ──────────────────────────────────── */
.cmd-disambiguation {
  white-space: normal;
}

.cmd-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.cmd-choice-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cmd-choice-btn:hover {
  background: #c7d2fe;
  border-color: #818cf8;
}

.cmd-choices-more {
  font-size: 11px;
  color: #6b7280;
  padding: 4px 0;
  width: 100%;
}

/* ── Result display ──────────────────────────────────────────── */
.cmd-result-message {
  margin-bottom: 4px;
}

.cmd-result-field {
  font-size: 12px;
  line-height: 1.4;
}

.cmd-result-field strong {
  color: #374151;
}

.cmd-result-list {
  margin: 2px 0 4px 12px;
  font-size: 12px;
}

.cmd-result-item {
  padding: 1px 0;
  color: #4b5563;
}

.cmd-result-item::before {
  content: "· ";
  color: #9ca3af;
}

/* ── Clickable entity links ──────────────────────────────────── */
.cmd-entity-link {
  color: #4338ca;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dashed #c7d2fe;
  transition: all 0.15s;
}

.cmd-entity-link:hover {
  color: #3730a3;
  border-bottom-color: #818cf8;
}

.cmd-entity-detail {
  color: #6b7280;
  font-size: 11px;
}

/* ── Choice wrapper with nav arrow ───────────────────────────── */
.cmd-choice-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.cmd-choice-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 11px;
  color: #9ca3af;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s;
}

.cmd-choice-nav:hover {
  color: #4338ca;
  background: #eef2ff;
}

/* -- Paperclip attach button ------------------------------------------ */
.cmd-palette-attach {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #9ca3af;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.cmd-palette-attach:hover {
  color: #0d9488;
  background: #f0fdfa;
}

.cmd-palette-attach svg {
  width: 16px;
  height: 16px;
}

/* -- File chip (shown when a file is attached) ------------------------ */
.cmd-palette-file-chip {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #f0fdfa;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
}

.cmd-file-chip-label {
  color: #0f766e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
}

.cmd-file-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.cmd-file-chip-remove:hover {
  color: #dc2626;
}

/* Markdown content in assistant messages */
.cmd-msg-assistant h1,.cmd-msg-assistant h2,.cmd-msg-assistant h3{font-size:14px;font-weight:700;margin:8px 0 4px;color:#e5e7eb}
.cmd-msg-assistant h1{font-size:16px}
.cmd-msg-assistant p{margin:4px 0}
.cmd-msg-assistant ul,.cmd-msg-assistant ol{margin:4px 0 4px 20px}
.cmd-msg-assistant li{margin:2px 0}
.cmd-msg-assistant table{width:100%;border-collapse:collapse;font-size:12px;margin:8px 0}
.cmd-msg-assistant th{background:rgba(255,255,255,0.06);padding:4px 8px;text-align:left;font-weight:600;border-bottom:1px solid rgba(255,255,255,0.1)}
.cmd-msg-assistant td{padding:4px 8px;border-bottom:1px solid rgba(255,255,255,0.05)}
.cmd-msg-assistant code{background:rgba(255,255,255,0.08);padding:1px 4px;border-radius:3px;font-size:12px}
.cmd-msg-assistant pre{background:rgba(255,255,255,0.06);padding:8px;border-radius:4px;overflow-x:auto;margin:8px 0}
.cmd-msg-assistant pre code{background:none;padding:0}
.cmd-msg-assistant a{color:#93c5fd;text-decoration:underline}
.cmd-msg-assistant strong{font-weight:600}
