/* Sochial Media Manger — UI tokens & components (RTL first) */
:root {
  --ink: #15162B;
  --ink-2: #23244A;
  --paper: #F1F2F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --line: #E2E4EE;
  --text: #1B1C33;
  --muted: #6B6E8A;
  --violet: #5B4BFF;
  --violet-soft: #ECEAFF;
  --gain: #0E9F6E;
  --gain-soft: #E3F6EE;
  --loss: #E5345F;
  --loss-soft: #FDE8EE;
  --amber: #D98A00;
  --amber-soft: #FFF3DA;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(21, 22, 43, .06), 0 6px 24px -12px rgba(21, 22, 43, .18);
  --font-ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-display: "Readex Pro", "IBM Plex Sans Arabic", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0F1021;
  --surface: #181A33;
  --surface-2: #1E2040;
  --line: #2C2F55;
  --text: #ECEDF7;
  --muted: #9A9DC0;
  --violet: #8B7FFF;
  --violet-soft: #26244F;
  --gain: #34D399;
  --gain-soft: #10352B;
  --loss: #FB7194;
  --loss-soft: #3D1A2A;
  --amber: #FBBF24;
  --amber-soft: #3A2E10;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-ui); background: var(--paper); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--violet); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.3; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .88em; direction: ltr; display: inline-block; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--ink); color: #C9CBE6; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 30px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 18px; }
.brand b { font-family: var(--font-display); font-size: 1rem; line-height: 1.15; }
.brand small { font-weight: 400; color: #8E91BD; font-size: .78rem; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: conic-gradient(from 200deg, #5B4BFF, #E1306C, #F5A524, #5B4BFF); display: grid; place-items: center; flex-shrink: 0; }
.brand-mark span { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.brand-mark.big { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; }
.brand-mark.big span { width: 46px; height: 46px; border-radius: 14px; font-size: 1.4rem; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: #C9CBE6; font-size: .92rem; margin-bottom: 2px; }
.sidebar nav a i { font-size: 1.15rem; opacity: .85; }
.sidebar nav a:hover { background: var(--ink-2); color: #fff; }
.sidebar nav a.active { background: var(--violet); color: #fff; }
.nav-group { font-size: .74rem; color: #6F729E; padding: 16px 12px 6px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--paper); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
.page-title { font-size: 1.25rem; margin: 0; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.only-mobile { display: none !important; }
.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { position: fixed; inset-block: 0; right: 0; z-index: 50; transform: translateX(100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 60px; }
  .hide-sm { display: none; }
}

/* ---------- Buttons & form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 16px; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--violet); }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--loss); }
.btn.danger:hover { border-color: var(--loss); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 11px; font-size: .86rem; border-radius: 8px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--violet); cursor: pointer; font: inherit; padding: 0; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; position: relative; font-size: 1.15rem; }
.icon-btn.sm { width: 30px; height: 30px; font-size: 1rem; border-radius: 8px; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--violet); color: #fff; font-family: var(--font-display); font-weight: 600; cursor: pointer; }
.badge-dot { position: absolute; top: -5px; left: -5px; background: var(--loss); color: #fff; font-style: normal; font-size: .68rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--violet); }
input[type=color] { padding: 2px; height: 40px; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .88rem; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 5px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.stack > * + * { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 16px; flex-wrap: wrap; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form > label { flex: 1; min-width: 140px; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid.side { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }
.mt { margin-top: 18px; }

/* KPI strip — one continuous band instead of separate cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.kpi { padding: 16px 20px; border-inline-start: 1px solid var(--line); }
.kpi:first-child { border-inline-start: 0; }
.kpi .label { font-size: .84rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.kpi .delta { font-size: .82rem; font-weight: 500; }
.up { color: var(--gain); } .down { color: var(--loss); } .flat { color: var(--muted); }

/* Follower pulse hero */
.pulse { background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 24px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-bottom: 18px; }
.pulse h2 { color: #fff; font-size: 1.05rem; }
.pulse .headline { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.35; margin: 4px 0 8px; }
.pulse .headline .g { color: #4ADE9B; } .pulse .headline .l { color: #FF7B9C; }
.pulse p { color: #A9ABD3; margin: 0; font-size: .9rem; }
.pulse-col h3 { font-size: .88rem; color: #A9ABD3; font-weight: 500; display: flex; justify-content: space-between; }
.pulse-col ul { list-style: none; margin: 0; padding: 0; }
.pulse-col li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #2A2B52; font-size: .9rem; }
.pulse-col li:last-child { border-bottom: 0; }
.pulse-col li small { margin-inline-start: auto; color: #7E81AE; font-size: .76rem; }
.pulse a { color: #fff; }
.pulse .btn { background: transparent; color: #fff; border-color: #3A3C6E; }
@media (max-width: 1000px) { .pulse { grid-template-columns: 1fr; } }

.uchip { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: .78rem; font-weight: 600; color: #fff; flex-shrink: 0; text-transform: uppercase; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: start; font-weight: 500; color: var(--muted); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- Tags / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.pill.gain { background: var(--gain-soft); color: var(--gain); border-color: transparent; }
.pill.loss { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.pill.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a.active { color: var(--text); border-color: var(--violet); font-weight: 500; }
.tabs a .count { font-size: .75rem; background: var(--surface-2); border-radius: 999px; padding: 0 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.alert.ok { background: var(--gain-soft); color: var(--gain); }
.alert.err { background: var(--loss-soft); color: var(--loss); }
.alert.warn { background: var(--amber-soft); color: var(--amber); }
.alert.info { background: var(--violet-soft); color: var(--violet); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty i { font-size: 2.4rem; color: var(--violet); }
.empty h3 { color: var(--text); margin-top: 10px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; left: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 220px; z-index: 30; overflow: hidden; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu > a { display: flex; gap: 8px; align-items: center; padding: 10px 14px; color: var(--text); }
.dropdown-menu > a:hover { background: var(--surface-2); }
.dm-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.notif-menu { width: 340px; max-height: 440px; overflow-y: auto; }
.notif { display: block !important; border-inline-start: 3px solid transparent; font-size: .88rem; }
.notif small { display: block; color: var(--muted); font-size: .75rem; }
.notif.unread { background: var(--violet-soft); }
.notif.n-unfollow { border-color: var(--loss); }
.notif.n-follow { border-color: var(--gain); }
.pad { padding: 14px; margin: 0; }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(640px, 94vw); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(15, 16, 33, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px; max-height: 75vh; overflow-y: auto; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 16px; }
.auth-card { background: var(--surface); padding: 32px; border-radius: 22px; width: min(420px, 100%); text-align: center; }
.auth-card form { text-align: start; margin-top: 18px; }
.auth-card h1 { font-size: 1.4rem; }

/* ---------- Accounts ---------- */
.acc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; border-top: 4px solid var(--acc, var(--violet)); }
.acc-top { display: flex; gap: 12px; align-items: center; }
.acc-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 1.4rem; overflow: hidden; flex-shrink: 0; }
.acc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.acc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; text-align: center; }
.acc-stats b { display: block; font-family: var(--font-display); font-size: 1.15rem; }
.acc-stats span { font-size: .76rem; color: var(--muted); }
.goal-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.goal-bar i { display: block; height: 100%; background: var(--violet); border-radius: 3px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; min-height: 300px; display: flex; flex-direction: column; }
.kcol-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; font-weight: 600; font-family: var(--font-display); font-size: .95rem; }
.kcol-head .count { font-size: .78rem; color: var(--muted); font-weight: 400; }
.klist { flex: 1; min-height: 60px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard h4 { font-size: .93rem; margin: 0 0 4px; font-family: var(--font-ui); font-weight: 600; }
.kcard p { font-size: .82rem; color: var(--muted); margin: 0 0 8px; }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kcard.p1 { border-inline-start: 3px solid var(--loss); }
.sortable-ghost { opacity: .4; }

/* ---------- Media ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); position: relative; }
.media-item .thumb { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .cap { padding: 8px 10px; font-size: .78rem; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.media-item .cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item.pickable { cursor: pointer; }
.media-item.pickable:hover { border-color: var(--violet); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius-lg); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--violet); background: var(--violet-soft); }

/* ---------- Composer ---------- */
.composer { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; }
@media (max-width: 1000px) { .composer { grid-template-columns: 1fr; } }
.preview-phone { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 14px; max-width: 340px; margin: 0 auto; }
.preview-phone .ph-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .88rem; margin-bottom: 10px; }
.preview-phone .ph-media { aspect-ratio: 4/5; background: var(--surface-2); border-radius: 12px; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.preview-phone .ph-media img { width: 100%; height: 100%; object-fit: cover; }
.preview-phone .ph-cap { font-size: .86rem; white-space: pre-wrap; margin-top: 10px; word-break: break-word; }
.counter { font-size: .78rem; color: var(--muted); text-align: end; }
.counter.over { color: var(--loss); }
.acc-check { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-check label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--text); font-weight: 400; }
.acc-check label:has(input:checked) { border-color: var(--violet); background: var(--violet-soft); }

/* ---------- Heatmap ---------- */
.heatmap { display: grid; grid-template-columns: 52px repeat(24, 1fr); gap: 3px; font-size: .7rem; color: var(--muted); }
.heatmap .cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heatmap .hl { display: flex; align-items: center; }

/* ---------- Bars ---------- */
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-list li { margin-bottom: 10px; font-size: .88rem; }
.bar-list .bl-top { display: flex; justify-content: space-between; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.bar-track i { display: block; height: 100%; background: var(--violet); border-radius: 4px; }

/* ---------- Misc ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.list-plain li .grow { flex: 1; min-width: 0; }
.task-done { text-decoration: line-through; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; }
.steps { padding-inline-start: 20px; margin: 0; }
.steps li { margin-bottom: 6px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.copy-box { position: relative; }
.post-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: block; }
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2); --fc-today-bg-color: var(--violet-soft); --fc-button-bg-color: var(--surface); --fc-button-text-color: var(--text); --fc-button-border-color: var(--line); --fc-button-active-bg-color: var(--violet); --fc-button-active-border-color: var(--violet); --fc-button-hover-bg-color: var(--surface-2); --fc-button-hover-border-color: var(--violet); font-size: .88rem; }
.fc .fc-toolbar-title { font-family: var(--font-display); font-size: 1.15rem; }
.fc-event { cursor: pointer; border-radius: 6px; padding: 1px 4px; }
@media print { .sidebar, .topbar, .no-print { display: none !important; } .content { padding: 0; } .panel { break-inside: avoid; } }
