/* ==== AI Chat (World Map) ==== */

.ai-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Không dùng backdrop-filter: blur ở đây nữa - overlay phủ toàn màn hình
     và phía sau có animation liên tục (node current pulse), kết hợp lại làm
     trình duyệt phải blur lại backdrop mỗi frame -> gõ chữ trong textarea bị
     giật/đơ. Dùng nền tối đặc hơn thay cho hiệu ứng mờ để giữ responsive. */
  background: rgba(4, 6, 10, 0.88);
}

.ai-chat-panel {
  width: min(680px, 100%);
  max-height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.ai-chat-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.ai-chat-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.ai-chat-subtitle {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 2px;
}

.ai-chat-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px 9px;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.ai-chat-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-chat-footer {
  flex: none;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ai-msg {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.ai-md-heading {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  margin: 14px 0 6px;
}

.ai-md-heading:first-child {
  margin-top: 0;
}

.ai-md-p {
  margin-bottom: 10px;
}

.ai-md-p:last-child {
  margin-bottom: 0;
}

.ai-md-list {
  margin: 4px 0 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-msg code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}

.ai-msg-system {
  color: var(--text-dim);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.ai-msg-onboarding {
  border-color: var(--accent-soft-border);
  background: var(--accent-soft-bg);
  color: var(--text);
}

.ai-btn {
  background: var(--accent-soft-bg);
  border: 1px solid var(--accent-soft-border);
  color: var(--accent);
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    transform 0.12s ease, box-shadow 0.15s ease;
}

/* .ai-btn cũng được dùng trên thẻ <a> (VD nút "Đăng nhập với Google" ở lỗi
   401/402) - reset lại style mặc định của link cho đồng nhất với <button>. */
a.ai-btn,
a.ai-btn-secondary {
  text-decoration: none;
  display: inline-block;
}

.ai-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.ai-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.ai-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text-dim);
}

.ai-btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 8px 0;
}

.ai-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: ai-spin 0.8s linear infinite;
  flex: none;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-mcq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-mcq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.ai-mcq-question {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 10px;
}

.ai-mcq-question strong {
  color: var(--text-faint);
  font-weight: 700;
  margin-right: 6px;
}

.ai-mcq-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-mcq-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-mcq-option:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.ai-mcq-option input {
  accent-color: var(--accent);
}

.ai-mcq-progress {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.ai-confidence-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-confidence-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
}

.ai-confidence-slider {
  width: 100%;
  accent-color: var(--accent);
}

.ai-open-ended-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-open-ended-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.ai-textarea {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ai-textarea:focus {
  outline: none;
  border-color: var(--accent-soft-border);
  background: rgba(255, 255, 255, 0.06);
}

.ai-report {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-result-badge {
  align-self: flex-start;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  padding: 6px 14px;
  border-radius: 999px;
}

.ai-result-badge.pass {
  background: var(--accent-green-soft-bg);
  border: 1px solid var(--accent-green-soft-border);
  color: var(--accent-green);
}

.ai-result-badge.retry {
  background: var(--accent-amber-soft-bg);
  border: 1px solid var(--accent-amber-soft-border);
  color: var(--accent-amber);
}

.ai-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.ai-score-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.ai-score-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.ai-score-label {
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.ai-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.ai-status-dot--red {
  background: #f85149;
  box-shadow: 0 0 5px #f85149;
}

.ai-status-dot--green {
  background: var(--accent-green);
  box-shadow: 0 0 5px var(--accent-green);
}

.ai-feedback-block {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.55;
  border-left: 2px solid var(--accent-soft-border);
  padding-left: 12px;
}

.ai-rubric-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
  font-size: 0.78rem;
}

.ai-rubric-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
}

.ai-rubric-table tr:last-child td {
  border-bottom: none;
}

.ai-rubric-score {
  text-align: right;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.ai-error {
  color: var(--accent-amber);
  font-size: 0.85rem;
  background: var(--accent-amber-soft-bg);
  border: 1px solid var(--accent-amber-soft-border);
  border-radius: 8px;
  padding: 12px 14px;
}
