/* PostAgent v2 — design system (PCC-aligned)
   ─────────────────────────────────────────────────────────────────
   Light-first, teal accent (#14B8A6), slate ramp, Inter typography,
   subtle Stripe-style shadows. No glow effects. Dark mode pivots to
   PCC navy palette (#0B1738 / #122150 / #1D2E6B). */

/* ─── Tokens (LIGHT — default) ───────────────────────────────── */

:root {
  /* Type — Inter with PCC feature settings */
  --font-sans: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Type scale */
  --fs-2xs: 10px;
  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-base:13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  18px;
  --fs-2xl: 22px;
  --fs-3xl: 26px;
  --fs-display: 30px;
  --lh-tight: 1.2;
  --lh-base:  1.5;
  --lh-loose: 1.65;
  --tracking-tight: -0.011em;
  --tracking-display: -0.020em;

  /* Spacing — 4px base */
  --sp-px: 1px;
  --sp-0_5: 2px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radii — PCC uses 0.5rem ≈ 8px for cards/buttons */
  --rd-xs: 3px;
  --rd-sm: 5px;
  --rd-md: 6px;
  --rd-lg: 8px;
  --rd-xl: 12px;
  --rd-pill: 999px;

  /* Surfaces — PCC light: slate-50 base, white cards */
  --bg:       #F8FAFC;   /* slate-50 — page bg */
  --bg-1:     #FFFFFF;   /* card bg / sidebar bg */
  --bg-2:     #F1F5F9;   /* slate-100 — subtle alt */
  --bg-3:     #F8FAFC;   /* slate-50 alt */
  --bg-4:     #F1F5F9;   /* hover */
  --bg-overlay: rgba(15,23,42,.45);

  /* Borders — slate-200 / 300 */
  --bd:       #E2E8F0;
  --bd-h:     #CBD5E1;
  --bd-strong:#94A3B8;

  /* Foreground — slate ramp */
  --tx:       #0F172A;   /* slate-900 */
  --tx-mut:   #475569;   /* slate-600 */
  --tx-mut-2: #64748B;   /* slate-500 */
  --tx-mut-3: #94A3B8;   /* slate-400 */
  --tx-inv:   #FFFFFF;

  /* Brand — PCC teal */
  --accent:    #0D9488;  /* teal-600 — primary action */
  --accent-h:  #14B8A6;  /* teal-500 — hover / lighter */
  --accent-d:  #0F766E;  /* teal-700 — pressed */
  --accent-bg: #F0FDFA;  /* teal-50 */
  --accent-bd: #99F6E4;  /* teal-200 */
  --accent-text: #0F766E;/* readable on accent-bg */

  /* Workspace stripe — fall back to brand teal; JS may set per-workspace */
  --ws-accent: var(--accent-h);

  /* Status — PCC chip palette */
  --st-draft:     #475569;  /* slate-600 */
  --st-draft-bg:  #F1F5F9;
  --st-ready:     #B45309;  /* amber-700 */
  --st-ready-bg:  #FFFBEB;
  --st-pub:       #047857;  /* emerald-700 */
  --st-pub-bg:    #ECFDF5;
  --st-fail:      #B91C1C;  /* red-700 */
  --st-fail-bg:   #FEF2F2;
  --st-info:      #1D4ED8;  /* blue-700 */
  --st-info-bg:   #EFF6FF;
  --st-purple:    #6D28D9;  /* violet-700 */
  --st-purple-bg: #F5F3FF;

  /* Shadows — Stripe-style, no color glow */
  --sh-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --sh-1:  0 1px 2px 0 rgb(15 23 42 / 0.04), 0 1px 3px 0 rgb(15 23 42 / 0.06);
  --sh-2:  0 4px 6px -1px rgb(15 23 42 / 0.06), 0 2px 4px -2px rgb(15 23 42 / 0.06);
  --sh-3:  0 10px 15px -3px rgb(15 23 42 / 0.08), 0 4px 6px -4px rgb(15 23 42 / 0.06);
  --sh-4:  0 25px 50px -12px rgb(15 23 42 / 0.18);
  --sh-focus: 0 0 0 3px rgb(20 184 166 / 0.18);

  /* Animation */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 100ms;
  --t-base: 160ms;
  --t-slow: 260ms;
}

/* ─── DARK theme — PCC navy palette ─────────────────────────── */

[data-theme="dark"] {
  --bg:       #060D22;   /* navy-950 */
  --bg-1:     #0B1738;   /* navy-900 — sidebar / surface */
  --bg-2:     #122150;   /* navy-800 */
  --bg-3:     #1D2E6B;   /* navy-700 */
  --bg-4:     #243A85;   /* hover */
  --bg-overlay: rgba(6,13,34,.78);
  --bd:       rgba(148,163,184,.12);   /* slate-400 / 12 */
  --bd-h:     rgba(148,163,184,.22);
  --bd-strong:rgba(148,163,184,.40);
  --tx:       #F1F5F9;
  --tx-mut:   #CBD5E1;
  --tx-mut-2: #94A3B8;
  --tx-mut-3: #64748B;
  --accent:    #14B8A6;
  --accent-h:  #2DD4BF;
  --accent-d:  #0D9488;
  --accent-bg: rgba(20,184,166,.12);
  --accent-bd: rgba(20,184,166,.30);
  --accent-text: #5EEAD4;
  --st-draft-bg:  rgba(148,163,184,.10);
  --st-ready-bg:  rgba(245,158,11,.12);
  --st-pub-bg:    rgba(16,185,129,.12);
  --st-fail-bg:   rgba(239,68,68,.12);
  --st-info-bg:   rgba(56,189,248,.12);
  --st-purple-bg: rgba(167,139,250,.14);
  --sh-1: 0 1px 2px rgba(0,0,0,.30), 0 0 0 1px rgba(255,255,255,.04);
  --sh-2: 0 4px 8px rgba(0,0,0,.36), 0 0 0 1px rgba(255,255,255,.04);
  --sh-3: 0 12px 24px rgba(0,0,0,.45);
  --sh-4: 0 24px 48px rgba(0,0,0,.55);
}

/* ─── Reset & base ───────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-feature-settings: "cv11", "ss01", "ss03"; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
button { font-family: inherit; }

.v2-table tbody td,
.v2-mono,
.v2-id,
time { font-variant-numeric: tabular-nums; }

/* ─── Layout shell ───────────────────────────────────────────── */

.v2-shell {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
  position: relative;
}
.v2-shell.collapsed { grid-template-columns: 56px 1fr; }

/* Optional thin accent line at very top — subtle, not glowing */
.v2-shell::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 100;
}

.v2-side {
  background: var(--bg-1);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 2px;
  position: relative;
  z-index: 2;
}
[data-theme="dark"] .v2-side { background: var(--bg-1); }

.v2-side-head {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--bd);
}
.v2-side-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: var(--rd-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.v2-side-logo svg { width: 14px; height: 14px; fill: #fff; }
.v2-side-name {
  font-weight: 600;
  font-size: var(--fs-md);
  letter-spacing: var(--tracking-tight);
  color: var(--tx);
}
.v2-shell.collapsed .v2-side-name { display: none; }

.v2-side-nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-2); }

.v2-nav-group { margin-bottom: var(--sp-4); }
.v2-nav-group-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tx-mut-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
}
.v2-shell.collapsed .v2-nav-group-label { display: none; }

.v2-nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px var(--sp-3);
  border-radius: var(--rd-md);
  color: var(--tx-mut);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
}
.v2-nav-item:hover { background: var(--bg-2); color: var(--tx); }
.v2-nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-text);
}
.v2-nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.v2-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.v2-shell.collapsed .v2-nav-item span { display: none; }
.v2-shell.collapsed .v2-nav-item { justify-content: center; padding: 8px; }
.v2-shell.collapsed .v2-nav-item.active::before { display: none; }

.v2-side-foot {
  border-top: 1px solid var(--bd);
  padding: var(--sp-2);
  display: flex; flex-direction: column; gap: 1px;
  flex-shrink: 0;
}
.v2-user-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--rd-md);
}
.v2-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: var(--fs-xs);
  flex-shrink: 0;
}
.v2-user-meta { overflow: hidden; }
.v2-shell.collapsed .v2-user-meta { display: none; }
.v2-user-name {
  font-size: var(--fs-base); font-weight: 600; line-height: 1.2;
  letter-spacing: var(--tracking-tight);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--tx);
}
.v2-user-role {
  font-size: var(--fs-xs);
  color: var(--tx-mut-2);
  text-transform: capitalize;
  font-weight: 500;
}
.v2-side-btn {
  background: none; border: none;
  color: var(--tx-mut);
  font-size: var(--fs-base); font-weight: 500;
  padding: 7px var(--sp-3);
  border-radius: var(--rd-md);
  text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  transition: background var(--t-fast), color var(--t-fast);
}
.v2-side-btn:hover { background: var(--bg-2); color: var(--tx); }
.v2-side-btn svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .8; }
.v2-shell.collapsed .v2-side-btn span { display: none; }

/* ─── Main / topbar / content ────────────────────────────────── */

.v2-main { display: flex; flex-direction: column; min-width: 0; padding-top: 2px; position: relative; z-index: 1; }
.v2-top {
  min-height: 60px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--bd);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "ws    search lang"
    "crumb crumb  crumb";
  align-items: center;
  padding: 10px var(--sp-6) 6px;
  gap: 10px var(--sp-4);
  flex-shrink: 0;
  position: relative;
}
.v2-ws-pill { grid-area: ws; }
.v2-search-trigger { grid-area: search; }
.v2-lang-toggle { grid-area: lang; }

/* Language toggle — flips between EN and العربية */
.v2-lang-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--bd);
  border-radius: var(--rd-md);
  padding: 7px 12px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--tx);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  font-family: inherit;
  white-space: nowrap;
}
.v2-lang-toggle:hover { border-color: var(--accent-h); background: var(--bg-1); }
.v2-lang-toggle:focus { outline: none; border-color: var(--accent); box-shadow: var(--sh-focus); }
.v2-lang-toggle svg { opacity: .65; flex-shrink: 0; }
.v2-crumbs-bottom {
  grid-area: crumb;
  padding: 4px 0 0;
  font-size: var(--fs-sm) !important;
}

.v2-crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-base);
  flex: 1; min-width: 0;
}
.v2-crumbs a {
  color: var(--tx-mut);
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--rd-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.v2-crumbs a:hover { color: var(--tx); background: var(--bg-2); }
.v2-crumbs .crumb-sep { color: var(--tx-mut-3); font-size: var(--fs-sm); }
.v2-crumbs .crumb-active {
  color: var(--tx);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  padding: 3px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Workspace pill — clean, no glow */
.v2-ws-pill {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--bd);
  padding: 6px 12px 6px 8px;
  border-radius: var(--rd-md);
  font-size: var(--fs-sm);
  cursor: pointer;
  color: var(--tx);
  transition: border-color var(--t-fast), background var(--t-fast);
  position: relative;
  min-height: 40px;
  font-family: inherit;
}
.v2-ws-pill:hover { border-color: var(--accent-h); background: var(--bg-2); }
.v2-ws-pill:focus { outline: none; border-color: var(--accent); box-shadow: var(--sh-focus); }
.v2-ws-dot {
  width: 26px; height: 26px;
  border-radius: var(--rd-sm);
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  flex-shrink: 0;
}

/* Search trigger */
.v2-search-trigger {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--bd);
  padding: 9px 14px;
  border-radius: var(--rd-md);
  color: var(--tx-mut-2);
  font-size: var(--fs-base);
  font-family: inherit;
  cursor: text;
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
  text-align: left;
}
.v2-search-trigger:hover { border-color: var(--accent-h); background: var(--bg-2); }
.v2-search-trigger:focus { outline: none; border-color: var(--accent); box-shadow: var(--sh-focus); }
.v2-search-trigger > svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }
.v2-search-trigger > span:not(.v2-kbd) { flex: 1; }
.v2-kbd-trigger { display: none; }

.v2-kbd { display: inline-flex; align-items: center; gap: 2px; }
.v2-kbd kbd {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--bd);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--tx-mut);
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

.v2-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-8);
}
.v2-page {
  max-width: 1280px;
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: var(--sp-5);
}
.v2-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--bd);
}
.v2-page-eyebrow {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tx-mut-2);
  margin-bottom: 6px;
}
.v2-page-title {
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1.15;
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  color: var(--tx);
}
.v2-page-sub {
  color: var(--tx-mut);
  font-size: var(--fs-md);
  margin-top: 6px;
  letter-spacing: var(--tracking-tight);
  max-width: 720px;
}
.v2-page-actions { display: flex; gap: var(--sp-2); align-items: center; }

/* ─── Cards ──────────────────────────────────────────────────── */

.v2-card {
  background: var(--bg-1);
  border: 1px solid var(--bd);
  border-radius: var(--rd-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.v2-card:hover { border-color: var(--bd-h); box-shadow: var(--sh-2); }
a.v2-card { color: var(--tx); }

.v2-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.v2-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--tx);
  display: flex; align-items: center; gap: var(--sp-2);
}
.v2-card-sub {
  color: var(--tx-mut);
  font-size: var(--fs-sm);
  margin-top: 4px;
  font-weight: 400;
}

.v2-grid { display: grid; gap: var(--sp-3); }
.v2-grid-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.v2-grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.v2-grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ─── Pills (status + ID + channel) ─────────────────────────── */

.v2-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--rd-pill);
  white-space: nowrap;
  border: 1px solid transparent;
}
.v2-pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.v2-pill-draft     { color: var(--st-draft);  background: var(--st-draft-bg); }
.v2-pill-ready     { color: var(--st-ready);  background: var(--st-ready-bg); }
.v2-pill-published { color: var(--st-pub);    background: var(--st-pub-bg); }
.v2-pill-failed    { color: var(--st-fail);   background: var(--st-fail-bg); }
.v2-pill-archived  { color: var(--tx-mut-3);  background: var(--st-draft-bg); }
.v2-pill-info      { color: var(--st-info);   background: var(--st-info-bg); }

.v2-chan {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--rd-sm);
  border: 1px solid var(--bd);
  background: var(--bg-2);
  color: var(--tx-mut);
  white-space: nowrap;
}
.v2-chan-blog      { color: var(--st-info);   background: var(--st-info-bg);   border-color: transparent; }
.v2-chan-linkedin  { color: var(--st-purple); background: var(--st-purple-bg); border-color: transparent; }
.v2-chan-newsletter{ color: var(--st-ready);  background: var(--st-ready-bg);  border-color: transparent; }
.v2-chan-video     { color: #BE185D; background: #FDF2F8; border-color: transparent; }
.v2-chan-publisher { color: var(--st-pub);    background: var(--st-pub-bg);    border-color: transparent; }
.v2-chan-tenant_api{ color: var(--accent);    background: var(--accent-bg);    border-color: transparent; }
.v2-chan-wordpress { color: var(--st-info);   background: var(--st-info-bg);   border-color: transparent; }

/* ID pill — Geist Mono → JetBrains Mono fallback */
.v2-id {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  padding: 2px 6px;
  background: var(--bg-2);
  border: 1px solid var(--bd);
  border-radius: var(--rd-sm);
  color: var(--tx-mut);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
  user-select: none;
  position: relative;
  letter-spacing: 0.02em;
}
.v2-id:hover { border-color: var(--bd-h); color: var(--tx); background: var(--bg-1); }
.v2-id:hover::after {
  content: attr(data-full);
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--bg-1);
  border: 1px solid var(--bd-h);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--rd-sm);
  white-space: nowrap;
  z-index: 50;
  box-shadow: var(--sh-2);
  font-size: var(--fs-2xs);
  color: var(--tx);
  font-family: var(--font-mono);
}
.v2-id-copy { font-size: 9px; opacity: .5; }
.v2-id.copied {
  color: var(--accent);
  border-color: var(--accent-bd);
  background: var(--accent-bg);
}

/* ─── Buttons ────────────────────────────────────────────────── */

.v2-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--rd-md);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: var(--tracking-tight);
  line-height: 1.2;
}
.v2-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.v2-btn-primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.v2-btn-ghost {
  background: var(--bg-1);
  border-color: var(--bd);
  color: var(--tx);
}
.v2-btn-ghost:hover { background: var(--bg-2); border-color: var(--bd-h); }
.v2-btn-icon {
  background: var(--bg-1);
  border-color: var(--bd);
  color: var(--tx-mut);
  padding: 6px;
}
.v2-btn-icon:hover { color: var(--tx); border-color: var(--bd-h); background: var(--bg-2); }
.v2-btn-sm { padding: 4px 10px; font-size: var(--fs-sm); }
.v2-btn-lg { padding: 9px 18px; font-size: var(--fs-md); }
.v2-btn svg { width: 14px; height: 14px; }
.v2-btn-icon svg { width: 14px; height: 14px; }
.v2-btn:focus { outline: none; box-shadow: var(--sh-focus); }

/* ─── Tables ─────────────────────────────────────────────────── */

.v2-table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--bd);
  border-radius: var(--rd-lg);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.v2-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.v2-table thead th {
  text-align: left;
  padding: 9px var(--sp-4);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tx-mut-2);
  background: var(--bg-2);
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}
.v2-table tbody td {
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--bd);
  vertical-align: middle;
  color: var(--tx);
  font-weight: 400;
}
.v2-table tbody tr:last-child td { border-bottom: none; }
.v2-table tbody tr:hover td { background: var(--bg-2); }
.v2-table tbody tr.row-link { cursor: pointer; }
.v2-row-title { font-weight: 500; color: var(--tx); letter-spacing: var(--tracking-tight); }
.v2-row-meta { font-size: var(--fs-xs); color: var(--tx-mut); margin-top: 2px; }

/* ─── Empty + skeleton ──────────────────────────────────────── */

.v2-empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--tx-mut);
}
.v2-empty-glyph {
  width: 44px; height: 44px;
  margin: 0 auto var(--sp-4);
  color: var(--tx-mut-3);
  opacity: .8;
}
.v2-empty-glyph svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.4; fill: none; }
.v2-empty-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--tx);
  margin-bottom: 6px;
  letter-spacing: var(--tracking-tight);
}
.v2-empty-sub { font-size: var(--fs-base); color: var(--tx-mut); max-width: 380px; margin: 0 auto var(--sp-4); }

.v2-skel {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-1) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--rd-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Toast ──────────────────────────────────────────────────── */

.v2-toast {
  position: fixed;
  bottom: var(--sp-5); right: var(--sp-5);
  background: var(--bg-1);
  border: 1px solid var(--bd);
  border-radius: var(--rd-md);
  padding: 8px 14px;
  box-shadow: var(--sh-3);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--tx);
  display: flex; align-items: center; gap: var(--sp-2);
  transform: translateY(20px);
  opacity: 0;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease-out);
  z-index: 1000;
  pointer-events: none;
  max-width: 360px;
  letter-spacing: var(--tracking-tight);
}
.v2-toast.show { transform: translateY(0); opacity: 1; }

/* ─── Forms ──────────────────────────────────────────────────── */

.v2-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.v2-field label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--tx);
  letter-spacing: var(--tracking-tight);
}
.v2-field .help { font-size: var(--fs-xs); color: var(--tx-mut); }
.v2-field input, .v2-field select, .v2-field textarea, .v2-input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--bd-h);
  border-radius: var(--rd-md);
  padding: 7px 11px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--tx);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.v2-field input:focus, .v2-field select:focus, .v2-field textarea:focus, .v2-input:focus {
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
}
.v2-field input::placeholder, .v2-input::placeholder { color: var(--tx-mut-3); }

/* ─── Popovers / Modals ──────────────────────────────────────── */

.v2-pop {
  position: fixed;
  background: var(--bg-1);
  border: 1px solid var(--bd-h);
  border-radius: var(--rd-lg);
  box-shadow: var(--sh-3);
  padding: var(--sp-1);
  z-index: 200;
}

.v2-modal-bg {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  z-index: 500;
}
.v2-modal-bg.show { display: flex; }
.v2-modal {
  background: var(--bg-1);
  border: 1px solid var(--bd);
  border-radius: var(--rd-xl);
  box-shadow: var(--sh-4);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}

/* ─── Filter chips ───────────────────────────────────────────── */

.v2-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.v2-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-2);
  border: 1px solid var(--bd);
  padding: 3px 7px 3px 10px;
  border-radius: var(--rd-pill);
  font-size: var(--fs-xs);
  color: var(--tx);
}
.v2-chip-key { color: var(--tx-mut-2); font-weight: 500; }
.v2-chip-val { font-weight: 600; }
.v2-chip-x {
  background: none; border: none;
  color: var(--tx-mut-2);
  cursor: pointer;
  padding: 0; margin-left: 2px;
  font-size: 14px; line-height: 1;
}
.v2-chip-x:hover { color: var(--st-fail); }

/* ─── Misc ───────────────────────────────────────────────────── */

.v2-hr { height: 1px; background: var(--bd); border: none; margin: var(--sp-5) 0; }
.v2-stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.v2-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.v2-spacer { flex: 1; }
.v2-mono { font-family: var(--font-mono); }
.v2-mut { color: var(--tx-mut); }
.v2-mut-2 { color: var(--tx-mut-2); }
.v2-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scrollbars — Stripe-subtle */
.v2-content::-webkit-scrollbar, .v2-side-nav::-webkit-scrollbar { width: 8px; }
.v2-content::-webkit-scrollbar-track, .v2-side-nav::-webkit-scrollbar-track { background: transparent; }
.v2-content::-webkit-scrollbar-thumb, .v2-side-nav::-webkit-scrollbar-thumb {
  background: var(--bd-h);
  border: 2px solid var(--bg);
  border-radius: 999px;
}
.v2-content::-webkit-scrollbar-thumb:hover { background: var(--bd-strong); }

::selection { background: var(--accent-bg); color: var(--accent-text); }

/* ─── RTL overrides — applied when <html dir="rtl"> ──────────────
   Selectively flips directional properties so Arabic-language
   workspaces render with the sidebar on the right and text aligned
   to the right. Most v2 CSS uses shorthand or symmetric values so
   it works in both directions; this block patches the asymmetric
   bits. */
[dir="rtl"] body { font-family: 'Noto Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }

/* Grid columns: with direction:rtl (inherited from html) the physical
   placement of tracks auto-reverses, so we keep the same template — the
   first track (244px) ends up on the right edge, second (1fr) on the
   left edge, automatically. We only need to flip the sidebar's border
   side (LTR right → RTL left) since border-* properties are physical. */
[dir="rtl"] .v2-side {
  border-right: none;
  border-left: 1px solid var(--bd);
}

[dir="rtl"] .v2-nav-item.active::before {
  left: auto; right: -8px;
  border-radius: 2px 0 0 2px;
}

[dir="rtl"] .v2-page-head::before {
  left: auto; right: 0;
}
[dir="rtl"] .v2-page-eyebrow::before {
  /* Keep the leading rule at the start of the inline direction */
}

[dir="rtl"] .v2-crumbs { direction: rtl; }
[dir="rtl"] .v2-crumbs-bottom { font-size: var(--fs-sm) !important; }

[dir="rtl"] .v2-table thead th { text-align: right; }
[dir="rtl"] .v2-table tbody td { text-align: right; }
[dir="rtl"] .v2-table th[style*="text-align:right"],
[dir="rtl"] .v2-table td[style*="text-align:right"] { text-align: left !important; }

/* Toast slides in from the bottom-LEFT in RTL since right-side is
   reserved for primary content */
[dir="rtl"] .v2-toast { right: auto; left: var(--sp-5); }

/* Drawer slides in from the LEFT in RTL */
[dir="rtl"] .v2-drawer {
  right: auto; left: 0;
  border-left: none;
  border-right: 1px solid var(--bd-strong);
  transform: translateX(-100%);
}
[dir="rtl"] .v2-drawer-overlay { /* full-screen overlay needs no flip */ }

/* Workspace pill chevron flips */
[dir="rtl"] .v2-ws-pill svg.chev { transform: scaleX(-1); }

/* Topbar grid: direction:rtl auto-flips column placement, so the
   workspace pill (column 1) ends up on the right edge and the lang
   toggle (column 3) ends up on the left automatically — no override
   needed. */

/* Forms — labels and inputs flow right-aligned */
[dir="rtl"] .v2-field label { text-align: right; }
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="search"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input:not([type]),
[dir="rtl"] textarea,
[dir="rtl"] select { text-align: right; }
[dir="rtl"] .help { text-align: right; }

/* Card heads — title aligned right */
[dir="rtl"] .v2-card-title,
[dir="rtl"] .v2-card-sub { text-align: right; }

/* Page header — eyebrow / title / sub right-align */
[dir="rtl"] .v2-page-eyebrow,
[dir="rtl"] .v2-page-title,
[dir="rtl"] .v2-page-sub { text-align: right; }

/* Buttons keep their content centered, but flip arrow glyphs */
[dir="rtl"] .v2-btn .arrow-right { transform: scaleX(-1); }

/* Empty state */
[dir="rtl"] .v2-empty,
[dir="rtl"] .v2-empty-title,
[dir="rtl"] .v2-empty-sub { text-align: center; } /* keep centered, override any inherited */

/* Modal popovers — anchor to inline-end naturally */
[dir="rtl"] .v2-pop {
  /* fixed positions still come from JS getBoundingClientRect; no flip */
}

/* Responsive: collapse sidebar below 900px */
/* Backdrop sits in the DOM at all viewports but is hidden until the
   off-canvas sidebar opens (phone only). Without this base rule the
   bare <div class="v2-backdrop"> took a grid cell on desktop and
   pushed .v2-main onto a second row — looked like an empty dashboard
   above the real one. */
.v2-backdrop { display: none; }

/* ─── Responsive ────────────────────────────────────────────────
   Two tiers, deliberately simple:
   - Phone ≤ 720 px: sidebar slides off-canvas with hamburger toggle.
   - Everything else (laptops, tablets, desktops): full 244-px sidebar.
     If the user wants a narrower sidebar they can click the Collapse
     button at the bottom of the sidebar — that's an explicit choice,
     not a width-based auto-collapse.
   The previous auto-collapse at 900-1024 px made laptops look "stuck
   on mobile" so it's gone. */

/* ── Phones: sidebar off-canvas with backdrop ──────────────── */
@media (max-width: 720px) {
  /* Layout — main content takes full width; sidebar overlays when open */
  .v2-shell { grid-template-columns: 1fr; }
  .v2-side {
    position: fixed;
    top: 0; bottom: 0;
    left: 0; width: 280px; max-width: 80vw;
    transform: translateX(-100%);
    transition: transform .22s var(--ease-out);
    z-index: 110;
    box-shadow: 0 0 24px rgba(0, 0, 0, .25);
  }
  [dir="rtl"] .v2-side {
    left: auto; right: 0;
    transform: translateX(100%);
  }
  .v2-shell.side-open .v2-side  { transform: translateX(0); }
  .v2-shell.side-open .v2-backdrop {
    display: block;
    opacity: 1;
  }
  .v2-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: var(--bg-overlay);
    z-index: 100;
    opacity: 0;
    transition: opacity .22s;
  }
  /* Hamburger button — only visible on phones */
  .v2-hamburger { display: inline-flex !important; }

  /* Touch targets: nav items at least 44px tall */
  .v2-nav-item { padding: 11px 12px !important; min-height: 44px; }
  .v2-side-btn { padding: 12px !important; }

  /* Topbar — wrap into 2 rows so search + workspace pill aren't squeezed */
  .v2-top {
    grid-template-columns: auto auto 1fr !important;
    grid-template-areas:
      "burger ws    lang"
      "search search search"
      "crumb  crumb  crumb" !important;
    padding: 8px 12px 4px !important;
    gap: 8px !important;
  }
  .v2-hamburger     { grid-area: burger; }
  .v2-ws-pill       { grid-area: ws; }
  .v2-lang-toggle   { grid-area: lang; }
  .v2-search-trigger { grid-area: search; }
  .v2-crumbs-bottom { grid-area: crumb; }
  .v2-ws-pill { padding: 6px 10px !important; }
  .v2-ws-pill > span:nth-of-type(2) > span:first-child { display: none; }   /* hide "Workspace" eyebrow on the pill */

  /* Page padding */
  .v2-content { padding: var(--sp-3) !important; }
  .v2-page-title { font-size: var(--fs-xl) !important; }
  .v2-page-eyebrow { font-size: var(--fs-2xs) !important; }
  .v2-page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .v2-page-actions { width: 100%; }
  .v2-page-actions > * { width: 100%; }

  /* Multi-column grids collapse */
  .v2-grid,
  .v2-grid-2,
  .v2-grid-3 {
    grid-template-columns: 1fr !important;
  }
  /* Cards reduce side padding */
  .v2-card { padding: var(--sp-3) !important; }

  /* Modals — go almost full viewport */
  .v2-modal {
    max-width: calc(100vw - 16px) !important;
    max-height: 92vh !important;
    border-radius: var(--rd-md) !important;
  }

  /* Tables — already wrapped in v2-table-wrap with overflow-x; force smaller padding */
  .v2-table th,
  .v2-table td { padding: 8px 10px !important; font-size: var(--fs-sm) !important; }

  /* Buttons in stacks become full width by default for easier tap */
  .v2-stack > .v2-btn { width: 100%; justify-content: center; }
  .v2-row { flex-wrap: wrap; }

  /* Floating chat panel — already full-bleed via its own rule */
}

/* Hamburger — hidden by default, shown by @media phone block above */
.v2-hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--bg-2);
  border: 1px solid var(--bd);
  border-radius: var(--rd-md);
  cursor: pointer;
  color: var(--tx);
  padding: 0;
  flex-shrink: 0;
}
.v2-hamburger:hover { background: var(--bg-1); border-color: var(--accent-h); }
.v2-hamburger svg { width: 18px; height: 18px; }


/* ─── Floating chat panel ─── shared between compose.php and blog.php.
   Docks to the inline-end edge of the viewport (right in LTR, left in
   RTL) so it appears on the opposite side of the editor.            */
.v2-chat-panel {
  position: fixed;
  top: 88px; bottom: 20px;
  right: 20px; left: auto;
  width: 420px;
  max-width: calc(100vw - 40px);
  background: var(--bg-1);
  border: 1px solid var(--bd-h);
  border-radius: var(--rd-lg, 12px);
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 2px 6px -1px rgba(15, 23, 42, .08);
  display: flex;
  flex-direction: column;
  z-index: 60;
  overflow: hidden;
  animation: v2-chat-slide-in-right .18s ease-out;
}
[dir="rtl"] .v2-chat-panel,
html[dir="rtl"] .v2-chat-panel {
  right: auto; left: 20px;
  animation: v2-chat-slide-in-left .18s ease-out;
}
@keyframes v2-chat-slide-in-right {
  from { transform: translateX(24px);  opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes v2-chat-slide-in-left {
  from { transform: translateX(-24px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.v2-chat-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bd);
  background: var(--bg-2);
  display: flex; align-items: center; gap: 10px;
}
.v2-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--bg-1);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.v2-chat-body:empty::before {
  content: 'No messages yet';
  display: block;
  text-align: center;
  color: var(--tx-mut-2);
  font-size: var(--fs-xs);
  padding: 24px 0;
}
.v2-chat-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--bd);
  background: var(--bg-2);
  display: flex; gap: 8px; align-items: flex-end;
}
.v2-chat-foot textarea {
  flex: 1; resize: none;
  font-family: inherit;
  font-size: var(--fs-sm);
  padding: 8px 10px;
  border: 1px solid var(--bd);
  border-radius: var(--rd-sm);
  background: var(--bg-1);
  color: var(--tx);
  line-height: 1.5;
}
.v2-chat-foot textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
@media (max-width: 720px) {
  .v2-chat-panel {
    top: 12px; bottom: 12px;
    left: 12px !important; right: 12px !important;
    width: auto;
  }
}
