/* "Pregunta": the assistant. Phone: a tall sheet. Desktop: a drawer on the right, the parcel stays visible. */

.ask-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 14px; margin-left: 4px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--gold); color: var(--pine);
  font: inherit; font-weight: 700; font-size: 15px;
  transition: transform 0.18s var(--ease-out), box-shadow 0.2s;
}
.ask-btn .ic { width: 20px; height: 20px; }
.ask-btn:hover { box-shadow: 0 4px 14px -4px rgba(243, 211, 107, 0.7); }
.ask-btn:active { transform: scale(0.96); }
@media (max-width: 599px) {
  .ask-btn { padding: 0; justify-content: center; }
  .ask-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

.ask-pill {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; margin: 14px 0 4px; padding: 8px 18px 8px 8px;
  border: 1.5px solid var(--line-strong); border-radius: var(--leaf-r-sm, 18px 5px 18px 5px);
  background: var(--surface); color: var(--muted);
  font: inherit; font-size: 16px; text-align: left; cursor: text;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.18s var(--ease-out);
}
.ask-pill:hover { border-color: var(--leaf); box-shadow: 0 0 0 4px var(--mint-tint); }
.ask-pill:active { transform: scale(0.99); }
.ask-pill-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px 4px 12px 4px; background: var(--pine); color: var(--gold); }
html:not([data-loaded]) .ask-pill { visibility: hidden; }

/* ---------- Sheet ---------- */
.sheet.sheet-ai { height: 88dvh; }
.ai-head { align-items: flex-start; padding-top: 8px; }
.ai-head-text { display: grid; gap: 4px; padding-top: 6px; min-width: 0; }
.ai-head-actions { display: flex; gap: 2px; flex: none; }
.ai-badge {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.ai-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ai-badge.is-claude { background: var(--mint-tint); color: var(--emerald); }
.ai-badge.is-rules { background: var(--gold-tint); color: var(--gold-text); }
.ai-badge.is-rules::before { border-radius: 2px; transform: rotate(45deg); }

.ai-thread {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px;
  padding: 10px 18px 16px;
}
.ai-msg { max-width: 88%; font-size: 16px; line-height: 1.5; }
.ai-msg p, .ai-msg ul, .ai-msg ol { margin: 0 0 8px; }
.ai-msg > :last-child { margin-bottom: 0; }
.ai-msg ul, .ai-msg ol { padding-left: 20px; }
.ai-msg li + li { margin-top: 4px; }
.ai-msg .prov { font-size: 12.5px; vertical-align: 1px; margin: 0 2px; }
.ai-user { align-self: flex-end; padding: 10px 14px; border-radius: 18px 18px 4px 18px; background: var(--emerald); color: var(--cream); }
.ai-assistant { align-self: flex-start; padding: 12px 16px; border-radius: 4px 18px 18px 18px; background: var(--sunken); color: var(--ink); }
.ai-assistant.is-error { background: var(--risk-tint); color: var(--risk); font-weight: 600; }
.ai-why { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.ai-cue { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--emerald); font-weight: 600; font-size: 14px; }
.ai-cue .ic { width: 18px; height: 18px; }

.ai-dots { display: inline-flex; gap: 5px; padding: 4px 0; }
.ai-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: aiDot 1.1s var(--ease-io) infinite; }
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiDot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-4px); } }

.ai-in { animation: aiIn 0.42s var(--ease-pop) both; }
.ai-user.ai-in { transform-origin: 100% 100%; }
.ai-assistant.ai-in { transform-origin: 0 0; }
@keyframes aiIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

.ai-empty { display: grid; gap: 14px; margin: auto 0; padding: 8px 0; }
.ai-empty-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px 5px 18px 5px; background: var(--pine); color: var(--gold); }
.ai-empty-mark .ic { width: 26px; height: 26px; }
.ai-empty p { margin: 0; color: var(--muted); max-width: 46ch; }
.ai-chips { display: grid; gap: 8px; }
.ai-chip {
  min-height: 48px; padding: 10px 14px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.18s var(--ease-out);
}
.ai-chip:hover { border-color: var(--leaf); background: var(--mint-tint); }
.ai-chip:active { transform: scale(0.98); }

.ai-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px 18px; border-top: 1px solid var(--line); }
.ai-composer textarea {
  flex: 1; min-height: 48px; max-height: 160px; padding: 12px 14px; resize: none;
  border: 1.5px solid var(--line-strong); border-radius: 16px; background: var(--paper, var(--surface));
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ink);
}
.ai-composer textarea:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 4px var(--mint-tint); }
.ai-composer .icon-btn { width: 48px; height: 48px; flex: none; }
.ai-composer .icon-btn:disabled { opacity: 0.5; }
.ai-foot { margin: 0; padding: 0 18px 10px; color: var(--muted); font-size: 13px; }

@media (min-width: 900px) {
  .sheet.sheet-ai {
    top: 12px; right: 12px; bottom: 12px; left: auto;
    width: min(440px, calc(100vw - 48px)); height: auto; max-height: none;
    border: 1px solid var(--line); border-radius: 24px;
    opacity: 1; transform: translateX(calc(100% + 24px));
    transition: transform 0.45s var(--ease-sheet);
    box-shadow: -20px 0 60px -20px rgba(16, 35, 26, 0.45);
  }
  .sheet.sheet-ai.open { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-dots i, .ai-in { animation: none !important; }
  .sheet.sheet-ai { transition: none; }
}
