/* ===== Prototype layouts (trong app chính) =====
   Dùng chung theme/.output/.progress-step/.modal của style.css.
   File này chỉ thêm: khung 2 layout của view-chat + detail kiểu FEED (Prototype B).
   Classic ("Giải bài tập") KHÔNG bị đụng — vẫn dùng .thread/.composer như cũ. */

/* 2 layout của view-chat, toggle bằng JS (applyLayout) */
.chat-layout { display: flex; flex: 1 1 0; min-height: 0; flex-direction: column; }

/* nav Prototype trong sidebar */
.proto-nav { display: flex; flex-direction: column; gap: 2px; }

/* ========== FEED detail (Prototype B) ========== */
.fd-feed {
  flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.fd-post, .fd-empty { max-width: 620px; margin: 0 auto; width: 100%; }
.fd-post { padding: 14px 16px 32px; }

.fd-empty { text-align: center; padding: 56px 24px; color: var(--text-soft); }
.fd-empty-icon { font-size: 40px; margin-bottom: 12px; }
.fd-empty-title { font-weight: 700; font-size: 16px; color: var(--text); margin: 0 0 4px; }
.fd-empty-sub { font-size: 13px; margin: 0 0 18px; }
.fd-empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
/* CTA dịu (không chói, hợp cả dark mode): nền accent-soft + chữ accent + viền mảnh */
.fd-empty-cta { margin-top: 16px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border); padding: 11px 22px; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fd-empty-cta:hover { border-color: var(--accent); }

.fd-post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fd-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #f97362 0%, #b3261e 100%);
  color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.fd-post-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--text-soft); }
.fd-post-name { font-weight: 700; color: var(--text); }
.fd-post-more { margin-left: auto; background: none; border: none; color: var(--text-soft); font-size: 18px; cursor: default; padding: 4px; }

.fd-post-title { font-size: 22px; font-weight: 800; margin: 4px 0 12px; line-height: 1.3; }
.fd-post-image-wrap { margin-bottom: 8px; }
.fd-post-image {
  width: 100%; max-height: 70vh; object-fit: contain; cursor: zoom-in;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.fd-post-image:hover { opacity: .95; }

/* Tabs dock dưới topbar khi cuộn */
.fd-dock-sentinel { height: 1px; }
.fd-tabs {
  position: sticky; top: 0; z-index: 6;
  display: flex; gap: 8px; padding: 8px 16px; margin: 0 -16px 4px;
  background: var(--bg); transition: box-shadow .15s ease, border-color .15s ease; border-bottom: 1px solid transparent;
}
.fd-tabs.docked { box-shadow: 0 4px 10px rgba(0, 0, 0, .07); border-bottom-color: var(--border); }
.fd-tab {
  flex: 0 0 auto; cursor: pointer; font-weight: 600; font-size: 13px; padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  display: inline-flex; align-items: center; gap: 5px;
}
.fd-tab:hover { border-color: var(--accent); }
.fd-tab.active { color: #fff; border-color: transparent; }
.fd-tab.active[data-mode="auto"] { background: var(--accent); }
.fd-tab.active[data-mode="hieusau"] { background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); }
.fd-tab .fd-spark { color: #f5b301; }
.fd-tab.active .fd-spark { color: #ffe08a; }
.fd-tab:disabled { opacity: .55; cursor: not-allowed; }

.fd-answer-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-soft); margin: 14px 0 10px; }
.fd-answer-h {
  width: 22px; height: 22px; border-radius: 50%; font-size: 12px;
  background: linear-gradient(135deg, #4ed4f8 0%, #16a34a 100%);
  color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.fd-answer { display: flex; flex-direction: column; gap: 12px; }
.fd-answer .user-bubble { align-self: flex-end; }
.fd-answer-placeholder { color: var(--text-soft); font-size: 14px; padding: 8px 0; }
.fd-answer-error { color: #dc2626; font-weight: 600; }
/* Câu trả lời FLAT: bỏ khung card của .output (nền/viền/bo/padding). Classic vẫn giữ card. */
.fd-answer .output { background: transparent; border: none; border-radius: 0; padding: 0; }

/* Footer cuối câu trả lời */
.fd-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.fd-foot-note { font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.fd-foot-actions { display: flex; align-items: center; justify-content: space-between; }
.fd-foot-left, .fd-foot-right { display: flex; gap: 2px; }
.fd-foot-btn { background: none; border: none; cursor: pointer; color: var(--text-soft); width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.fd-foot-btn:hover { background: var(--surface-2); color: var(--text); }
.fd-foot-btn.on { color: var(--green); }
.fd-foot-btn svg { width: 19px; height: 19px; display: block; }

/* Toast nhỏ (copy / demo action) */
.fd-toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%) translateY(8px); z-index: 700; background: rgba(20, 24, 30, .92); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
.fd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Nút "Lưu bài" pill (Prototype B) */
.fd-bookmark-pill {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 22px; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
  color: var(--text);
}
.fd-bookmark-pill svg { width: 16px; height: 16px; flex-shrink: 0; }
.fd-bookmark-pill:hover:not(:disabled) { background: var(--border); }
.fd-bookmark-pill:disabled { opacity: 0.45; cursor: not-allowed; }
.fd-bookmark-pill.on { color: var(--green); border-color: var(--green); }
.fd-bookmark-pill.on svg { fill: var(--green); stroke: var(--green); }

/* ===== Action Bar (Prototype B) ===== */
.action-bar {
  max-width: 620px; margin: 0 auto 6px;
  display: flex; align-items: center; gap: 5px;
  overflow-x: auto; padding: 2px 0;
  scrollbar-width: none;
}
.action-bar::-webkit-scrollbar { display: none; }
.act-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 11px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 12px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: background .12s, color .12s, border-color .12s;
}
.act-btn:hover { background: var(--border); }
.act-btn.on { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.act-sep { flex-shrink: 0; width: 1px; height: 14px; background: var(--border); margin: 0 2px; align-self: center; }

/* Action popup panels */
.act-popup-panel {
  max-width: 620px; margin: 0 auto 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.ap-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ap-title { font-size: 13px; font-weight: 700; }
.ap-close {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text-soft);
  cursor: pointer; font-size: 11px; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-row { display: flex; align-items: center; gap: 8px; }
.ap-row + .ap-row { margin-top: 8px; }
.ap-label { font-size: 12px; color: var(--text-soft); flex-shrink: 0; min-width: 60px; }
.ap-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.ap-chip {
  padding: 4px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 12px; font-family: inherit; cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
}
.ap-chip.active { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.ap-lang-row { display: flex; align-items: center; gap: 8px; flex: 1; }
.ap-select {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  padding: 5px 8px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.ap-arrow { color: var(--text-soft); font-size: 14px; flex-shrink: 0; }
.ap-haylm-body { display: flex; align-items: center; gap: 10px; }
.ap-haylm-icon { font-size: 22px; flex-shrink: 0; }
.ap-haylm-text { font-size: 13px; color: var(--text); line-height: 1.4; }

/* Value-add per câu (Prototype B): đề thi/đề ôn + video */
.fd-res-wrap { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.fd-res-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.fd-res-list { display: flex; flex-direction: column; gap: 8px; }
.fd-res-card { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer; background: var(--surface); text-decoration: none; color: inherit; }
.fd-res-card:hover { border-color: var(--accent); }
.fd-res-thumb { flex: 0 0 auto; width: 40px; height: 52px; border-radius: 6px; background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1d4ed8; font-weight: 800; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.fd-res-thumb.vid { width: 64px; height: 40px; background: linear-gradient(135deg, #fde68a, #fca5a5); color: #7c2d12; font-size: 16px; }
.fd-res-body { flex: 1; min-width: 0; }
.fd-res-name { font-size: 13.5px; font-weight: 600; line-height: 1.35; margin-bottom: 5px; }
.fd-res-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.fd-chip { font-size: 11px; color: var(--text-soft); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.fd-chip:first-child { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

/* Video: scroll ngang, thumb lớn + ảnh preview */
.fd-vid-scroller { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.fd-vid-scroller::-webkit-scrollbar { height: 0; }
.fd-vid-card { flex: 0 0 240px; max-width: 240px; text-decoration: none; color: inherit; cursor: pointer; }
.fd-vid-thumb {
  position: relative; width: 240px; height: 135px; border-radius: 12px; overflow: hidden;
  background-size: cover; background-position: center; background-color: var(--surface-2);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
}
.fd-vid-thumb.noimg { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.fd-vid-play { width: 46px; height: 46px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.fd-vid-src { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .6); padding: 2px 8px; border-radius: 6px; }
.fd-vid-name { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.fd-bottom { flex-shrink: 0; padding: 10px 12px 14px; background: var(--bg); border-top: 1px solid var(--border); }
.fd-compose-thumb {
  max-width: 620px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px;
}
.fd-compose-thumb img { max-height: 56px; border-radius: 6px; border: 1px solid var(--border); }
.fd-thumb-info { flex: 1; font-size: 12px; color: var(--text-soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fd-thumb-x { flex-shrink: 0; background: rgba(0,0,0,.55); color: #fff; border: none; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 11px; }
.fd-bottom-row { max-width: 620px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.fd-bottom-row .fd-bottom-box { flex: 1; max-width: none; margin: 0; }
.fd-bottom-box {
  max-width: 620px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 6px 8px 6px 8px; box-shadow: var(--shadow);
}
.fd-attach {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
}
.fd-attach:hover { background: var(--border); }
.fd-attach svg { width: 18px; height: 18px; display: block; }
.fd-bottom-input {
  flex: 1; min-width: 0; border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 16px; line-height: 1.5; color: var(--text); max-height: 120px; padding: 6px 0;
}
.fd-bottom-input::placeholder { color: var(--text-soft); }
.fd-counter { font-size: 11px; color: var(--text-soft); font-weight: 600; align-self: center; }
.fd-counter.warn { color: #b45309; }
.fd-send { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; background: var(--green); color: #fff; font-size: 18px; font-weight: 700; }
.fd-send:disabled { background: var(--surface-2); color: var(--text-soft); cursor: not-allowed; }

.fd-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; }
.fd-ghost:hover { border-color: var(--accent); }

/* ===== Prototype B — hàng tab số câu + subtab ===== */
.cau-bar {
  position: sticky; top: 0; z-index: 6;
  background: var(--bg); margin: 0 -16px; padding: 0 16px;
  transition: box-shadow .15s ease, border-color .15s ease; border-bottom: 1px solid transparent;
}
.cau-bar.docked { box-shadow: 0 4px 10px rgba(0, 0, 0, .07); border-bottom-color: var(--border); }
.cau-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 6px; -webkit-overflow-scrolling: touch; }
.cau-tabs::-webkit-scrollbar { height: 0; }
.cau-tab {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cau-tab:hover { border-color: var(--accent); }
.cau-tab.active { background: var(--green); color: #fff; border-color: transparent; }
.cau-tab:disabled { opacity: .55; cursor: not-allowed; }
.cau-detecting { font-size: 13px; color: var(--text-soft); padding: 12px 0; }
.fd-subtabs { display: flex; gap: 8px; padding: 2px 0 10px; }

@media (min-width: 769px) { .fd-post-image { max-height: 56vh; } }
