/* Bao cao AI, 4 tab cot thong tin, menu chuot phai, tep cho gui, tai them... (bo sung sau). (Tach tu styles.css - nap theo DUNG thu tu trong index.html) */

/* ---------- Tro ly AI: tab Hoi dap / Bao cao + bao cao hang ngay ---------- */
.ai-report-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger); box-shadow: 0 0 0 2px #fff, 0 0 8px rgba(229, 72, 77, .6);
  animation: badge-pop .35s var(--ease);
}
.ai-trigger .ai-report-dot { position: absolute; top: 8px; right: 10px; }
.ai-tabs { display: flex; gap: 4px; padding: 8px 12px 0; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px 10px; border: none; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; border-radius: 9px 9px 0 0; transition: color .2s, background .2s;
}
.ai-tab:hover { color: var(--text); }
.ai-tab.active { color: #5b3fe0; background: var(--surface); }
.ai-tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--ai-grad);
}

.ai-reports-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-reports-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--muted); flex-shrink: 0;
}
.ai-secondary-btn.small-run { padding: 6px 12px; font-size: 12.5px; }
.ai-reports-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(400px 300px at 100% 0%, rgba(124, 92, 255, .06), transparent 70%);
}
.ai-reports-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13.5px; max-width: 320px; }
.ai-reports-empty .ai-empty-orb { font-size: 30px; }
.ai-report-date {
  margin: 6px 2px 0; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.ai-report-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow .2s, border-color .2s;
  animation: msg-in .3s var(--ease);
}
.ai-report-card:hover { border-color: #d9d0ff; }
.ai-report-card.open { box-shadow: 0 8px 22px rgba(124, 92, 255, .12); border-color: #d9d0ff; }
.ai-report-card.is-error { border-color: #f5c2c3; }
.ai-report-card-head {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border: none; background: transparent; text-align: left;
}
.ai-report-account { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ai-new-badge {
  font-size: 10px; font-weight: 700; color: #fff; background: var(--ai-grad); padding: 1px 7px; border-radius: 999px;
}
.ai-report-meta { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.ai-report-card.is-error .ai-report-meta { color: var(--danger); }
.ai-report-chevron { color: var(--muted); font-size: 11px; transition: transform .2s var(--ease); }
.ai-report-card:not(.open) .ai-report-chevron { transform: rotate(-90deg); }
.ai-report-card:not(.open) .ai-report-body { display: none; }
.ai-report-body { max-width: 100%; padding: 2px 16px 12px; border-top: 1px solid var(--border); }
.ai-report-body > :first-child { margin-top: 10px; }
.ai-report-copy { opacity: 1; margin-top: 8px; border: 1px solid var(--border); }

.ai-report-settings {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.ai-report-settings .switch-label { font-size: 13.5px; }
.ai-report-time-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.ai-report-time-label input { padding: 6px 8px; font-size: 13.5px; }
/* The bao cao giu nguyen chieu cao that (khong bi flex co lai + cat noi dung do overflow:hidden) - danh sach se cuon */
.ai-report-card, .ai-report-date { flex-shrink: 0; }

/* Khung trich dan bam duoc -> cuon toi tin goc */
.msg-quote { cursor: pointer; transition: background .15s, filter .15s; }
.msg-quote:hover { background: rgba(0, 104, 255, .12); }
.msg.out .msg-quote:hover { background: rgba(255, 255, 255, .28); }
/* Tin goc vua duoc cuon toi: nhap nhay vien sang 2 lan */
.msg-row.msg-highlight .msg { animation: msg-flash 1.1s ease-in-out 2; }
@keyframes msg-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 184, 0, 0); }
  40% { box-shadow: 0 0 0 4px rgba(255, 184, 0, .75), 0 0 22px rgba(255, 184, 0, .45); }
}

/* ---------- Cot thong tin: 3 tab Anh / Video / File ---------- */
.info-tabs {
  display: flex; gap: 3px; padding: 3px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.info-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 6px; border: none; border-radius: 8px; background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600; transition: background .2s, color .2s, box-shadow .2s;
}
.info-tab:hover { color: var(--text); }
.info-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.info-tab-count {
  min-width: 18px; padding: 0 5px; border-radius: 999px; font-size: 10.5px; line-height: 17px; text-align: center;
  background: var(--border); color: var(--text-2);
}
.info-tab.active .info-tab-count { background: var(--primary-soft); color: var(--primary); }
.info-tab-panel.info-media-grid { margin-top: 0; max-height: 360px; overflow-y: auto; }
.info-tab-panel.info-files-list { margin-top: 0; max-height: 360px; }
.info-tab-empty { grid-column: 1 / -1; padding: 18px 0; text-align: center; color: var(--muted); font-size: 12.5px; list-style: none; }

.info-file-row { gap: 10px !important; padding: 7px 6px !important; }
.info-file-badge {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 800; letter-spacing: .02em; color: #fff; background: #94a3b8;
}
.info-file-badge.kind-pdf { background: linear-gradient(135deg, #f87171, #dc2626); }
.info-file-badge.kind-doc { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.info-file-badge.kind-xls { background: linear-gradient(135deg, #4ade80, #16a34a); }
.info-file-badge.kind-ppt { background: linear-gradient(135deg, #fb923c, #ea580c); }
.info-file-badge.kind-zip { background: linear-gradient(135deg, #facc15, #ca8a04); }
.info-file-badge.kind-audio { background: linear-gradient(135deg, #c084fc, #9333ea); }
.info-file-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.info-file-body a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; font-weight: 500; }
.info-file-date { font-size: 11px; color: var(--muted); }

/* 4 tab trong cot thong tin -> chu nho hon chut cho vua */
.info-tab { padding: 7px 4px; font-size: 12.5px; gap: 4px; }
.info-tab-panel.info-links-list { margin-top: 0; max-height: 360px; }
.info-link-row { gap: 10px !important; padding: 7px 6px !important; }
.info-link-badge {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: var(--primary); background: var(--primary-soft); border: 1px solid var(--primary-soft-2);
}
.info-tab-hint { margin: 8px 0 0; text-align: center; font-size: 11px; color: var(--muted); }
.info-media-cell, .info-file-row, .info-link-row { user-select: none; }

/* ---------- Menu chuot phai ---------- */
.ctx-menu {
  position: fixed; z-index: 300; min-width: 200px; padding: 5px;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: pop-in .14s var(--ease); transform-origin: top left;
}
.ctx-menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: none; border-radius: 8px; background: transparent; color: var(--text);
  font-size: 13.5px; text-align: left; transition: background .12s;
}
.ctx-menu-item:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.ctx-menu-item:disabled { color: var(--muted); cursor: not-allowed; }
.ctx-menu-icon { width: 18px; text-align: center; font-size: 14px; }

/* ---------- Anh vua dan cho gui (xem truoc tren o nhap) ---------- */
.attach-preview-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px 4px;
  background: var(--surface); flex-shrink: 0; animation: pop-in .2s var(--ease);
}
.attach-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 4px; max-width: 70%; }
.attach-thumb {
  position: relative; flex-shrink: 0; width: 72px; height: 72px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); box-shadow: var(--shadow-sm);
  animation: badge-pop .3s var(--ease);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; cursor: zoom-in; display: block; }
.attach-thumb-remove {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--surface); background: #1f2937; color: #fff; font-size: 10px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: background .15s, transform .15s var(--ease);
}
.attach-thumb-remove:hover { background: var(--danger); transform: scale(1.1); }
.attach-hint { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.attach-hint strong { color: var(--primary); font-size: 13px; }
.attach-hint kbd {
  font-family: inherit; font-size: 10.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px;
}

/* Anh dai dien that cua hoi thoai (thay cho chu cai dau ten) */
img.conv-avatar { object-fit: cover; display: block; background: var(--surface-hover); text-shadow: none; }

/* Chu thich gui kem anh/video */
.msg-caption { padding: 6px 8px 2px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg:has(> .msg-video) .msg-caption { padding: 6px 6px 2px; }

/* Tep lon dang gui len Zalo */
.msg-file-pending { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.msg-file-pending strong { display: block; font-size: 13.5px; }
.msg-file-pending small { display: block; font-size: 12px; opacity: .85; }
.msg-file-spinner {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite;
}
.msg.in .msg-file-spinner { border-color: var(--border); border-top-color: var(--primary); }

/* Toast tien trinh tai tep */
.toast-progress { min-width: 300px; cursor: default; border-left-color: var(--primary); }
.toast-progress-text { margin-bottom: 8px; }
.toast-progress-bar { height: 6px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.toast-progress-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width .2s; }

/* Duong ke giua cac nhom lenh trong menu chuot phai */
.ctx-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* O tep (khong phai anh) trong hang cho gui */
.attach-file-tile {
  width: 100%; height: 100%; border-radius: 11px; padding: 6px 4px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden;
}
.attach-file-tile .info-file-badge { width: 30px; height: 30px; font-size: 8.5px; border-radius: 7px; }
.attach-file-name { max-width: 100%; font-size: 10px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-file-size { font-size: 9.5px; color: var(--muted); }

/* Tai them hoi thoai / tin nhan cu khi cuon */
.conversation-list li.conv-load-more {
  justify-content: center; margin: 6px 0 10px; padding: 9px; font-size: 12.5px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft); border-radius: var(--radius);
}
.conversation-list li.conv-load-more:hover { transform: none; background: var(--primary-soft-2); }
.chat-older-indicator {
  align-self: center; margin: 4px 0 8px; padding: 4px 12px; border-radius: 999px;
  font-size: 11.5px; color: var(--text-muted); background: var(--chat-system-bg);
  border: 1px solid var(--border-subtle);
}

/* So phien ban o man hinh dang nhap */
.app-version { margin: 6px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); }

.role-home { display: none !important; }
/* S04 D28 (PO 06/11/2026): staff read and reply on their own Zalo. The composer shows where the viewer may send —
   Admin: everywhere; others: a Zalo they hold (#app-screen[data-can-send="1"], set by s19-chat.js from /api/accounts;
   the server checks again). Before a conversation is open, non-Admin composers stay hidden as before. */
body.role-user #manage-auto-reply-btn,
body.role-manager #manage-auto-reply-btn,
body:not(.role-admin) #app-screen:not([data-can-send="1"]) .chat-toolbar,
body:not(.role-admin) #app-screen:not([data-can-send="1"]) .chat-input-row,
body:not(.role-admin) #app-screen:not([data-can-send="1"]) #reply-preview-row { display: none !important; }
