/* ════════════════════════════════════════
   AI CREATE — redesigned UX
════════════════════════════════════════ */

/* ── Card wrap ────────────────────────── */
.ai-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

/* ── Hero: topic input ────────────────── */
.ai-topic-group  { margin-bottom: 14px; }
.ai-topic-label  { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.ai-topic-hint   { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); text-transform: none; letter-spacing: 0; opacity: 0.8; }
.ai-dup-hint     { font-size: 0.78rem; font-weight: 600; color: #92400E; background: #FEF3C7; border: 1px solid #FDE68A; border-radius: 6px; padding: 6px 10px; margin-top: 6px; line-height: 1.4; }
.ai-topic-input  {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; color: var(--text);
  background: var(--bg); outline: none; box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-topic-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
  background: var(--surface);
}
.ai-topic-foot {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  margin-top: 8px;
}
.ai-char-count { font-size: 0.71rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; padding-top: 2px; }

/* Example topic chips */
.ai-topic-chips { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }

/* ── Settings grid ────────────────────── */
.ai-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.ai-settings-grid .modal-label { margin-bottom: 4px; }

/* Count pills */
.ai-count-pills { display: flex; gap: 5px; }

/* ── Deck picker ──────────────────────── */
.ai-deck-group { margin-bottom: 12px; }
.ai-deck-group .modal-label { margin-bottom: 4px; }

/* ── Add-to-existing banner ───────────── */
.ai-add-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--purple-light);
  border: 1.5px solid var(--purple);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.aab-icon  { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }
.aab-body  { min-width: 0; }
.aab-title { font-size: 0.92rem; font-weight: 700; color: var(--purple-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aab-meta  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Detail requirements ──────────────── */
.ai-desc-group { margin-bottom: 14px; }
.ai-desc-optional { font-weight: 400; opacity: 0.65; }
.ai-desc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 8px; }
.ai-textarea {
  width: 100%; min-height: 60px; margin-top: 8px;
  padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.88rem;
  font-family: inherit; resize: vertical; outline: none;
  transition: border-color 0.2s; box-sizing: border-box;
  color: var(--text); background: var(--bg);
}
.ai-textarea:focus { border-color: var(--purple); }

/* ── Generate CTA ─────────────────────── */
.btn-ai-generate {
  width: 100%; padding: 12px; border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--purple-d), #38BDF8);
  color: #fff; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.2s, transform 0.15s;
}
.btn-ai-generate:hover { opacity: 0.9; transform: translateY(-1px); }
.btn--loading { opacity: 0.65; pointer-events: none; transform: none !important; }
.btn--copied  {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  transform: none !important;
}
.ai-privacy-note { font-size: 0.71rem; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* ── Result area ──────────────────────── */
.ai-result-area { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.ai-result-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.ai-result-title {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.btn-ai-paste {
  flex-shrink: 0; border: 1.5px solid var(--border); background: none;
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--text-muted); white-space: nowrap;
  transition: all 0.18s;
}
.btn-ai-paste:hover { border-color: var(--purple); color: var(--purple); background: #E0F2FE; }
.dark-mode .btn-ai-paste:hover { background: #312e81; }
.ai-result-area .import-textarea { height: 90px; margin-bottom: 10px; }
.ai-import-btn { width: 100%; }

/* ── Tablet ≥ 640px: 2-column, Desktop ≥ 1024px: 4-column ── */
@media (min-width: 640px) {
  .ai-settings-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (min-width: 1024px) {
  .ai-settings-grid { grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; }
}

/* ── Scope banner ── */
.scope-banner {
  margin-top: 14px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.86rem;
}
.scope-banner.scope-banner--warn      { background: #fff8e6; border-color: #fde68a; color: #92400e; }
.scope-banner.scope-banner--exhausted { background: #fff1f0; border-color: #fecaca; color: #991b1b; }

.scope-banner-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.92rem;
}
.scope-banner-icon  { font-size: 1.1rem; }
.scope-banner-close {
  margin-left: auto; border: none; background: none; cursor: pointer;
  font-size: 1rem; color: inherit; opacity: 0.6; padding: 0 4px; line-height: 1;
}
.scope-banner-close:hover { opacity: 1; }

.scope-banner-stats  { margin-top: 6px; font-size: 0.78rem; opacity: 0.85; }
.scope-banner-reason { margin-top: 6px; line-height: 1.4; }

.scope-sug-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 10px;
}
.scope-sug-label { font-size: 0.78rem; font-weight: 600; opacity: 0.85; margin-right: 4px; }
.scope-sug-chip {
  border: 1.5px solid currentColor;
  background: rgba(255,255,255,0.5);
  border-radius: 50px; padding: 4px 12px;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer; font-family: inherit; color: inherit;
  transition: background 0.15s;
}
.scope-sug-chip:hover { background: rgba(255,255,255,0.9); }

/* ── Dupe review banner ── */
.dupe-banner {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.86rem;
}
.dupe-head { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }
.dupe-head-icon { font-size: 1.1rem; }
.dupe-close {
  margin-left: auto; border: none; background: none; cursor: pointer;
  font-size: 1rem; color: inherit; opacity: 0.6; padding: 0 4px; line-height: 1;
}
.dupe-close:hover { opacity: 1; }
.dupe-hint { margin-top: 4px; font-size: 0.78rem; opacity: 0.8; }
.dupe-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.dupe-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: rgba(255,255,255,0.6);
  border-radius: 8px;
}
.dupe-row-info { flex: 1; min-width: 0; }
.dupe-pair { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.86rem; }
.dupe-new   { font-weight: 700; color: #1e1b4b; }
.dupe-arrow { opacity: 0.5; }
.dupe-old   { font-weight: 600; }
.dupe-where { font-size: 0.74rem; opacity: 0.7; }
.dupe-meanings  { margin-top: 2px; font-size: 0.78rem; opacity: 0.8; }
.dupe-old-vi    { opacity: 0.7; }
.dupe-add-btn {
  border: 1.5px solid #4f46e5; background: #4f46e5; color: #fff;
  border-radius: 50px; padding: 4px 12px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: opacity 0.15s;
}
.dupe-add-btn:hover { opacity: 0.85; }

/* ── Auto-attention pulse (scroll + glow) ── */
@keyframes alertPulse {
  0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55); }
  60%  { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0);  }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);     }
}
.alert-pulse {
  animation: alertPulse 1.4s ease-out 1;
}
.scope-banner.alert-pulse.scope-banner--exhausted {
  animation-name: alertPulseRed;
}
@keyframes alertPulseRed {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  60%  { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);  }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);     }
}

/* ── Deck tip (hint khi deck dày) ── */
.ai-deck-tip {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #92400e;
  line-height: 1.45;
}
.ai-deck-tip b { font-weight: 700; }

/* ── Conflict banner ──────────────────── */
.conflict-banner { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.conflict-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 500; line-height: 1.5;
}
.conflict-item--hard {
  background: #FEF2F2; border: 1.5px solid #FCA5A5; color: #991B1B;
}
.conflict-item--soft {
  background: #FFFBEB; border: 1.5px solid #FDE68A; color: #92400E;
}
.conflict-icon { flex-shrink: 0; font-size: 1rem; line-height: 1.5; }
.conflict-msg  { flex: 1; }
