/* ══════════════════════════════════════════════════════════════
   Hiệu suất các kênh — GSC + GA4 + Facebook
   Tiền tố ch- riêng cho module này
   ══════════════════════════════════════════════════════════════ */

/* ── Thanh công cụ: chọn kỳ + làm mới ─────────────────────────── */
.ch-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.ch-ranges { display: flex; gap: 6px; }
.ch-range-btn {
    padding: 8px 16px; border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid rgba(255,255,255,0.08);
    color: var(--text-muted); cursor: pointer;
    font-size: 13px; font-weight: 600; transition: all 0.15s;
}
.ch-range-btn:hover  { border-color: rgba(99,102,241,0.4); color: #a5b4fc; }
.ch-range-btn.active { background: rgba(99,102,241,0.16); border-color: rgba(99,102,241,0.55); color: #a5b4fc; }

.ch-toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ch-updated {
    font-size: 12px; color: var(--text-muted);
    display: inline-flex; align-items: center; gap: 6px;
}
.ch-updated.stale { color: #fbbf24; }
.ch-age { opacity: 0.65; }
.ch-refresh-btn {
    padding: 8px 14px; border-radius: 8px;
    border: 1px solid rgba(99,102,241,0.3);
    background: rgba(99,102,241,0.1);
    color: #a5b4fc; cursor: pointer;
    font-size: 12.5px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background 0.15s;
}
.ch-refresh-btn:hover:not(:disabled) { background: rgba(99,102,241,0.2); }
.ch-refresh-btn:disabled { opacity: 0.55; cursor: default; }
.ch-spin { animation: ch-rot 0.9s linear infinite; display: inline-block; }
@keyframes ch-rot { to { transform: rotate(360deg); } }

/* ── Tabs ──────────────────────────────────────────────────────── */
.ch-tabs {
    display: flex; gap: 4px; flex-wrap: wrap;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 18px;
}
.ch-tab {
    padding: 11px 18px; background: transparent; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    color: var(--text-muted); cursor: pointer;
    font-size: 13.5px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 7px;
    transition: color 0.15s, border-color 0.15s;
}
.ch-tab:hover  { color: #a5b4fc; }
.ch-tab.active { color: #818cf8; border-bottom-color: #818cf8; }

/* ── Dải kỳ báo cáo ────────────────────────────────────────────── */
.ch-period {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 12px; color: var(--text-muted); margin-bottom: 14px;
}
.ch-period-prev { opacity: 0.7; }
.ch-period-note {
    margin-left: auto; font-size: 11px; color: #64748b;
    background: rgba(255,255,255,0.03); padding: 3px 9px; border-radius: 20px;
}

/* ── KPI ───────────────────────────────────────────────────────── */
.ch-kpi-grid {
    display: grid; gap: 12px; margin-bottom: 18px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.ch-kpi-5 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.ch-kpi {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.07);
    border-top: 3px solid var(--kpi-color, #818cf8);
    border-radius: 10px; padding: 14px 16px;
}
.ch-kpi-label {
    font-size: 12px; color: var(--text-muted); font-weight: 600;
    display: flex; align-items: center; gap: 5px; margin-bottom: 8px;
}
.ch-hint { font-size: 13px; opacity: 0.5; cursor: help; }
.ch-kpi-value {
    font-size: 26px; font-weight: 800; color: var(--kpi-color, #818cf8);
    line-height: 1.1; margin-bottom: 8px; font-variant-numeric: tabular-nums;
}
.ch-kpi-delta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ch-kpi-prev  { font-size: 10.5px; color: #64748b; }
.ch-delta {
    font-size: 11.5px; font-weight: 700; border-radius: 20px;
    padding: 2px 8px; display: inline-flex; align-items: center; gap: 3px;
}
.ch-good { background: rgba(16,185,129,0.14); color: #34d399; }
.ch-bad  { background: rgba(239,68,68,0.14);  color: #f87171; }
.ch-flat { background: rgba(255,255,255,0.05); color: #94a3b8; font-weight: 600; }

/* ── Thẻ nội dung ──────────────────────────────────────────────── */
.ch-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.ch-card-head {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 700; color: var(--text-main);
    margin-bottom: 14px;
}
.ch-card-head i { color: #818cf8; font-size: 17px; }
.ch-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.ch-grid-2 > .ch-card { margin-bottom: 0; }
.ch-grid-2 + .ch-grid-2 { margin-top: 16px; }

/* ── Biểu đồ ───────────────────────────────────────────────────── */
.ch-chart-box { position: relative; height: 230px; }
.ch-chart-tall { height: 300px; }
.ch-chart-sm   { height: 150px; }
.ch-chart-cap  { text-align: center; font-size: 11px; color: #64748b; margin-top: 6px; }

/* ── Bảng ──────────────────────────────────────────────────────── */
.ch-table-wrap { max-height: 380px; overflow-y: auto; overflow-x: auto; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ch-table th {
    position: sticky; top: 0; z-index: 1;
    background: #101a2e; text-align: left;
    padding: 8px 10px; font-size: 11px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ch-table th.r, .ch-table td.r { text-align: right; }
.ch-table td {
    padding: 8px 10px; color: #cbd5e1;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ch-table tbody tr:hover td { background: rgba(99,102,241,0.05); }
.ch-td-main {
    max-width: 260px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.ch-dim   { color: #64748b; }
.ch-green { color: #34d399; }
.ch-amber { color: #fbbf24; }

/* ── Trạng thái ────────────────────────────────────────────────── */
.ch-loading, .ch-empty {
    padding: 44px 20px; text-align: center;
    color: var(--text-muted); font-size: 13.5px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.ch-error {
    display: flex; align-items: flex-start; gap: 16px;
    padding: 26px; border-radius: 12px;
    background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.2);
}
.ch-error > i { font-size: 30px; color: #f87171; }
.ch-error strong { color: #fca5a5; font-size: 14.5px; display: block; margin-bottom: 6px; }
.ch-error p { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.ch-warn {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 11px 15px; border-radius: 9px; margin-bottom: 14px;
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.28);
    font-size: 12.5px; color: #fcd34d; line-height: 1.55;
}
.ch-warn i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.ch-note {
    display: flex; align-items: flex-start; gap: 8px;
    margin-top: 12px; padding: 10px 13px; border-radius: 8px;
    background: rgba(255,255,255,0.03);
    font-size: 12px; color: var(--text-muted); line-height: 1.6;
}
.ch-note-info { background: rgba(56,189,248,0.07); border: 1px solid rgba(56,189,248,0.18); color: #93c5fd; }
.ch-note i { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.ch-note-sm { font-size: 11.5px; color: #64748b; margin-top: 10px; font-style: italic; }

/* ── Facebook: thẻ mini ở tab Tổng quan ────────────────────────── */
.ch-fbmini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; }
.ch-fbmini {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px; padding: 13px 15px;
}
.ch-fbmini-name { font-size: 13px; font-weight: 700; color: #e2e8f0; margin-bottom: 5px; }
.ch-fbmini-fans {
    font-size: 11.5px; color: #f472b6; margin-bottom: 11px;
    display: flex; align-items: center; gap: 5px;
}
.ch-fbmini-rows { display: flex; flex-direction: column; gap: 6px; }
.ch-fbmini-rows > div { display: flex; justify-content: space-between; font-size: 12px; }
.ch-fbmini-rows span { color: var(--text-muted); }
.ch-fbmini-rows b { color: #cbd5e1; font-variant-numeric: tabular-nums; }

/* ── Facebook: chi tiết từng trang ─────────────────────────────── */
.ch-fbpage { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }
.ch-fbfans {
    font-size: 13px; color: #f472b6; margin-bottom: 11px;
    display: flex; align-items: center; gap: 6px;
}
.ch-fbfans b { font-size: 16px; }

.ch-posts { margin-top: 15px; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 13px; }
.ch-posts-head {
    font-size: 12.5px; font-weight: 700; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
.ch-post {
    background: rgba(255,255,255,0.025); border-radius: 8px;
    padding: 10px 13px; margin-bottom: 7px;
}
.ch-post-msg { font-size: 12.5px; color: #cbd5e1; line-height: 1.5; margin-bottom: 7px; }
.ch-post-meta {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 11.5px; color: var(--text-muted);
}
.ch-post-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ch-post-link { color: #818cf8; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.ch-post-link:hover { text-decoration: underline; }

/* ── Toast ─────────────────────────────────────────────────────── */
.ch-toast {
    position: fixed; bottom: 26px; right: 26px; z-index: 9999;
    padding: 13px 19px; border-radius: 10px;
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 9px;
    max-width: 400px; line-height: 1.5;
    opacity: 0; transform: translateY(14px); pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.ch-toast.show { opacity: 1; transform: translateY(0); }
.ch-toast.ok   { background: rgba(16,185,129,0.16); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7; }
.ch-toast.warn { background: rgba(245,158,11,0.16); border: 1px solid rgba(245,158,11,0.4); color: #fcd34d; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .ch-fbpage { grid-template-columns: 1fr; }
    .ch-period-note { margin-left: 0; }
}
@media (max-width: 640px) {
    .ch-toolbar { flex-direction: column; align-items: stretch; }
    .ch-ranges { justify-content: space-between; }
    .ch-range-btn { flex: 1; padding: 9px 6px; font-size: 12px; }
    .ch-toolbar-right { justify-content: space-between; }
    .ch-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .ch-tab { padding: 10px 13px; font-size: 12.5px; white-space: nowrap; }
    .ch-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .ch-kpi { padding: 11px 12px; }
    .ch-kpi-value { font-size: 20px; }
    .ch-kpi-label { font-size: 11px; }
    .ch-grid-2 { grid-template-columns: 1fr; }
    .ch-card { padding: 13px 14px; }
    .ch-chart-box { height: 190px; }
    .ch-td-main { max-width: 140px; }
    .ch-toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}
