/* ============================================================
   PhucDCH Chart — style dùng lại biến CSS của dashboard
   (--bg-container, --bg-card, --border-stroke, --text-primary,
    --text-secondary, --text-muted, --price-up, --price-down,
    --primary-brand, --radius-sm)
   ============================================================ */

:root { --pdch-h: 460px; }
.pdch-card {
  background: var(--bg-container);
  border: 1px solid var(--border-stroke);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.pdch-card .pdch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-stroke);
  font-size: 12.5px;
}
.pdch-card .pdch-head b { font-weight: 600; color: var(--text-primary); }

.pdch-root { display: flex; flex-direction: column; }

/* ---------- toolbar ---------- */
.pdch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-stroke);
  background: var(--bg-subtle, var(--bg-container));
}
.pdch-sym { display: flex; gap: 4px; }
.pdch-input {
  width: 70px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--bg-container);
  border: 1px solid var(--border-stroke);
  border-radius: var(--radius-sm);
  outline: none;
}
.pdch-input:focus { border-color: var(--primary-brand); }

.pdch-group { display: flex; gap: 3px; flex-wrap: wrap; }
.pdch-btn {
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1.2;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stroke);
  background: var(--bg-container);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pdch-btn:hover { color: var(--text-primary); border-color: var(--primary-brand); }
.pdch-btn.active {
  background: var(--primary-brand);
  border-color: var(--primary-brand);
  color: #fff;
  font-weight: 600;
}
.pdch-btn-primary {
  background: #f97316;
  border-color: #f97316;
  color: #111;
  font-weight: 600;
}
.pdch-btn-primary:hover { background: #ea580c; border-color: #ea580c; color: #111; }
.pdch-spacer { flex: 1 1 auto; }
.pdch-quote { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.pdch-quote b { color: var(--text-primary); margin-right: 4px; }
.pdch-quote .up { color: var(--price-up); font-weight: 600; }
.pdch-quote .down { color: var(--price-down); font-weight: 600; }

/* ---------- body ---------- */
.pdch-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: stretch;
}
.pdch-chartwrap { position: relative; min-width: 0; }
.pdch-chart { width: 100%; height: var(--pdch-h); }
.pdch-status {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; gap: 10px;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  font-size: 13px; color: var(--text-secondary);
  background: var(--bg-container);
}
.pdch-status.is-error { color: var(--price-down); }
.pdch-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border-stroke);
  border-top-color: var(--primary-brand);
  animation: pdchspin .8s linear infinite;
}
@keyframes pdchspin { to { transform: rotate(360deg); } }
.pdch-status .pdch-retry {
  margin-top: 2px; padding: 6px 14px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--border-stroke); border-radius: var(--radius-sm);
  background: var(--bg-container); color: var(--text-primary); cursor: pointer;
}
.pdch-status .pdch-retry:hover { border-color: var(--primary-brand); }

/* ---------- panel phải ---------- */
.pdch-side {
  border-left: 1px solid var(--border-stroke);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* [PhucDCH] khoá đúng bằng chiều cao chart: danh sách dài KHÔNG đẩy khoảng trắng */
  max-height: var(--pdch-h);
  height: var(--pdch-h);
  background: var(--bg-container);
}
.pdch-side-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-stroke);
  font-size: 12px;
  color: var(--text-primary);
}
.pdch-side-head .pdch-sub {
  display: block; font-size: 11px; color: var(--text-secondary); font-weight: 500; margin-top: 1px;
}
.pdch-side-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.pdch-side-foot {
  padding: 6px 9px;
  border-top: 1px solid var(--border-stroke);
  font-size: 10px;
  color: var(--text-muted);
}
.pdch-empty { padding: 18px 12px; text-align: center; font-size: 11.5px; color: var(--text-muted); }

.pdch-row {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; padding: 7px 9px;
  background: transparent; border: 0; border-bottom: 1px solid var(--border-stroke);
  font-family: inherit; text-align: left; cursor: pointer;
}
.pdch-row:hover { background: var(--bg-subtle, rgba(127,127,127,.08)); }
.pdch-row-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.pdch-row-top b { font-size: 13px; font-weight: 700; color: var(--text-primary); letter-spacing: .1px; }
.pdch-row-bot {
  display: flex; justify-content: space-between; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
}
.pdch-row-bot .up { color: var(--price-up); }
.pdch-row-bot .down { color: var(--price-down); }
.pdch-tag {
  font-style: normal; font-size: 10.5px; font-weight: 800;
  padding: 1px 5px; border-radius: 3px; letter-spacing: .3px;
}
.pdch-tag.buy { background: var(--price-up-bg, rgba(34,197,94,.15)); color: var(--price-up); }
.pdch-tag.sell { background: var(--price-down-bg, rgba(239,68,68,.15)); color: var(--price-down); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --pdch-h: 380px; }
  .pdch-body { grid-template-columns: minmax(0, 1fr); }
  .pdch-side { border-left: 0; border-top: 1px solid var(--border-stroke); height: auto; max-height: 320px; }
  .pdch-side-body { max-height: 240px; }
  .pdch-chart { height: var(--pdch-h); }
}
@media (max-width: 620px) {
  .pdch-chart { height: var(--pdch-h); }
  .pdch-input { width: 58px; }
  .pdch-btn { padding: 4px 7px; font-size: 11px; }
  /* [PhucDCH] thanh công cụ chỉ 1 hàng, cuộn ngang thay vì chiếm 3-4 dòng */
  .pdch-toolbar { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 6px 8px; gap: 8px; }
  .pdch-toolbar::-webkit-scrollbar { display: none; }
  .pdch-group { flex-wrap: nowrap !important; flex: 0 0 auto; }
  .pdch-sym { flex: 0 0 auto; }
}
@media (max-width: 992px) {
  /* [PhucDCH] nút Trợ lý AI gọn, không che tab/panel */
  .floating-ai-fab { width: 44px !important; height: 44px !important; padding: 0 !important;
    border-radius: 50% !important; bottom: 12px !important; right: 12px !important; }
}

/* ---------- tabs trong panel + chấm tiêu chí ---------- */
.pdch-tabs { display: flex; gap: 4px; width: 100%; margin-top: 4px; }
.pdch-tabs .pdch-tab { flex: 1 1 0; }
.pdch-tab { font-size: 10.5px; padding: 3px 7px; }
.pdch-dots { display: flex; gap: 2px; margin: 1px 0 2px; }
.pdch-dot {
  display: inline-block; width: 12px; height: 4px; border-radius: 2px;
  background: var(--border-stroke-2, #CBD5E1);
}
.pdch-dot.on { background: var(--price-up); }
.pdch-tag.warn { background: rgba(245,158,11,.18); color: #f59e0b; }

/* [PhucDCH] chọn tham số cho chỉ báo PhucDCH Trading */
.pdch-pt-sel {
  font-size: 11px; padding: 3px 4px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border, #d5d9e0); background: var(--card, #fff);
  color: var(--foreground, #222); font-family: inherit;
}
