/* TKGO Bot Control - CSS rieng, khong dung chung voi trang tracker.
   Bang mau lay dung bo bien cua tracker de hai trang nhin cung mot nha. */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(42, 120, 214, 0.10);
  --pos: #2a78d6;
  --neg: #e34948;
  --good-text: #006300;
  --bad-text: #d03b3b;
  --brand: #a8871f;
  --hot: #b25c00;
  --hot-bg: rgba(178, 92, 0, 0.10);
}
:root[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(57, 135, 229, 0.12);
  --pos: #3987e5;
  --neg: #e66767;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --brand: #e6c34c;
  --hot: #fab219;
  --hot-bg: rgba(250, 178, 25, 0.14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-1);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Thanh tren ---- */
.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 36px; height: 36px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.18; }
.logo { font-size: 17px; font-weight: 700; }
.logo span { color: var(--brand); }
.slogan {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}
.theme-btn:hover { background: var(--wash); }
.btn {
  border-radius: 999px;
  padding: 7px 18px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--pos); border-color: var(--pos); color: #fff; }

/* ---- Khung ---- */
.wrap { max-width: 720px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-head { margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 16px; }
.sub { font-size: 12.5px; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

/* ---- Trang thai EA ---- */
.bot-status { display: flex; flex-direction: column; gap: 10px; }
.bot-live { display: flex; align-items: center; gap: 9px; }
.bot-live .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); flex: none;
}
.bot-live .dot.on { background: var(--good-text); box-shadow: 0 0 0 4px rgba(42, 163, 42, 0.18); }
.bot-live .dot.off { background: var(--bad-text); box-shadow: 0 0 0 4px rgba(224, 72, 72, 0.16); }
.bot-live-text { font-weight: 600; font-size: 15px; }
.bot-facts {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 13px; color: var(--text-2);
}
.bot-facts b { color: var(--text-1); }
.bot-pos { display: flex; gap: 8px; flex-wrap: wrap; }
.pos-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-2);
}
.pos-chip.buy { border-color: var(--pos); color: var(--pos); }
.pos-chip.sell { border-color: var(--neg); color: var(--neg); }

/* ---- Bang dieu khien ---- */
.bot-lock {
  display: none;
  padding: 14px 16px; border-radius: 8px;
  background: var(--hot-bg); color: var(--hot); font-size: 13.5px;
}
.bot-fields {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 12px; margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-1);
  font: inherit;
}
.field input:focus { outline: none; border-color: var(--pos); }

.bot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bot-btn {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 18px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--page); color: var(--text-1);
  transition: background 0.12s, color 0.12s;
  /* Nut vao lenh that -> chan trinh duyet hieu 2 lan cham la phong to trang */
  touch-action: manipulation;
}
.bot-btn:disabled { opacity: 0.5; cursor: default; }
.bot-btn.buy { border-color: var(--pos); color: var(--pos); }
.bot-btn.sell { border-color: var(--neg); color: var(--neg); }
.bot-btn.xbuy, .bot-btn.xsell { font-size: 13.5px; padding: 14px 10px; color: var(--text-2); }
.bot-btn.wide { grid-column: 1 / -1; }
/* Hai chieu cung luc: to mau nua xanh nua do de khong lan voi nut mot chieu */
.bot-btn.both {
  border-color: var(--brand); color: var(--brand);
  background: linear-gradient(90deg, var(--wash) 0 50%, transparent 50% 100%);
}
.bot-btn.armed {
  background: var(--hot); border-color: var(--hot);
  color: #fff; font-size: 13.5px;
  animation: bot-pulse 0.9s ease-in-out infinite;
}
@keyframes bot-pulse { 50% { opacity: 0.72; } }
@media (hover: hover) {
  .bot-btn.both:hover { background: var(--brand); color: #fff; }
  .bot-btn.buy:hover { background: var(--pos); color: #fff; }
  .bot-btn.sell:hover { background: var(--neg); color: #fff; }
  .bot-btn.xbuy:hover, .bot-btn.xsell:hover { background: var(--wash); }
  .bot-btn.armed:hover { background: var(--hot); color: #fff; }
}

/* ---- Ket qua lenh vua bam ---- */
.bot-result { margin-top: 14px; min-height: 34px; }
.bot-msg { font-size: 13px; }
.bot-msg.ok { color: var(--good-text); }
.bot-msg.bad { color: var(--bad-text); }
.bot-msg.warn { color: var(--hot); }
.bot-msg.wait { color: var(--text-2); }
.bot-lag {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---- Modal dang nhap ---- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 40;
  padding: 60px 16px;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.form-error { color: var(--bad-text); font-size: 12.5px; margin-right: auto; }

/* ---- Chan trang ---- */
footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.disclaimer { max-width: 620px; margin: 0 auto 8px; }

@media (max-width: 640px) {
  .bot-fields { grid-template-columns: 1fr 1fr; }
  .bot-fields .field:last-child { grid-column: 1 / -1; }
}
