/* Social Media Auto Poster — "PostPilot". Cyan/teal. Namespaced .sm */
* { box-sizing: border-box; }
.sm {
    --bg: #f4f7fb; --panel: #ffffff; --panel2: #eef2f8; --line: #e3e8f1;
    --ink: #101828; --muted: #667089; --brand: #06b6d4; --brand-ink: #0891b2; --accent: #0ea5e9;
    --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
    --shadow: 0 16px 38px -22px rgba(30,50,90,.45);
    font-family: "Inter", ui-sans-serif, system-ui, sans-serif; color: var(--ink);
    min-height: calc(100vh - 44px);
    background: radial-gradient(900px 400px at 90% -12%, rgba(6,182,212,.1), transparent), var(--bg);
}
:root[data-demo-theme="dark"] .sm {
    --bg: #0c1322; --panel: #131c2f; --panel2: #172136; --line: #24314c; --ink: #e7edf8; --muted: #93a0bd;
}
.sm h1, .sm h2, .sm h3, .sm p { margin: 0; }

/* ── Topbar ─────────────────────────────────────────────── */
.sm-topbar {
    display: flex; align-items: center; gap: 1rem; padding: .75rem 1.4rem;
    background: var(--panel); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
}
.sm-brand { display: flex; align-items: center; gap: .6rem; }
.sm-logo { width: 2.1rem; height: 2.1rem; border-radius: .6rem; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; display: grid; place-items: center; font-size: 1.15rem; }
.sm-brand b { display: block; line-height: 1.1; }
.sm-brand small { color: var(--muted); font-size: .72rem; }
.sm-nav { display: flex; gap: .25rem; margin: 0 auto; flex-wrap: wrap; }
.sm-navbtn { border: 0; background: transparent; color: var(--muted); padding: .5rem .9rem; border-radius: .6rem; font: 600 .85rem inherit; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.sm-navbtn:hover { color: var(--ink); background: var(--panel2); }
.sm-navbtn.active { background: var(--brand); color: #fff; }
.sm-top-actions { display: flex; align-items: center; gap: .7rem; }
.sm-live { color: var(--ok); font-size: .72rem; font-weight: 800; letter-spacing: .08em; display: inline-flex; gap: .35rem; align-items: center; }
.sm-live::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); animation: smp 1.4s infinite; }
@keyframes smp { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.sm-view { max-width: 1240px; margin: 0 auto; padding: 1.4rem; }
.sm-view[hidden] { display: none !important; }
.sm-h { font-size: 1.3rem; font-weight: 800; }
.sm-sub { color: var(--muted); font-size: .84rem; margin-bottom: 1.1rem; }

.sm-btn { border: 0; cursor: pointer; border-radius: .6rem; padding: .55rem 1rem; font: 700 .84rem inherit; background: var(--brand); color: #fff; display: inline-flex; align-items: center; gap: .4rem; }
.sm-btn:hover { background: var(--brand-ink); }
.sm-btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.sm-btn.ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.sm-btn.sm-sm { padding: .4rem .7rem; font-size: .78rem; }

/* ── Create view (3-column) ─────────────────────────────── */
.sm-create { display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; gap: 1.1rem; align-items: start; }
.sm-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.1rem; box-shadow: var(--shadow); }
.sm-panel h3 { font-size: .95rem; margin-bottom: .8rem; }

/* Accounts column */
.sm-acct-marks { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .8rem; }
.sm-acct-marks .m { width: 1.7rem; height: 1.7rem; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--panel); }
.sm-acct-marks .m svg { width: 100%; height: 100%; display: block; }
.sm-search { position: relative; margin-bottom: .8rem; }
.sm-search input { width: 100%; border: 1px solid var(--line); border-radius: .6rem; padding: .5rem .7rem .5rem 2rem; font: inherit; font-size: .84rem; background: var(--panel2); color: var(--ink); }
.sm-search .ic { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; }
.sm-acct { display: flex; align-items: center; gap: .6rem; padding: .55rem .3rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.sm-acct:last-of-type { border-bottom: 0; }
.sm-acct input { accent-color: var(--brand); width: 1rem; height: 1rem; flex: none; }
.sm-acct .av { position: relative; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--panel2); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); overflow: hidden; }
.sm-acct .av .pf { position: absolute; right: -2px; bottom: -2px; width: 1rem; height: 1rem; }
.sm-acct .nm { min-width: 0; flex: 1; }
.sm-acct .nm b { display: block; font-size: .84rem; }
.sm-acct .nm small { color: var(--muted); font-size: .74rem; }

/* Composer column */
.sm-tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel2); border-radius: .7rem; margin-bottom: 1rem; }
.sm-tab { border: 0; background: transparent; color: var(--muted); font: 700 .82rem inherit; padding: .45rem 1rem; border-radius: .55rem; cursor: pointer; }
.sm-tab.active { background: var(--brand); color: #fff; }
.sm-editor { width: 100%; min-height: 150px; border: 0; resize: vertical; font: inherit; font-size: .92rem; line-height: 1.55; color: var(--ink); background: transparent; outline: none; }
.sm-tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding-top: .8rem; border-top: 1px solid var(--line); margin-top: .4rem; }
.sm-tool { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: .55rem; padding: .4rem .6rem; font: 600 .8rem inherit; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.sm-tool:hover { color: var(--ink); border-color: var(--muted); }
.sm-tool.ai { color: var(--brand-ink); border-color: var(--brand); }
.sm-composer-foot { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: 1rem; }
.sm-tmpl { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .82rem; }
.sm-tmpl input { accent-color: var(--brand); }
.sm-composer-foot .sp { flex: 1; }
.sm-split { display: inline-flex; }
.sm-split .sm-btn { border-radius: .6rem 0 0 .6rem; }
.sm-split .cx { border-radius: 0 .6rem .6rem 0; padding: .55rem .55rem; border-left: 1px solid rgba(255,255,255,.35); }

/* Preview column (Facebook style) */
.sm-preview-hd { font-size: .95rem; font-weight: 800; margin-bottom: .8rem; }
.sm-fb { border: 1px solid var(--line); border-radius: .8rem; overflow: hidden; background: var(--panel); }
.sm-fb-top { display: flex; align-items: center; gap: .6rem; padding: .8rem; }
.sm-fb-top .av { width: 2.2rem; height: 2.2rem; border-radius: 50%; overflow: hidden; flex: none; }
.sm-fb-top .av svg { width: 100%; height: 100%; }
.sm-fb-top b { display: block; font-size: .86rem; }
.sm-fb-top small { color: var(--muted); font-size: .72rem; }
.sm-fb-text { padding: 0 .8rem .7rem; font-size: .86rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.sm-fb-tags { padding: 0 .8rem .7rem; color: var(--brand-ink); font-size: .82rem; font-weight: 600; }
.sm-fb-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: linear-gradient(135deg, #6d5bd0, #d97ba6); }
.sm-fb-actions { display: flex; justify-content: space-around; padding: .5rem .3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; font-weight: 600; }
.sm-fb-actions span { display: inline-flex; align-items: center; gap: .35rem; }

/* ── Platforms view ─────────────────────────────────────── */
.sm-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.sm-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.sm-kpi b { font-size: 1.7rem; font-weight: 800; display: block; letter-spacing: -.02em; }
.sm-kpi small { color: var(--muted); font-size: .78rem; }
.sm-plat { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.sm-plat-hd { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.sm-plat-hd .mk { width: 2rem; height: 2rem; }
.sm-plat-hd .mk svg { width: 100%; height: 100%; }
.sm-plat-hd b { font-size: .98rem; }
.sm-plat-hd .add { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: .25rem .6rem; font: 600 .74rem inherit; cursor: pointer; }
.sm-plat-hd .sync { margin-left: auto; color: var(--muted); font-size: .74rem; }
.sm-plat-grid { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 1rem; align-items: center; }
.sm-stat b { display: block; font-size: 1rem; font-weight: 800; }
.sm-stat small { color: var(--muted); font-size: .74rem; }
.sm-plat-actions { display: flex; flex-direction: column; gap: .4rem; min-width: 190px; }
.sm-plat-actions .sm-btn { justify-content: center; }

/* ── Calendar view ──────────────────────────────────────── */
.sm-cal-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sm-cal-nav { display: inline-flex; align-items: center; gap: .5rem; }
.sm-cal-nav button { border: 1px solid var(--line); background: var(--panel); border-radius: .5rem; width: 2rem; height: 2rem; cursor: pointer; color: var(--ink); }
.sm-cal-nav b { min-width: 5rem; text-align: center; }
.sm-cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sm-cal { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed; }
.sm-cal th { padding: .5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; border-bottom: 1px solid var(--line); }
.sm-cal td { border: 1px solid var(--line); vertical-align: top; height: 118px; padding: .35rem; }
.sm-cal .dn { font-size: .78rem; color: var(--muted); font-weight: 700; margin-bottom: .3rem; }
.sm-cal td.out { background: var(--panel2); }
.sm-post { display: flex; align-items: center; gap: .35rem; background: var(--panel2); border: 1px solid var(--line); border-radius: .45rem; padding: .25rem .35rem; margin-bottom: .3rem; font-size: .72rem; cursor: pointer; }
.sm-post .mk { width: 1rem; height: 1rem; flex: none; }
.sm-post .mk svg { width: 100%; height: 100%; }
.sm-post .tx { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.sm-post .kd { flex: none; opacity: .8; }

/* ── AI Assistance slide-over ───────────────────────────── */
.sm-ai-scrim { position: fixed; inset: 0; background: rgba(8,14,26,.35); z-index: 120; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sm-ai-scrim.on { opacity: 1; pointer-events: auto; }
.sm-ai { position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 92vw; background: var(--panel); border-left: 1px solid var(--line); z-index: 121; transform: translateX(100%); transition: transform .28s var(--ds-ease, ease); display: flex; flex-direction: column; }
.sm-ai.on { transform: none; }
.sm-ai-hd { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.sm-ai-hd b { font-size: .95rem; }
.sm-ai-x { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.sm-ai-body { flex: 1; overflow-y: auto; padding: 1.2rem; }
.sm-ai-welcome { text-align: center; padding: 2rem 1rem; }
.sm-ai-welcome .orb { width: 3rem; height: 3rem; border-radius: 50%; margin: 0 auto .8rem; background: linear-gradient(135deg, var(--brand), var(--accent)); display: grid; place-items: center; color: #fff; font-size: 1.3rem; }
.sm-ai-welcome b { display: block; font-size: 1rem; }
.sm-ai-welcome small { color: var(--muted); }
.sm-ai-msg { max-width: 90%; padding: .6rem .8rem; border-radius: .8rem; font-size: .86rem; line-height: 1.5; margin-bottom: .7rem; }
.sm-ai-msg.me { margin-left: auto; background: var(--brand); color: #fff; border-bottom-right-radius: .2rem; }
.sm-ai-msg.bot { background: var(--panel2); color: var(--ink); border-bottom-left-radius: .2rem; }
.sm-ai-sugs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: 0 1.2rem 1rem; }
.sm-ai-sug { border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: .6rem; padding: .55rem .6rem; font: 500 .76rem inherit; text-align: left; cursor: pointer; }
.sm-ai-sug:hover { color: var(--ink); border-color: var(--brand); }
.sm-ai-foot { display: flex; align-items: center; gap: .5rem; padding: .8rem 1.2rem 1rem; border-top: 1px solid var(--line); }
.sm-ai-foot input { flex: 1; border: 1px solid var(--line); border-radius: .7rem; padding: .55rem .8rem; font: inherit; font-size: .85rem; background: var(--panel2); color: var(--ink); }
.sm-ai-send { border: 0; background: var(--brand); color: #fff; border-radius: 50%; width: 2.2rem; height: 2.2rem; cursor: pointer; flex: none; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1080px) {
    .sm-create { grid-template-columns: 260px minmax(0, 1fr); }
    .sm-preview-col { grid-column: 1 / -1; }
    .sm-plat-grid { grid-template-columns: repeat(2, 1fr); }
    .sm-plat-actions { grid-column: 1 / -1; flex-direction: row; min-width: 0; }
}
@media (max-width: 768px) {
    .sm-nav { width: 100%; margin: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .sm-nav::-webkit-scrollbar { display: none; }
    .sm-navbtn { flex: 0 0 auto; }
    .sm-create { grid-template-columns: minmax(0, 1fr); }
    .sm-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .sm-view { padding: 1rem; }
    .sm-kpis { grid-template-columns: 1fr; }
    .sm-plat-grid { grid-template-columns: 1fr; }
    .sm-plat-actions { flex-direction: column; }
    .sm-composer-foot .sp { display: none; }
}
