/* ============================================================
   Video Feedback Tool (dark theme theo ảnh)
   Palette: nền #0d0d12 · card #17171f · vàng #f5c518
            hồng #e91e8c · xanh lá #7ed957 · chữ phụ #8b8b99
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d12;
  --bg-panel: #121218;
  --card: #17171f;
  --card-2: #1e1e28;
  --border: #2a2a36;
  --text: #e8e8ee;
  --muted: #8b8b99;
  --yellow: #f5c518;
  --pink: #e91e8c;
  --green: #7ed957;
  --orange: #f0a030;
  --red: #e05252;
  --blue: #4da3ff;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- banner local ---------- */
.local-banner {
  background: #3a3110;
  color: var(--yellow);
  border-bottom: 1px solid #5a4d1a;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
}

/* ---------- nút chung ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #262633; }
.btn-pink {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
  font-weight: 700;
}
.btn-pink:hover { background: #ff37a3; }
.btn-ghost { background: transparent; }
.btn-dark { background: var(--card-2); }
.btn-toggle.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #14140a;
  font-weight: 700;
}
.link-btn {
  background: none; border: none; color: var(--pink);
  cursor: pointer; font-size: 12px; text-decoration: underline;
}

.inp {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.inp:focus { border-color: var(--pink); }

/* ---------- VIEW: danh sách video ---------- */
.list-view { padding: 24px; max-width: 1100px; margin: 0 auto; width: 100%; }
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.brand { font-size: 18px; font-weight: 800; }
.brand span { color: var(--yellow); letter-spacing: 2px; }
.list-head-actions { display: flex; gap: 8px; align-items: center; }
.trash-hint {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; color: var(--muted);
  font-size: 13px; line-height: 1.6; margin-bottom: 18px;
}
.trash-hint b { color: var(--text); }
.player-reclaimed {
  margin: auto; max-width: 460px; text-align: center;
  color: var(--muted); line-height: 1.7; font-size: 14px; padding: 24px;
}
.player-reclaimed b { color: var(--yellow); }
/* nút sửa/xoá trên comment (icon nhỏ) */
.c-btn.c-edit { color: var(--blue); }
.c-btn.c-delete { color: var(--red); }
.c-btn.c-edit:hover { border-color: var(--blue); }
.c-btn.c-delete:hover { border-color: var(--red); }
.comment.deleted { opacity: .5; }
.comment.deleted .c-body { text-decoration: line-through; }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.video-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.video-card:hover { border-color: var(--yellow); transform: translateY(-2px); }
.video-card .vc-code {
  display: inline-block;
  background: var(--yellow); color: #14140a;
  font-weight: 800; font-size: 12px;
  border-radius: 8px; padding: 2px 8px; margin-bottom: 8px;
}
.video-card .vc-title { font-weight: 600; margin-bottom: 8px; min-height: 34px; }
.video-card .vc-meta { color: var(--muted); font-size: 12px; }
.list-empty { color: var(--muted); text-align: center; margin-top: 60px; }
.archived-bar { text-align: center; margin-top: 24px; }
.video-card { position: relative; }
.video-card.archived { opacity: .6; }
.vc-action {
  position: absolute; top: 10px; right: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 12px;
  padding: 3px 10px; font-size: 11px; cursor: pointer;
}
.vc-action:hover { color: var(--red); border-color: var(--red); }
.vc-action.restore:hover { color: var(--green); border-color: var(--green); }

/* ---------- VIEW: video + feedback ---------- */
.video-view {
  flex: 1;
  display: flex;
  min-height: 0;
  height: calc(100vh - 0px);
}

/* cột trái */
.player-pane {
  flex: 1.4;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #000;
}
.player-top {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.video-meta { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.video-code {
  background: var(--yellow); color: #14140a;
  font-weight: 800; font-size: 12px;
  border-radius: 8px; padding: 2px 8px;
}
.video-title {
  font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.version-select {
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 10px; font-size: 13px; outline: none; cursor: pointer;
}
.video-desc {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
}
.video-desc-text {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 96px;
  overflow-y: auto;
}
.video-desc-text.has-desc { color: var(--text); }
.btn-desc-edit { padding: 3px 10px; font-size: 13px; flex-shrink: 0; }
.modal textarea.inp { resize: vertical; min-height: 80px; }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-status { font-size: 12px; color: var(--muted); }
.vc-desc {
  color: var(--muted); font-size: 12px; line-height: 1.45;
  margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.player-wrap { flex: 1; position: relative; min-height: 0; display: flex; }
.player-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-frame { width: 100%; height: 100%; border: 0; background: #000; }
/* YouTube IFrame API biến #yt-player thành iframe con → ép chiếm đầy khung */
#yt-player iframe { width: 100%; height: 100%; border: 0; }

/* ---------- Dải chia sẻ (đầu AM) ---------- */
.share-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, #2a1520, var(--bg-panel));
  border-bottom: 1px solid var(--border);
}
.share-bar .share-icon { font-size: 18px; flex-shrink: 0; }
.share-bar .share-body { flex: 1; min-width: 0; }
.share-bar .share-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.share-url {
  width: 100%;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-family: var(--mono, monospace);
  outline: none;
}
.share-url:focus { border-color: var(--pink); }
.share-copy { flex-shrink: 0; }

/* ---------- Dải hướng dẫn (đầu PIC) ---------- */
.pic-guide {
  padding: 12px 16px;
  background: #3a1520;
  color: #ffd0e0;
  border-bottom: 1px solid #5a2030;
  font-size: 13px; line-height: 1.6;
}
.pic-guide b { color: #fff; }

/* ---------- Màn PIC (mở qua /f/<slug>) — trơ trụi, giấu đồ nghề của AM ---------- */
body.pic-mode #btn-back,
body.pic-mode #version-select,
body.pic-mode #btn-goc,
body.pic-mode #btn-add-version,
body.pic-mode #btn-copy-link,
body.pic-mode #btn-delete-video,
body.pic-mode #btn-edit-desc,
body.pic-mode #share-bar,        /* dải chia sẻ chỉ dành cho AM */
body.pic-mode .feed-head,        /* thanh "Tiến độ Fix" — chuyện nội bộ AM */
body.pic-mode .feed-tools {      /* nút Xếp Timecode / Ẩn đã Fix — không cần cho PIC */
  display: none !important;
}
/* PIC: cho player-top gọn lại, chỉ còn mã + tên bản */
body.pic-mode .player-top { justify-content: flex-start; }
.pause-cmt {
  position: absolute; right: 14px; bottom: 74px; z-index: 6;
  background: var(--pink); color: #fff;
  border: none; border-radius: 22px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  animation: pause-cmt-in .18s ease-out;
}
.pause-cmt:hover { background: #ff37a3; }
.pause-cmt span { background: rgba(0,0,0,.25); border-radius: 8px; padding: 2px 8px; }
@keyframes pause-cmt-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.drive-notice {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(23, 23, 31, .95);
  border: 1px solid var(--yellow);
  color: var(--yellow);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
.player-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 13, 18, .92);
  color: var(--yellow);
  padding: 24px; text-align: center; font-size: 14px;
}

/* cột phải */
.feed-pane {
  flex: 1;
  max-width: 560px;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  min-height: 0;
}
.feed-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.feed-head-label { color: var(--yellow); font-weight: 800; }
.fix-badge {
  background: #3a1520;
  color: #ff9db0;
  border: 1px solid #5a2030;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
}
.feed-tools {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tool-btn {
  flex: 1;
  background: var(--card);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
}
.tool-btn:last-child { border-right: none; }
.tool-btn:hover { color: var(--text); }
.tool-btn.active { color: var(--yellow); font-weight: 700; background: var(--card-2); }

/* feed comment */
.comments {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comments::-webkit-scrollbar { width: 8px; }
.comments::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.comment {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.comment.pinned { border-color: var(--yellow); }
.comment.reply { margin-left: 26px; background: var(--card-2); }
.comment.fixed { opacity: .65; }
.c-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.c-author { color: var(--green); font-weight: 800; }
.c-time { color: var(--muted); font-size: 12px; }
.c-pin-flag { font-size: 12px; }
.c-tc {
  margin-left: auto;
  background: var(--yellow); color: #14140a;
  font-weight: 800; font-size: 12px;
  border: none; border-radius: 8px;
  padding: 3px 9px; cursor: pointer;
}
.c-tc:hover { background: #ffd84d; }
.c-body { line-height: 1.5; white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.c-like {
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text);
  padding: 3px 10px; font-size: 13px; cursor: pointer; margin-bottom: 8px;
}
.c-like:hover { border-color: var(--pink); }
.c-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.c-btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}
.c-btn:hover { color: var(--text); }
.c-btn.on-pin { color: var(--yellow); border-color: var(--yellow); }
.c-btn.on-approve { color: var(--blue); border-color: var(--blue); font-weight: 700; }
.c-status { margin-left: auto; }
.c-status.st-open { color: var(--muted); }
.c-status.st-fixing { color: var(--orange); border-color: var(--orange); }
.c-status.st-fixed { color: var(--green); border-color: var(--green); }
.comments-empty { color: var(--muted); text-align: center; padding: 40px 16px; }

/* composer */
.composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--bg-panel);
}
.reply-bar {
  font-size: 12px; color: var(--muted);
  padding: 4px 6px 8px;
  display: flex; gap: 6px; align-items: center;
}
.reply-bar b { color: var(--green); }
.range-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.range-label { color: var(--yellow); font-size: 12px; font-weight: 700; }
.inp-tc { width: 230px; padding: 6px 12px; font-size: 12px; }
.brand-mini {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px; font-weight: 800; letter-spacing: 2px;
}
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.inp-name { width: 110px; flex-shrink: 0; }
.inp-body { flex: 1; resize: none; border-radius: 16px; max-height: 120px; }
.composer-error { color: var(--red); font-size: 12px; padding: 6px 4px 0; }

/* ---------- ảnh đính kèm comment ---------- */
.attach-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px 10px;
}
.attach-preview img {
  height: 56px; max-width: 120px;
  border-radius: 8px; border: 1px solid var(--border);
  object-fit: cover;
}
.c-image {
  display: block;
  max-width: 100%; max-height: 200px;
  border-radius: 10px; border: 1px solid var(--border);
  margin-bottom: 8px;
  cursor: zoom-in;
}
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 8px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { font-size: 16px; }
.modal-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal .inp { border-radius: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .video-view { flex-direction: column; height: auto; }
  .player-pane { flex: none; }
  .player-wrap { height: 46vw; min-height: 200px; }
  .feed-pane { max-width: none; min-width: 0; border-left: none; border-top: 1px solid var(--border); }
  .comments { max-height: 55vh; }
}
