/* ═══════════════════════════════════════════════
   Activity Try-It Box + Copy Button
   ═══════════════════════════════════════════════ */

/* ── Prompt-try wrapper — needed for copy button positioning ── */
.prompt-try-wrap {
  position: relative;
  margin-top: 1.5rem;
}

/* ── Copy button ── */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .8rem;
  color: rgba(255,255,255,.7);
  transition: background .15s, color .15s, transform .1s;
  z-index: 2;
  flex-shrink: 0;
}
.copy-btn:hover {
  background: rgba(255,255,255,.25);
  color: white;
  transform: scale(1.1);
}
.copy-btn.copied {
  background: #0EB07A;
  border-color: #0EB07A;
  color: white;
}

/* ── Copied bubble ── */
.copy-bubble {
  position: absolute;
  top: -32px;
  right: 0;
  background: #1A1826;
  color: white;
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s;
  z-index: 10;
  font-family: var(--font-body, sans-serif);
}
.copy-bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 8px;
  border: 5px solid transparent;
  border-top-color: #1A1826;
  border-bottom: none;
}
.copy-bubble.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Try-it chatbox ── */
.activity-tryit {
  margin-top: 20px;
  border: 2px solid var(--accent, var(--m1));
  border-radius: var(--radius-lg, 22px);
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
}

.activity-tryit-header {
  background: var(--accent, var(--m1));
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.activity-tryit-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-weight: 700;
  font-size: .88rem;
}
.activity-tryit-counter {
  background: rgba(255,255,255,.2);
  color: white;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.activity-tryit-counter.warn {
  background: rgba(255,200,0,.35);
}
.activity-tryit-counter.out {
  background: rgba(255,80,80,.35);
}

/* Chat messages area */
.activity-chat-messages {
  max-height: 300px;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.activity-chat-messages:empty {
  display: none;
}

/* Individual message */
.act-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .86rem;
  line-height: 1.6;
  word-break: break-word;
}
.act-msg.user {
  background: var(--accent-l, var(--m1-l));
  color: var(--ink);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 600;
}
.act-msg.ai {
  background: #F4F4F6;
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.act-msg.thinking {
  background: #F4F4F6;
  color: var(--muted);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  font-style: italic;
}
.act-msg.error {
  background: #FFF0F0;
  color: #C0392B;
  align-self: flex-start;
  font-size: .82rem;
}

/* Input row */
.activity-tryit-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1.5px solid var(--border);
  background: #fafafa;
}
.activity-tryit-input textarea {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .88rem;
  font-family: var(--font-body, sans-serif);
  outline: none;
  transition: border-color .2s;
  background: white;
  color: var(--ink);
  min-width: 0;
  resize: none;
  overflow: hidden;
  min-height: 40px;
  max-height: 140px;
  line-height: 1.5;
  display: block;
}
.activity-tryit-input textarea:focus {
  border-color: var(--accent, var(--m1));
}
.activity-tryit-input textarea:disabled {
  background: #f0f0f0;
  color: var(--muted);
}
.activity-tryit-send {
  padding: 9px 16px;
  background: var(--accent, var(--m1));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  font-family: var(--font-body, sans-serif);
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-tryit-send:hover:not(:disabled) {
  opacity: .88;
  transform: translateY(-1px);
}
.activity-tryit-send:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

/* "Prompt loaded" flash on input */
@keyframes inputFlash {
  0% { border-color: var(--accent, var(--m1)); background: var(--accent-l, var(--m1-l)); }
  100% { border-color: var(--border); background: white; }
}
.activity-tryit-input textarea.flash {
  animation: inputFlash .6s ease forwards;
}

/* Limit reached message */
.activity-limit-msg {
  text-align: center;
  padding: 12px 16px;
  font-size: .84rem;
  color: var(--muted);
  border-top: 1.5px solid var(--border);
  background: #fafafa;
}

/* RTL */
[lang="he"] .activity-tryit-input textarea,
[lang="he"] .act-msg {
  direction: rtl;
  text-align: right;
}
[lang="he"] .act-msg.user { align-self: flex-start; border-bottom-left-radius: 4px; border-bottom-right-radius: 14px; }
[lang="he"] .act-msg.ai   { align-self: flex-end; }
[lang="he"] .copy-bubble  { right: auto; left: 0; }
[lang="he"] .copy-bubble::after { right: auto; left: 8px; }
