/* ================= Đăng bài nhóm Facebook ================= */
.panel {
    background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: 15px; }
.panel-head select { padding: 6px 30px 6px 10px; max-width: 200px; }
.panel > label { gap: 6px; }
.panel select { font-size: 13.5px; }
textarea {
    font: inherit; font-size: 14px; color: var(--text); background: rgba(10,12,17,.6); resize: vertical; min-height: 150px;
    border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 10px 12px; line-height: 1.55;
    transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.22); }
textarea::placeholder { color: #5b6375; }

/* --- tài khoản --- */
.fb-accounts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.fb-accounts:empty { display: none; }
.fb-acc {
    background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.fb-acc:hover { border-color: var(--border-2); }
.fb-acc.active { border-color: rgba(59,130,246,.55); box-shadow: 0 0 0 1px rgba(59,130,246,.35); }
.fb-acc-top { display: flex; gap: 12px; align-items: center; }
.fb-acc .name { font-weight: 650; display: flex; align-items: center; gap: 4px; }
.avatar.fb { background: linear-gradient(135deg, #1877f2, #0a5bd1); color: #fff; font-size: 22px; font-weight: 800; font-family: Georgia, serif; }
.avatar.fb.has-img { background: var(--panel-3); }
.fb-acc .who { min-width: 0; }
.fb-acc .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-acc .meta { align-items: center; }
.fb-acc .note.err { white-space: normal; }

/* --- thêm tài khoản bằng cookie --- */
.howto { margin: 12px 0 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
.howto .steps { margin: 10px 0 4px; }
#fbAddForm textarea { min-height: 110px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
#fbAddForm > label { margin-top: 12px; }
#fbAddForm .note { margin-top: 12px; white-space: normal; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; font-size: 12.5px; }
button.primary.small { padding: 6px 10px; }
.fb-acc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
button.link { background: none; border: 0; padding: 2px; color: var(--muted); }
button.link:hover:not(:disabled) { background: none; color: var(--text); }
button.link svg { width: 13px; height: 13px; }

/* --- soạn bài + chọn nhóm --- */
.fb-compose { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.fb-tools { display: flex; align-items: center; gap: 8px; }
.fb-tools .muted { margin-right: auto; }
.preview { border: 1px dashed var(--border-2); border-radius: var(--radius-sm); overflow: hidden; }
.preview-head {
    display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 12px;
    background: rgba(255,255,255,.02); border-bottom: 1px dashed var(--border-2);
}
.preview-head small { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.preview-body { padding: 12px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; font-size: 14px; }

.fb-group-tools { display: flex; gap: 8px; align-items: center; }
.fb-group-tools .search { flex: 1; width: auto; }
.group-list { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.group-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); }
.group-list li:last-child { border-bottom: 0; }
.group-list li:hover { background: rgba(255,255,255,.02); }
.group-list li.selected { background: rgba(59,130,246,.08); }
.g-pick { flex-direction: row; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-tags { display: flex; gap: 4px; flex: none; }
.tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--panel-3); color: var(--text-2); white-space: nowrap; }
.group-list .icon-only, .ghost-link { opacity: .55; }
.group-list li:hover .icon-only, .group-list li:hover .ghost-link { opacity: 1; }
.ghost-link { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--text-2); flex: none; }
.ghost-link:hover { background: var(--panel-3); }
.ghost-link svg { width: 14px; height: 14px; }
.list-empty { padding: 28px 16px !important; text-align: center; color: var(--muted); display: block !important; margin: 0; border: 0 !important; }

/* --- gửi --- */
.fb-submit {
    display: flex; align-items: center; gap: 16px; justify-content: flex-end; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel);
}
.fb-submit #fbPlan { flex: 1; font-size: 13px; }
.fb-submit #fbPlan b { color: var(--text); }
.warn-text { color: #fbbf24; }
.ok-text { color: #4ade80; }
.err-text { color: #f87171; }

.onboard {
    display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius);
    border: 1px dashed rgba(59,130,246,.45); background: rgba(59,130,246,.06);
}
.onboard .empty-ico { margin: 0; flex: none; }
.onboard p { margin: 4px 0 0; }
.onboard > div:nth-child(2) { flex: 1; }
#fbNotice { display: flex; flex-direction: column; gap: 10px; }
#fbNotice:empty { display: none; }

/* --- chiến dịch --- */
.campaign { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.campaign:first-child { padding-top: 0; }
.campaign:last-child { border-bottom: 0; padding-bottom: 0; }
.campaign-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.campaign-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; color: var(--text-2); max-height: 3.1em; overflow: hidden; }
.progress { display: flex; height: 6px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.progress span { width: 0; transition: width .4s var(--ease); }
.p-ok { background: var(--ok); }
.p-warn { background: var(--warn); }
.p-err { background: var(--err); }
.campaign-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.campaign-foot .muted { margin-right: auto; }
.campaign-actions { display: flex; gap: 6px; }

/* --- hộp thoại chi tiết chiến dịch --- */
.steps { margin: 14px 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--panel-3); padding: 2px 6px; border-radius: 6px; color: #c7d2fe; word-break: break-all; }
.job-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.job-list .batch-head { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 0 4px; }
.job { padding: 8px 0; border-bottom: 1px solid var(--border); }
.job-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-name { color: var(--text); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-name:hover { text-decoration: underline; }
.job-sub { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .reason { max-width: none; white-space: normal; }

@media (max-width: 1100px) {
    .fb-compose { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    #fbBtnSettings, #fbBtnAdd { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
    #fbBtnSettings span, #fbBtnAdd span { display: none; }
    #fbBtnSettings svg, #fbBtnAdd svg { width: 18px; height: 18px; }
    .input-row { flex-direction: column; }
    #view-fb .view-body { overflow-x: hidden; }
    .fb-accounts { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
    .fb-accounts::-webkit-scrollbar { display: none; }
    .fb-acc { flex: 0 0 86%; scroll-snap-align: start; }
    .group-list { max-height: 50dvh; }
    .group-list li { padding: 8px 6px 8px 12px; }
    .g-name { white-space: normal; line-height: 1.35; }
    .group-list .ghost-link { display: none; }
    .group-list .icon-only { opacity: 1; }
    .fb-submit { flex-direction: column; align-items: stretch; gap: 8px; }
    .fb-submit button { width: 100%; }
    .onboard { flex-direction: column; text-align: center; }
    .campaign-top { flex-direction: column; gap: 6px; }
}
