/* ============================================================================
   FaceCheck — Light Control Center · base + reusable components
   Loaded after lc-tokens.css. Everything here is direction-agnostic:
   logical properties only (margin-inline / inset-inline / text-align:start …)
   so the same rules serve  dir="rtl" (Arabic, default)  and  dir="ltr".
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--lc-ground);
}

body {
  font-family: var(--lc-font);
  font-size: var(--lc-fs-base);
  line-height: var(--lc-lh-base);
  color: var(--lc-ink);
  background: var(--lc-ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--lc-font-display); line-height: var(--lc-lh-tight); font-weight: var(--lc-fw-bold); color: var(--lc-ink); letter-spacing: -0.02em; }
h1 { font-size: var(--lc-fs-xl); letter-spacing: -0.01em; }
h2 { font-size: var(--lc-fs-lg); }
h3 { font-size: var(--lc-fs-md); font-weight: var(--lc-fw-semi); }

a { color: var(--lc-indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--lc-primary); outline-offset: 2px; border-radius: var(--lc-r-xs); }

::selection { background: rgba(79, 70, 229, .20); }

/* Numbers / times / durations stay LTR-internal even in an RTL context. */
.lc-num, bdi { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

.lc-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── App frame ──────────────────────────────────────────────────────────── */
.lc-app {
  display: grid;
  grid-template-columns: var(--lc-sidebar-w) 1fr;
  min-height: 100vh;
}
.lc-body { display: flex; flex-direction: column; min-width: 0; }
.lc-main {
  flex: 1;
  padding: var(--lc-6);
  max-width: var(--lc-content-max);
  width: 100%;
  margin-inline: auto;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.lc-sidebar {
  background: var(--lc-surface);
  border-inline-end: 1px solid var(--lc-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.lc-brand {
  display: flex; align-items: center; gap: var(--lc-2);
  padding: var(--lc-5) var(--lc-5) var(--lc-4);
  font-weight: var(--lc-fw-bold); font-size: var(--lc-fs-md);
  color: var(--lc-ink); text-decoration: none;
}
.lc-brand:hover { text-decoration: none; }
.lc-brand-mark {
  width: 26px; height: 26px; flex-shrink: 0;
  color: var(--lc-primary);
}
.lc-nav { flex: 1; padding: var(--lc-2) var(--lc-3); display: flex; flex-direction: column; gap: 2px; }
.lc-nav-item {
  display: flex; align-items: center; gap: var(--lc-3);
  padding: var(--lc-2) var(--lc-3);
  border-radius: var(--lc-r-md);
  color: var(--lc-ink-2);
  font-size: var(--lc-fs-base); font-weight: var(--lc-fw-medium);
  text-decoration: none;
  transition: background var(--lc-transition), color var(--lc-transition);
  white-space: nowrap;
}
.lc-nav-item:hover { background: var(--lc-ground-2); color: var(--lc-ink); text-decoration: none; }
.lc-nav-item[aria-current="page"] { background: var(--lc-primary-wash); color: var(--lc-primary-ink); font-weight: var(--lc-fw-semi); }
.lc-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.lc-nav-label { flex: 1; }
.lc-nav-item--muted { color: var(--lc-ink-3); }
.lc-nav-divider { height: 1px; background: var(--lc-border-2); margin: var(--lc-2) var(--lc-3); }
.lc-nav-soon {
  font-size: 0.625rem; font-weight: var(--lc-fw-bold);
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--lc-ink-3); background: var(--lc-ground-2);
  border-radius: var(--lc-r-xs); padding: 1px 6px;
}
.lc-sidebar-foot {
  padding: var(--lc-3) var(--lc-5);
  border-top: 1px solid var(--lc-border-2);
  font-size: var(--lc-fs-xs); color: var(--lc-ink-3);
  display: flex; align-items: center; gap: var(--lc-2);
}
.lc-foot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lc-ink-3); flex-shrink: 0; }
.lc-foot-dot--ok { background: var(--lc-live); }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.lc-topbar {
  height: var(--lc-topbar-h);
  background: var(--lc-surface);
  border-bottom: 1px solid var(--lc-border);
  display: flex; align-items: center; gap: var(--lc-3);
  padding-inline: var(--lc-6);
  position: sticky; top: 0; z-index: 20;
}
.lc-topbar h1 { font-size: var(--lc-fs-md); font-weight: var(--lc-fw-semi); }
.lc-topbar-spacer { flex: 1; }
.lc-hamburger { display: none; }
.lc-lang-toggle {
  display: inline-flex; background: var(--lc-ground-2); border: 1px solid var(--lc-border);
  border-radius: var(--lc-r-pill); padding: 3px; gap: 2px;
}
.lc-lang-toggle button {
  border: 0; background: transparent; cursor: pointer;
  font-size: var(--lc-fs-sm); font-weight: var(--lc-fw-semi); color: var(--lc-ink-2);
  padding: 4px 12px; border-radius: var(--lc-r-pill);
}
.lc-lang-toggle button[aria-pressed="true"] { background: var(--lc-surface); color: var(--lc-primary); box-shadow: var(--lc-shadow-xs); }

/* ── Card / panel ───────────────────────────────────────────────────────── */
.lc-card {
  background: var(--lc-surface);
  border: 1px solid var(--lc-border);
  border-radius: var(--lc-r-lg);
  box-shadow: var(--lc-shadow-sm);
}
.lc-panel { overflow: hidden; }
.lc-panel-head {
  display: flex; align-items: center; gap: var(--lc-3); flex-wrap: wrap;
  padding: var(--lc-4) var(--lc-5);
  border-bottom: 1px solid var(--lc-border-2);
}
.lc-panel-title {
  font-size: var(--lc-fs-md); font-weight: var(--lc-fw-bold);
  display: flex; align-items: center; gap: var(--lc-2);
}
.lc-panel-tools { margin-inline-start: auto; display: flex; align-items: center; gap: var(--lc-2); flex-wrap: wrap; }

.lc-count-badge {
  font-size: var(--lc-fs-sm); font-weight: var(--lc-fw-semi);
  background: var(--lc-live-wash); color: var(--lc-live-ink);
  border-radius: var(--lc-r-pill); padding: 2px 10px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.lc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--lc-2);
  height: 38px; padding-inline: var(--lc-4);
  border-radius: var(--lc-r-md); border: 1px solid transparent;
  font-size: var(--lc-fs-base); font-weight: var(--lc-fw-semi);
  cursor: pointer; white-space: nowrap;
  transition: background var(--lc-transition), border-color var(--lc-transition), box-shadow var(--lc-transition);
}
.lc-btn--primary { background: var(--lc-primary); color: var(--lc-on-primary); }
.lc-btn--primary:hover { background: var(--lc-primary-hov); }
.lc-btn--ghost { background: var(--lc-surface); color: var(--lc-ink-2); border-color: var(--lc-border); }
.lc-btn--ghost:hover { background: var(--lc-ground-2); color: var(--lc-ink); }
.lc-btn--sm { height: 32px; font-size: var(--lc-fs-sm); padding-inline: var(--lc-3); }
.lc-btn:disabled { opacity: .5; cursor: not-allowed; }

.lc-icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--lc-r-md); border: 1px solid var(--lc-border);
  background: var(--lc-surface); color: var(--lc-ink-2); cursor: pointer;
}
.lc-icon-btn:hover { background: var(--lc-ground-2); color: var(--lc-ink); }
.lc-icon-btn:focus-visible { outline: 2px solid var(--lc-primary); outline-offset: 2px; }

/* Theme toggle — show the icon for the theme you'd switch TO */
.lc-theme-ic { width: 17px; height: 17px; }
.lc-theme-ic--sun { display: none; }               /* light theme → offer dark (moon) */
:root[data-theme="dark"] .lc-theme-ic--moon { display: none; }
:root[data-theme="dark"] .lc-theme-ic--sun  { display: block; }

/* ── Search field ──────────────────────────────────────────────────────── */
.lc-search {
  display: flex; align-items: center; gap: var(--lc-2);
  background: var(--lc-ground); border: 1px solid var(--lc-border);
  border-radius: var(--lc-r-md); padding-inline: var(--lc-3); height: 38px;
  min-width: 220px;
  transition: border-color var(--lc-transition), box-shadow var(--lc-transition);
}
.lc-search:focus-within { border-color: var(--lc-primary); box-shadow: var(--lc-ring); }
.lc-search svg { flex-shrink: 0; color: var(--lc-ink-3); }
.lc-search input {
  border: 0; background: transparent; outline: 0;
  font: inherit; font-size: var(--lc-fs-base); width: 100%; color: var(--lc-ink);
}
.lc-search input::placeholder { color: var(--lc-ink-3); }
.lc-search-clear { border: 0; background: transparent; color: var(--lc-ink-3); cursor: pointer; display: none; padding: 2px; }
.lc-search--filled .lc-search-clear { display: inline-flex; }

/* ── Segmented control (filters, tabs) ─────────────────────────────────── */
.lc-segmented {
  display: inline-flex; background: var(--lc-ground); border: 1px solid var(--lc-border);
  border-radius: var(--lc-r-md); padding: 3px; gap: 2px;
}
.lc-segmented button {
  border: 0; background: transparent; cursor: pointer;
  font-size: var(--lc-fs-sm); font-weight: var(--lc-fw-semi); color: var(--lc-ink-2);
  padding: 5px 12px; border-radius: var(--lc-r-sm);
  display: inline-flex; align-items: center; gap: var(--lc-1);
  white-space: nowrap;
  transition: background var(--lc-transition), color var(--lc-transition);
}
.lc-segmented button:hover { color: var(--lc-ink); }
.lc-segmented button[aria-pressed="true"] { background: var(--lc-surface); color: var(--lc-primary); box-shadow: var(--lc-shadow-xs); }
.lc-segmented button svg { width: 14px; height: 14px; }

/* ── Menu (sort) ───────────────────────────────────────────────────────── */
.lc-menu { position: relative; }
.lc-menu-btn {
  display: inline-flex; align-items: center; gap: var(--lc-2);
  height: 38px; padding-inline: var(--lc-3);
  background: var(--lc-ground); border: 1px solid var(--lc-border); border-radius: var(--lc-r-md);
  font-size: var(--lc-fs-sm); font-weight: var(--lc-fw-semi); color: var(--lc-ink-2); cursor: pointer;
}
.lc-menu-btn:hover { color: var(--lc-ink); }
.lc-menu-btn svg { width: 14px; height: 14px; }
.lc-menu-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px);
  background: var(--lc-surface); border: 1px solid var(--lc-border);
  border-radius: var(--lc-r-md); box-shadow: var(--lc-shadow-md);
  padding: var(--lc-1); min-width: 190px; z-index: 30;
  display: none;
}
.lc-menu[data-open="true"] .lc-menu-list { display: block; }
.lc-menu-list button {
  display: flex; width: 100%; align-items: center; gap: var(--lc-2);
  border: 0; background: transparent; cursor: pointer;
  padding: var(--lc-2) var(--lc-3); border-radius: var(--lc-r-sm);
  font-size: var(--lc-fs-base); color: var(--lc-ink-2); text-align: start;
}
.lc-menu-list button:hover { background: var(--lc-ground-2); color: var(--lc-ink); }
.lc-menu-list button[aria-checked="true"] { color: var(--lc-primary); font-weight: var(--lc-fw-semi); }
.lc-menu-list button[aria-checked="true"]::after { content: ""; margin-inline-start: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--lc-primary); }

/* ── Avatar (monogram) ────────────────────────────────────────────────── */
.lc-avatar {
  --sz: 38px;
  width: var(--sz); height: var(--sz); flex-shrink: 0;
  border-radius: var(--lc-r-md);
  display: grid; place-items: center;
  color: #fff; font-weight: var(--lc-fw-bold);
  font-size: calc(var(--sz) * 0.36);
  line-height: 1; letter-spacing: 0;
  unicode-bidi: isolate;
}
.lc-avatar--lg { --sz: 48px; border-radius: var(--lc-r-lg); }

/* ── Chips ─────────────────────────────────────────────────────────────── */
.lc-chip {
  display: inline-flex; align-items: center; gap: var(--lc-1);
  font-size: var(--lc-fs-xs); font-weight: var(--lc-fw-medium);
  color: var(--lc-ink-2); background: var(--lc-ground-2);
  border: 1px solid var(--lc-border); border-radius: var(--lc-r-sm);
  padding: 2px 8px; white-space: nowrap;
}
.lc-chip--plain { background: transparent; border-color: transparent; padding-inline: 0; }

.lc-dur {
  display: inline-flex; align-items: center; gap: var(--lc-2);
  font-weight: var(--lc-fw-semi); font-size: var(--lc-fs-sm);
  color: var(--lc-live-ink); background: var(--lc-live-wash);
  border-radius: var(--lc-r-sm); padding: 3px 10px;
  unicode-bidi: isolate;
}
.lc-dur-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lc-live); flex-shrink: 0; }

.lc-source {
  display: inline-flex; align-items: center; gap: var(--lc-2);
  color: var(--lc-ink-2); font-size: var(--lc-fs-sm);
}
.lc-source svg { width: 15px; height: 15px; color: var(--lc-ink-3); flex-shrink: 0; }

/* ── Live indicator ───────────────────────────────────────────────────── */
.lc-live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--lc-live);
  box-shadow: 0 0 0 4px var(--lc-live-wash); flex-shrink: 0;
  position: relative;
}
.lc-live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--lc-live); opacity: .5;
  animation: lc-ping 2s cubic-bezier(0, 0, .2, 1) infinite;
}
@media (prefers-reduced-motion: reduce) { .lc-live-dot::after { animation: none; opacity: 0; } }
@keyframes lc-ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }

/* ── Skeleton ─────────────────────────────────────────────────────────── */
.lc-skel {
  background: linear-gradient(90deg, var(--lc-ground-2) 25%, var(--lc-skel-hi) 50%, var(--lc-ground-2) 75%);
  background-size: 200% 100%; border-radius: var(--lc-r-xs);
}
@media (prefers-reduced-motion: no-preference) { .lc-skel { animation: lc-shimmer 1.4s ease infinite; } }
@keyframes lc-shimmer { to { background-position: -200% 0; } }

/* ── State blocks (empty / error / no-results) ────────────────────────── */
.lc-state {
  padding: var(--lc-8) var(--lc-6);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.lc-state-ic {
  width: 44px; height: 44px; border-radius: var(--lc-r-lg); margin-bottom: var(--lc-3);
  display: grid; place-items: center;
  background: var(--lc-ground-2); color: var(--lc-ink-3);
}
.lc-state--error .lc-state-ic { background: var(--lc-danger-wash); color: var(--lc-danger); }
.lc-state h3 { font-size: var(--lc-fs-md); font-weight: var(--lc-fw-bold); margin-bottom: var(--lc-1); }
.lc-state p { color: var(--lc-ink-2); font-size: var(--lc-fs-base); max-width: 42ch; }
.lc-state .lc-btn { margin-top: var(--lc-4); }

/* ── Drawer / bottom sheet ────────────────────────────────────────────── */
.lc-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  opacity: 0; pointer-events: none; transition: opacity var(--lc-transition);
  z-index: 40;
}
.lc-scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
.lc-drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0;
  width: min(380px, 92vw);
  background: var(--lc-surface);
  border-inline-start: 1px solid var(--lc-border);
  box-shadow: var(--lc-shadow-lg);
  transform: translateX(100%);            /* LTR: pinned to the right, hidden off-screen right */
  transition: transform 180ms cubic-bezier(.32, .72, 0, 1);
  z-index: 41;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
:dir(rtl) .lc-drawer { transform: translateX(-100%); }  /* RTL: inline-end is the left edge, hide off-screen left */
.lc-drawer[data-open="true"] { transform: translateX(0); }
.lc-drawer-head {
  display: flex; align-items: center; gap: var(--lc-3);
  padding: var(--lc-5);
  border-bottom: 1px solid var(--lc-border-2);
}
.lc-drawer-head .lc-drawer-close { margin-inline-start: auto; }
.lc-drawer-body { padding: var(--lc-5); flex: 1; }
.lc-field { margin-bottom: var(--lc-4); }
.lc-field-label {
  font-size: var(--lc-fs-xs); font-weight: var(--lc-fw-semi);
  color: var(--lc-ink-3); margin-bottom: 2px; display: block;
}
.lc-field-value { font-size: var(--lc-fs-base); font-weight: var(--lc-fw-medium); color: var(--lc-ink); }
.lc-drawer-actions { display: flex; gap: var(--lc-2); padding: var(--lc-5); border-top: 1px solid var(--lc-border-2); }
.lc-drawer-actions .lc-btn--primary { flex: 1; }

@media (max-width: 640px) {
  .lc-drawer {
    inset-inline: 0; inset-block: auto 0;
    width: auto; max-height: 82vh;
    border-inline-start: 0; border-top: 1px solid var(--lc-border);
    border-start-start-radius: var(--lc-r-lg); border-start-end-radius: var(--lc-r-lg);
    transform: translateY(100%);
  }
  :dir(rtl) .lc-drawer,
  :dir(ltr) .lc-drawer { transform: translateY(100%); }
  .lc-drawer[data-open="true"] { transform: translateY(0); }
}

/* ── Mobile shell ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lc-app { grid-template-columns: 1fr; }
  .lc-sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: var(--lc-sidebar-w); z-index: 50;
    transform: translateX(-100%);
    transition: transform 180ms cubic-bezier(.32, .72, 0, 1);
  }
  /* inset-inline-start:0 already anchors to the right edge in RTL; only the
     hide direction needs to flip (slide off the right instead of the left). */
  :dir(rtl) .lc-sidebar { transform: translateX(100%); }
  .lc-app[data-nav="open"] .lc-sidebar { transform: translateX(0); }
  .lc-hamburger { display: grid; }
  .lc-main { padding: var(--lc-4); }
}
