/* ============================================
   bm-clone.css — Override nhỏ cho trang Clone.
   Phần lớn style đã có sẵn trong css/app.css (table, top, panel, btn, util)
   ============================================ */

/* Ép full-width khi embed iframe — bỏ min-width 1100px của .app, đặt body/.app stretch hết */
html.bm-embedded, html.bm-embedded body {
  width: 100%; height: 100%;
  margin: 0; padding: 0;
  overflow: hidden;
}
html.bm-embedded .app {
  width: 100%; min-width: 0;
  height: 100vh;
}
html.bm-embedded .sidebar { display: none !important; }
html.bm-embedded .main { width: 100%; }

/* Search trong topbar — flex grow đầy khoảng trống, đẩy cụm nút phải ra sát mép.
   Bỏ max-width để search co giãn theo bề ngang (responsive). */
.top .search { flex: 1 1 auto; min-width: 160px; }

/* (clone-count-pill ở topbar đã bỏ — count nằm trong tbl-stats footer) */

/* Active state cho util — viền trái xanh + nền xanh nhạt */
.util.active {
  border-left: 3px solid var(--accent) !important;
  background: rgba(79,70,229,0.06) !important;
  padding-left: 13px !important;
}
[data-theme="dark"] .util.active { background: rgba(79,70,229,0.12) !important; }

/* Empty state — overlay tuyệt đối ở giữa .tbl-area khi list rỗng */
.tbl-area { position: relative; }
.clone-empty[style*="display: none"] { display: none !important; }
.clone-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 32px 28px; text-align: center;
  color: var(--text-sec);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.clone-empty:not([style*="display: none"]) { display: flex; }
.clone-empty-ic {
  width: 72px; height: 72px;
  background: var(--bg-soft);
  color: var(--text-mut);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.clone-empty-title { font-size: 16px; font-weight: 700; color: var(--text); }
.clone-empty-desc { font-size: 13px; max-width: 480px; line-height: 1.5; }

/* Status pill — clone uses */
.clone-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.clone-pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.clone-pill-ok   { background: rgba(34,197,94,0.10);  color: #16a34a; }
.clone-pill-warn { background: rgba(245,158,11,0.10); color: #d97706; }
.clone-pill-err  { background: rgba(239,68,68,0.10);  color: #dc2626; }
.clone-pill-idle { background: var(--bg-soft);        color: var(--text-mut); }
[data-theme="dark"] .clone-pill-ok   { color: #4ade80; }
[data-theme="dark"] .clone-pill-warn { color: #fbbf24; }
[data-theme="dark"] .clone-pill-err  { color: #f87171; }

/* Account cell (avatar + tên + uid) */
.clone-acc { display: flex; align-items: center; gap: 10px; min-width: 0; }
.clone-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-2);
  color: #fff; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--border);
}
.clone-av-text { background: var(--accent); }
/* Avatar + badge nền tảng (FB/IG) ở góc dưới phải */
.clone-av-wrap { position: relative; flex-shrink: 0; display: inline-flex; }
.clone-plat {
  position: absolute; right: -2px; bottom: -2px;
  width: 15px; height: 15px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.clone-plat svg { width: 9px; height: 9px; display: block; }
.clone-plat-fb { background: #1877F2; }
.clone-plat-ig { background: radial-gradient(circle at 30% 110%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }

/* Clone: panel phải chỉ còn thẻ tài khoản (đã gỡ 4 chức năng) → co vừa thẻ CẢ NGANG LẪN DỌC
   để bảng giãn chiếm phần còn lại (không chừa cột trống 390px) */
.panel-compact {
  align-self: flex-start;
  flex: 0 0 auto;
  width: auto; min-width: 260px;
  height: auto;
  border-bottom: 0.5px solid rgba(79,70,229,0.12);
  border-bottom-left-radius: 14px;
  overflow: hidden;
}
.panel-compact .panel-fb { border-bottom: none; }

/* Marquee nhắc cập nhật tiện ích — chạy phải→trái, KHÔNG viền, chữ sáng nổi bật (header nền xanh đậm) */
.ext-marquee {
  position: relative; overflow: hidden;
  flex: 0 1 560px; min-width: 240px; max-width: 620px; height: 28px;
  background: transparent; border: none; cursor: pointer; padding: 0;
}
.ext-marquee-track {
  position: absolute; top: 50%; white-space: nowrap;
  font-size: 13.5px; font-weight: 800; color: #fde047; letter-spacing: 0.2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
  transform: translateY(-50%);
  animation: ext-marquee-run 13s linear 2;  /* chậm hơn + chạy 2 vòng mỗi đợt */
}
@keyframes ext-marquee-run { from { left: 100%; } to { left: -100%; } }

/* Chấm đỏ nhấp nháy — icon "Cài đặt Extension" khi tiện ích cũ */
.ext-dot {
  position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: #ef4444; box-shadow: 0 0 0 2px var(--card, #fff);
  animation: ext-dot-blink 1s ease-in-out infinite;
}
@keyframes ext-dot-blink { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.25; transform: scale(0.7); } }

/* Modal Import clone — đồng bộ theme tool */
.ic-modal {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  width: min(580px, 92vw); padding: 18px 20px 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.32);
}
.ic-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ic-title { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -0.2px; }
.ic-x { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--text-mut); cursor: pointer; padding: 0 2px; border-radius: 6px; }
.ic-x:hover { color: var(--text); background: var(--bg); }
.ic-hint { font-size: 12.5px; color: var(--text-mut); margin: 0 0 10px; line-height: 1.5; }
.ic-hint code { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.ic-ta {
  width: 100%; box-sizing: border-box;
  height: 200px; resize: vertical;
  padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.6;
  outline: none;
  white-space: pre; overflow: auto;   /* mỗi acc 1 dòng — KHÔNG wrap, cuộn ngang */
}
.ic-ta:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ic-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ic-count { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-mut); }
.ic-count b { color: var(--text); font-size: 13px; }
.ic-file { font-size: 12.5px; color: var(--accent); font-weight: 600; cursor: pointer; }
.ic-actions { margin-left: auto; display: flex; gap: 8px; }
.clone-acc-info { min-width: 0; line-height: 1.25; }
.clone-acc-nm {
  font-size: 13px; font-weight: 600; color: var(--name-accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
  letter-spacing: -0.1px;
}
.clone-acc-uid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 400; color: var(--label3);
  margin-top: 1px;
}

/* Row state */
.tbl-wrap tbody tr.is-active { background: rgba(52,199,89,0.08); }
[data-theme="dark"] .tbl-wrap tbody tr.is-active { background: rgba(52,199,89,0.12); }
.tbl-wrap tbody tr.is-loading {
  opacity: 0.6; pointer-events: none;
  background: linear-gradient(90deg, var(--hover), var(--active), var(--hover));
  background-size: 200% 100%;
  animation: cloneShimmer 1.2s linear infinite;
}
@keyframes cloneShimmer { from { background-position: 0% 0; } to { background-position: -200% 0; } }

/* Action buttons in last cell */
.clone-row-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.clone-btn-switch {
  height: 28px; padding: 0 11px;
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(79,70,229,0.30);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.clone-btn-switch:hover { background: var(--accent-2); box-shadow: 0 2px 6px rgba(79,70,229,0.40); }
.clone-btn-switch:active { transform: scale(0.97); }
.clone-btn-switch:disabled { background: var(--text-mut); box-shadow: none; opacity: 0.6; cursor: not-allowed; }
/* Khi đang chuyển — vẫn giữ màu xanh (không xám như disabled) để thấy rõ đang chạy */
.clone-btn-switch:disabled:has(.clone-spin) { background: var(--accent); opacity: 0.85; cursor: wait; }
.clone-spin { animation: clone-spin 0.7s linear infinite; transform-origin: center; }
@keyframes clone-spin { to { transform: rotate(360deg); } }

.clone-btn-rm {
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-mut);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
tbody tr:hover .clone-btn-rm { opacity: 1; }
.clone-btn-rm:hover { background: rgba(239,68,68,0.10); color: #ef4444; }

/* Ghi chú — sửa inline */
.clone-note-view { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.clone-note-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clone-note-edit {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  border: none; background: transparent; color: var(--text-mut);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0.45;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
tbody tr:hover .clone-note-edit { opacity: 1; }
.clone-note-edit:hover { background: rgba(79,70,229,0.10); color: var(--accent); }
.clone-note-input {
  width: 100%; height: 28px; padding: 0 8px;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--card); color: var(--text);
  font-family: inherit; font-size: 12px; outline: none;
}

/* Logout button — chỉ hiện ở row đang active */
.clone-btn-logout {
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-sec);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 1;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.clone-btn-logout:hover { background: rgba(239,68,68,0.10); color: #ef4444; }
.clone-btn-logout:active { transform: scale(0.92); }

/* Helper text classes — unify size 13px + cùng màu var(--text) */
.tbl-wrap td,
.tbl-wrap td.mono,
.tbl-wrap td.small,
.tbl-wrap td .muted {
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}
.tbl-wrap td.mono  { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.tbl-wrap td.tabnum { font-variant-numeric: tabular-nums; }
.tbl-wrap td .text-err  { color: #ef4444; font-weight: 600; }
.tbl-wrap td .text-warn { color: #f59e0b; }
/* Account name vẫn giữ riêng (bold) — đã set ở .clone-acc-nm */
/* UID dưới tên account vẫn giữ mono nhỏ — đã set ở .clone-acc-uid */

/* ===== Swap menu — mini modal chuyển clone nhanh ===== */
.clone-swap-overlay {
  position: fixed; inset: 0; z-index: 4500;
  background: rgba(15,23,42,0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: cloneConfirmFade 0.18s ease-out;
}
[data-theme="dark"] .clone-swap-overlay { background: rgba(0,0,0,0.55); }
.clone-swap-box {
  position: relative;
  width: 440px; max-width: 92vw; max-height: 80vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  padding: 22px 20px 18px;
  animation: cloneConfirmSlide 0.22s cubic-bezier(0.32,0.72,0.32,1);
}
.clone-swap-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--hover); border: none;
  color: var(--text-sec);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.clone-swap-close:hover { background: var(--bg-2); color: var(--text); }
.clone-swap-title {
  font-size: 15px; font-weight: 700;
  color: var(--text); letter-spacing: -0.2px;
  margin: 4px 0 14px;
}
.clone-swap-search {
  width: 100%; box-sizing: border-box;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit; font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 12px;
}
.clone-swap-search::placeholder { color: var(--text-mut); }
.clone-swap-search:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.clone-swap-list {
  flex: 1 1 auto; min-height: 60px; max-height: 380px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.clone-swap-empty {
  text-align: center; padding: 24px 12px;
  color: var(--text-mut); font-size: 13px;
}
.clone-swap-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  transition: background 0.15s;
}
.clone-swap-item:hover { background: var(--hover); }
.clone-swap-item.is-active { background: rgba(52,199,89,0.08); }
.clone-swap-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-2); color: #fff;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--border);
}
.clone-swap-av-text { background: var(--accent); }
.clone-swap-info { flex: 1; min-width: 0; line-height: 1.25; }
.clone-swap-nm {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
  letter-spacing: -0.1px;
}
.clone-swap-uid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-mut);
  margin-top: 1px;
}

/* Confirm modal */
.clone-confirm-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: cloneConfirmFade 0.18s ease-out;
}
@keyframes cloneConfirmFade { from { opacity: 0; } to { opacity: 1; } }
[data-theme="dark"] .clone-confirm-overlay { background: rgba(0,0,0,0.6); }
.clone-confirm-box {
  width: 420px; max-width: 92vw;
  background: var(--bg);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px 22px;
  text-align: center;
  animation: cloneConfirmSlide 0.22s cubic-bezier(0.32,0.72,0.32,1);
}
@keyframes cloneConfirmSlide { from { transform: translateY(10px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.clone-confirm-ic {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: rgba(79,70,229,0.10);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.clone-confirm-box.is-danger .clone-confirm-ic {
  background: rgba(239,68,68,0.10);
  color: #ef4444;
}
.clone-confirm-title {
  font-size: 16px; font-weight: 700;
  color: var(--text); letter-spacing: -0.2px;
  margin-bottom: 8px;
}
.clone-confirm-msg {
  font-size: 13px; line-height: 1.5;
  color: var(--text-sec);
  margin-bottom: 20px;
}
.clone-confirm-actions {
  display: flex; gap: 10px; justify-content: center;
}
.clone-confirm-btn {
  flex: 1;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.clone-confirm-btn:hover { background: var(--bg-2); }
.clone-confirm-btn:active { transform: scale(0.97); }
.clone-confirm-ok {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(79,70,229,0.30);
}
.clone-confirm-ok:hover { background: var(--accent-2); border-color: var(--accent-2); }
.clone-confirm-ok-danger {
  background: #ef4444; border-color: #ef4444;
  box-shadow: 0 1px 3px rgba(239,68,68,0.30);
}
.clone-confirm-ok-danger:hover { background: #dc2626; border-color: #dc2626; }

/* Toast */
.clone-toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 3000; max-width: 80vw;
  background: var(--text); color: var(--bg);
}
.clone-toast.show { opacity: 1; transform: translate(-50%, 0); }
.clone-toast-success { background: #16a34a; color: #fff; }
.clone-toast-error   { background: #dc2626; color: #fff; }
.clone-toast-warn    { background: #f59e0b; color: #fff; }

/* Stats colors */
.ts-live .ts-dot   { background: #22c55e; }
.ts-dead .ts-dot   { background: #ef4444; }
.ts-selected .ts-dot { background: #8b5cf6; }
