/* Social Intelligence — platform UI. Arabic-first, RTL. */
:root {
  --ink: #142B4A;
  --ink-2: #2A4468;
  --teal: #0E7C86;
  --teal-2: #0B626A;
  --paper: #F5F7F9;
  --surface: #FFFFFF;
  --line: #DCE2EA;
  --line-2: #C7CFDA;
  --text: #1F2A3A;
  --muted: #6B7688;
  --neg: #B01B1B;
  --neu: #8A94A6;
  --pos: #1E8449;
  --neg-bg: #FBEDED;
  --neu-bg: #F0F2F5;
  --pos-bg: #E9F5EE;
  --radius: 6px;
  --w: 1180px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
  color: var(--text); background: var(--paper); direction: rtl; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); font-weight: 600; margin: 0 0 .4em; line-height: 1.35; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
:focus-visible { outline: 3px solid #7CC7CE; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav {
  background: var(--ink); color: #DCE6F2; padding: 22px 18px; display: flex; flex-direction: column; gap: 6px;
}
.nav .brand { color: #fff; font-weight: 600; font-size: 1.05rem; padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.14); margin-bottom: 12px; }
.nav .brand small { display: block; color: #9FB3CC; font-weight: 400; font-size: .78rem; }
.nav a { color: #DCE6F2; padding: 9px 10px; border-radius: var(--radius); display: block; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--teal); color: #fff; }
.nav .spacer { flex: 1; }
.nav .who { font-size: .82rem; color: #9FB3CC; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.14); }
.nav .who b { color: #fff; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; }
.nav .who .who-line { display: flex; gap: 10px; align-items: center; }
.nav .who .who-line a { padding: 0; display: inline; }
.nav .who .who-line a::before { content: "·"; margin-inline-end: 10px; color: #9FB3CC; }
main { padding: 28px 36px; max-width: var(--w); width: 100%; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 0; }

/* ---- buttons & forms ---- */
.btn {
  display: inline-block; background: var(--teal); color: #fff; border: 0; border-radius: var(--radius);
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--teal-2); text-decoration: none; }
.btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line-2); }
.btn.quiet:hover { background: #fff; }
.btn.small { padding: 5px 10px; font-size: .85rem; font-weight: 500; }
label { display: block; font-weight: 600; color: var(--ink); margin: 14px 0 6px; font-size: .92rem; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius);
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; max-width: 760px; }
.error { background: var(--neg-bg); color: var(--neg); border: 1px solid #EFC2C2; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }
.notice { background: var(--pos-bg); color: var(--pos); border: 1px solid #BFE1CB; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .hero { background: var(--ink); color: #fff; padding: 56px 60px; display: flex; flex-direction: column; justify-content: space-between; }
.login .hero h1 { color: #fff; font-size: 2.6rem; line-height: 1.25; max-width: 14ch; }
.login .hero p { color: #B7C7DA; max-width: 42ch; font-size: 1.02rem; }
.login .bands { display: flex; height: 10px; width: 260px; margin-top: 28px; }
.login .bands i { flex: 1; }
.login .panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login .panel form { width: 100%; max-width: 380px; }
.login .panel h2 { margin-bottom: 18px; }
.login .panel .btn { width: 100%; margin-top: 18px; }
.login .foot { font-size: .8rem; color: #9FB3CC; }

/* ---- project list ---- */
.projects { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.projects .item { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); align-items: center; }
.projects .item:last-child { border-bottom: 0; }
.projects .item:hover { background: #FAFBFC; }
.projects .head { background: var(--paper); color: var(--muted); font-size: .82rem; font-weight: 600; }
.projects .name a { color: var(--ink); font-weight: 600; }
.projects .name small { display: block; color: var(--muted); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* ---- dashboard ---- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 22px; }
.kpis div { padding: 16px 18px; border-left: 1px solid var(--line); }
.kpis div:last-child { border-left: 0; }
.kpis .v { font-size: 1.6rem; font-weight: 600; color: var(--ink); line-height: 1.2; }
.kpis .k { color: var(--muted); font-size: .85rem; }
.kpis .d { font-size: .82rem; margin-top: 2px; }
.kpis .d.up { color: var(--pos); } .kpis .d.down { color: var(--neg); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 22px; }
.panel h2 { display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 small { color: var(--muted); font-weight: 400; font-size: .85rem; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.chart { width: 100%; height: 300px; }
.topics td, .topics th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.topics th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.topics .score { font-weight: 600; font-variant-numeric: tabular-nums; }
.topics tr:last-child td { border-bottom: 0; }
table { width: 100%; border-collapse: collapse; }

/* ---- sentiment marks (data only) ---- */
.s-Negative { color: var(--neg); } .s-Neutral { color: var(--neu); } .s-Positive { color: var(--pos); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.tag.Negative { background: var(--neg-bg); color: var(--neg); }
.tag.Neutral { background: var(--neu-bg); color: #5B6577; }
.tag.Positive { background: var(--pos-bg); color: var(--pos); }

/* ---- feed ---- */
.feed-wrap { display: grid; grid-template-columns: 1fr 250px; gap: 22px; align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: sticky; top: 20px; }
.filters h3 { font-size: 1rem; font-weight: 600; color: var(--ink); margin: 20px 0 8px;
              padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.filters h3:first-child { margin-top: 0; }
.filters a.facet { display: block; color: var(--text); padding: 6px 6px 7px; border-radius: 4px; }
.filters a.facet:hover { background: var(--paper); text-decoration: none; }
.filters a.facet.on { background: var(--paper); }
.facet-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.facet-label { font-size: .93rem; }
.facet.on .facet-label { font-weight: 600; }
.facet-n { display: flex; align-items: baseline; gap: 6px; }
.facet-n b { font-weight: 600; font-size: .93rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.facet-pct { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; min-width: 3.1ch; text-align: left; }
/* proportion bar: shows the shape of the data without adding another colour */
.facet-bar { display: block; height: 3px; margin-top: 5px; background: #E9EDF2; border-radius: 2px; overflow: hidden; }
.facet-bar > span { display: block; height: 100%; border-radius: 2px; background: currentColor; opacity: .85; }
.facet-bar > .bar-quiet { background: var(--line-2); }
.facet-bar > .tone-author { background: var(--teal); opacity: .55; }
.facet-bar > .s-Negative { background: var(--neg); }
.facet-bar > .s-Neutral { background: var(--neu); }
.facet-bar > .s-Positive { background: var(--pos); }

.feed { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mention { display: grid; grid-template-columns: 4px 1fr; border-bottom: 1px solid var(--line); }
.mention:last-child { border-bottom: 0; }
.mention .bar { background: var(--neu); }
.mention.Negative .bar { background: var(--neg); } .mention.Positive .bar { background: var(--pos); }
.mention .body { padding: 14px 18px; }
.mention .meta { display: flex; gap: 14px; align-items: center; font-size: .84rem; color: var(--muted); margin-bottom: 6px; }
.mention .meta b { color: var(--ink); font-weight: 600; }
.mention .text { font-size: 1rem; line-height: 1.8; white-space: pre-wrap; }
.mention .foot { display: flex; gap: 16px; align-items: center; margin-top: 8px; font-size: .84rem; color: var(--muted); flex-wrap: wrap; }
.mention .foot .topics span { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; margin-inline-start: 4px; }
.override { display: inline-flex; gap: 4px; }
.override button { font: inherit; font-size: .8rem; border: 1px solid var(--line-2); background: #fff; border-radius: 4px; padding: 2px 8px; cursor: pointer; color: var(--muted); }
.override button.on { border-color: currentColor; font-weight: 600; }
.override button:hover { background: var(--paper); }
.pager { display: flex; justify-content: center; gap: 10px; padding: 14px; color: var(--muted); font-size: .9rem; }
.pager a { padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--ink); }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav .brand { border: 0; padding: 0 8px; margin: 0; }
  .nav .spacer, .nav .who { display: none; }
  main { padding: 18px; }
  .login { grid-template-columns: 1fr; }
  .login .hero { padding: 36px 28px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis div { border-left: 0; border-bottom: 1px solid var(--line); }
  .two, .feed-wrap { grid-template-columns: 1fr; }
  .projects .item { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: 1fr; }
}

/* background job progress */
.spin { width: 14px; height: 14px; border: 2px solid #BFD3E6; border-top-color: var(--teal);
        border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; border-top-color: #BFD3E6; } }

/* period control */
.period { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 0 0 18px;
          background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
          padding: 10px 16px; }
.period-presets { display: flex; gap: 4px; }
.period-presets a { padding: 5px 12px; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.period-presets a:hover { background: var(--paper); text-decoration: none; }
.period-presets a.on { background: var(--ink); color: #fff; font-weight: 600; }
.period-range { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.period-range label { margin: 0; font-weight: 400; color: var(--muted); font-size: .9rem; }
.period-range input[type=date] { width: auto; padding: 6px 10px; font-size: .9rem;
                                 font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .period-range { margin-inline-start: 0; width: 100%; }
  .period-range input[type=date] { flex: 1; }
}

/* applied filters */
.results-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 26px 0 12px; }
.results-head h2 { margin: 0; }
.results-head .count { color: var(--muted); font-weight: 400; font-size: .95rem; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips-label { color: var(--muted); font-size: .85rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
        background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
        font-size: .86rem; color: var(--text); }
.chip:hover { border-color: var(--ink); text-decoration: none; }
.chip-k { color: var(--muted); }
.chip-v { font-weight: 600; }
.chip.s-Negative .chip-v { color: var(--neg); }
.chip.s-Neutral .chip-v { color: #5B6577; }
.chip.s-Positive .chip-v { color: var(--pos); }
.chip-x { color: var(--muted); font-size: 1rem; line-height: 1; }
.chip:hover .chip-x { color: var(--neg); }
.chip-clear { font-size: .85rem; color: var(--teal); }

/* author avatars */
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none;
          background: var(--paper); border: 1px solid var(--line); }
.avatar-sm { width: 20px; height: 20px; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center;
                   background: var(--ink-2); color: #fff; font-weight: 600; font-size: .78rem;
                   border-color: transparent; }
.avatar-sm.avatar-fallback { font-size: .66rem; }
.facet-author { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.facet-author .handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention .meta { gap: 10px; }

/* engagement figures: the number carries the weight, the label explains it */
.engagement { display: inline-flex; gap: 14px; flex-wrap: wrap; }
.engagement span { color: var(--muted); font-size: .84rem; }
.engagement b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums;
                margin-inline-end: 3px; }

/* sort control */
.sorter { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-inline-start: auto; }
.sorter-label { color: var(--muted); font-size: .85rem; margin-inline-end: 4px; }
.sorter a { padding: 4px 10px; border-radius: 999px; color: var(--muted); font-size: .87rem; }
.sorter a:hover { background: var(--paper); text-decoration: none; }
.sorter a.on { background: var(--paper); color: var(--ink); font-weight: 600; }
.sorter .dir { margin-inline-start: 4px; color: var(--teal); }
@media (max-width: 900px) { .sorter { margin-inline-start: 0; } }

/* interaction network */
.net-help { color: var(--muted); font-size: .88rem; margin: -4px 0 12px; }
.net-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
                gap: 16px 22px; margin-bottom: 16px; font-size: .88rem; color: var(--muted); }
.net-control { display: flex; flex-direction: column; gap: 4px; }
.net-control-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.net-control-help { color: var(--muted); font-size: .8rem; line-height: 1.7; }
.net-controls label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--muted); }
.net-controls input[type=number], .net-controls select, .net-controls input[type=search]
  { padding: 4px 8px; font-size: .86rem; width: auto; }
.net-chart { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #FCFDFE; }
.net-side { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 14px; }
.net-side h3 { font-size: .9rem; color: var(--muted); margin: 0 0 6px; }
.net-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 6px; border-radius: 4px; color: var(--text); font-size: .9rem; }
a.net-row:hover { background: var(--paper); text-decoration: none; }
.net-row .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 4px; }
@media (max-width: 900px) { .net-side { grid-template-columns: 1fr; } .net-chart { height: 420px; } }

.net-empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
             gap: 8px; height: 100%; min-height: 240px; text-align: center; padding: 24px; }
.net-empty b { color: var(--ink); }
.net-empty span { color: var(--muted); font-size: .9rem; max-width: 52ch; line-height: 1.8; }

.net-note { color: var(--muted); font-size: .84rem; line-height: 1.8; margin: 0 0 8px; }

/* community rows are buttons that filter the graph */
button.net-row { width: 100%; border: 0; background: none; font: inherit; text-align: inherit;
                 cursor: pointer; align-items: center; }
button.net-row:hover { background: var(--paper); }
button.net-row.on { background: var(--paper); font-weight: 600; box-shadow: inset 2px 0 0 var(--teal); }
.net-clear { margin-bottom: 6px; }

.quota-bar { height: 10px; background: #E9EDF2; border-radius: 5px; overflow: hidden; margin: 6px 0 8px; }
.quota-bar > span { display: block; height: 100%; background: var(--teal); border-radius: 5px; }
.quota-bar > span.warn { background: #B5651D; }

/* content filter panel */
.filter-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
                margin: 0 0 18px; }
.filter-panel > summary { cursor: pointer; padding: 12px 16px; list-style: none; display: flex;
                          align-items: baseline; gap: 12px; flex-wrap: wrap; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary::before { content: "▸"; color: var(--teal); margin-inline-end: 2px; }
.filter-panel[open] > summary::before { content: "▾"; }
.filter-panel > summary span { font-weight: 600; color: var(--ink); }
.filter-panel > summary small { color: var(--muted); font-size: .84rem; }
.filter-form { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.filter-row { margin-top: 12px; }
.filter-row label, .filter-label { display: block; font-weight: 600; color: var(--ink); margin: 0 0 6px; font-size: .92rem; }
.filter-row .hint code { background: var(--paper); padding: 1px 5px; border-radius: 3px; font-size: .8rem; direction: ltr; unicode-bidi: isolate; }
.filter-form input[type=search] { font-size: .95rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 18px; align-items: end; }
.filter-grid label { margin-top: 12px; }
.filter-check label { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; margin: 12px 0 8px; }
.filter-actions { display: flex; gap: 10px; margin-top: 16px; }
.chips label.chip { cursor: pointer; }
.chips label.chip input { display: none; }
.chips label.chip.on { border-color: var(--teal); color: var(--teal); font-weight: 600; background: #EEF6F7; }
