/* ============================================
   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); }
.clone-acc-info { min-width: 0; line-height: 1.25; }
.clone-acc-nm {
  font-size: 13px; font-weight: 700; color: var(--text);
  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; color: var(--text-mut);
  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; }

.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; }

/* 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; }
