/* ════════════════════════════════════════════════════════════════
   TherapyFlow · app.css — shared CRM shell + components
   Inherits tokens.css. Every internal screen links BOTH.
   "יוקרה קלינית רגועה" — calm, rich, cinematic-but-restrained.
   RTL-first · logical spacing only.
   ════════════════════════════════════════════════════════════════ */

/* ─── readable text helpers (WCAG: never --muted/--sage on cream for body) ─── */
.t-ink     { color: var(--ink); }
.t-2       { color: var(--ink-2); }       /* secondary readable text */
.t-soft    { color: var(--muted); }        /* decoration / large labels ONLY */
.t-sage    { color: var(--sage-dark); }    /* sage text, AA-safe variant */
.num       { font-variant-numeric: tabular-nums; }

/* ════════════ APP SHELL ════════════ */
.app {
  display: grid;
  grid-template-columns: 268px 1fr;     /* sidebar (right in RTL) + main */
  min-height: 100vh;
}
@media (max-width: 980px){ .app { grid-template-columns: 1fr; } }

/* ─── Sidebar (sits on the right in RTL) ─── */
.side {
  grid-column: 1;
  background: linear-gradient(180deg, var(--cream-2), var(--cream-3));
  border-inline-start: 1px solid var(--line);
  padding: 22px 16px 28px;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
}
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 10px 22px;
}
.side-brand .mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(145deg, var(--sage), var(--sage-deep));
  display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  box-shadow: var(--sh-2);
}
.side-brand .wm { font-family: var(--font-display); font-weight: 700; color: var(--sage-deep); font-size: 1.18rem; line-height: 1; }
.side-brand .sb { font-size: .72rem; color: var(--muted); margin-top: 3px; }

.nav-group { margin-top: 18px; }
.nav-group > .gl {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 500; font-size: .92rem;
  position: relative; cursor: pointer;
  transition: background .2s, color .2s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--sage-tint); color: var(--sage-deep); }
.nav-item.active { background: var(--paper); color: var(--sage-deep); font-weight: 600; box-shadow: var(--sh-1); }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: -16px; top: 50%;
  transform: translateY(-50%); width: 4px; height: 22px; border-radius: 4px;
  background: var(--sage);
}
.nav-item .tag { margin-inline-start: auto; font-size: .68rem; background: var(--sage-soft); color: var(--sage-dark); padding: .15em .5em; border-radius: 999px; font-weight: 700; }

/* ─── Main column ─── */
.main { grid-column: 2; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px;
  background: rgba(253,251,247,.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar h1 { font-size: 1.5rem; margin-inline-end: auto; }
.topbar .crumb { color: var(--muted); font-size: .82rem; font-weight: 500; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 16px; width: 280px;
  color: var(--muted); transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-tint); }
.search input { border: 0; background: none; outline: none; flex: 1; font-family: var(--font-ui); font-size: .9rem; color: var(--ink); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); display: grid; place-items: center; cursor: pointer;
  color: var(--ink-2); position: relative; transition: border-color .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--sage); transform: translateY(-1px); }
.icon-btn .pip { position: absolute; top: 8px; inset-inline-end: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--clay); border: 2px solid var(--paper); }

.avatar { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; box-shadow: var(--sh-1); }

.page { padding: 28px 32px 64px; max-width: 1320px; }

/* ════════════ STAT CARDS ════════════ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 1100px){ .stat-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px){ .stat-grid { grid-template-columns: 1fr; } }

.stat {
  background: var(--paper); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--sh-1);
  position: relative; overflow: hidden;
  transition: box-shadow .3s, transform .3s;
}
.stat:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.stat .lbl { color: var(--ink-2); font-size: .86rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat .lbl .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--sage-tint); color: var(--sage-dark); display: grid; place-items: center; }
.stat .ic svg { width: 17px; height: 17px; }
.stat .val { font-family: var(--font-display); font-weight: 700; font-size: 2.4rem; color: var(--sage-deep); line-height: 1.1; margin-top: 10px; }
.stat .foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.trend { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: .2em .6em; border-radius: 999px; }
.trend.up   { background: var(--sage-soft); color: var(--sage-dark); }
.trend.down { background: #F6E2DD; color: #9E4B3A; }
.stat .spark { position: absolute; inset-block-end: 0; inset-inline: 0; height: 38px; opacity: .9; }

/* ════════════ PANELS / SECTION HEADERS ════════════ */
.panel { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.panel-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-h h3 { font-size: 1.15rem; margin-inline-end: auto; }
.panel-h .link { color: var(--sage-dark); font-weight: 600; font-size: .85rem; cursor: pointer; }

/* ════════════ DATA TABLE ════════════ */
.table-wrap { overflow: auto; border-radius: var(--r-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data thead th {
  position: sticky; top: 0; background: var(--cream-2);
  text-align: start; font-weight: 700; color: var(--ink-2);
  font-size: .78rem; letter-spacing: .03em; padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
table.data tbody td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); color: var(--ink); height: 54px; }
table.data tbody tr { transition: background .18s; }
table.data tbody tr:hover { background: var(--sage-tint); }
table.data tbody tr:last-child td { border-bottom: 0; }
.cell-user { display: flex; align-items: center; gap: 11px; }
.cell-user img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.cell-user .nm { font-weight: 600; color: var(--sage-deep); }
.cell-user .su { font-size: .78rem; color: var(--muted); }
.row-act { opacity: 0; display: inline-flex; gap: 6px; transition: opacity .18s; }
tr:hover .row-act { opacity: 1; }

/* ════════════ FORM FIELDS ════════════ */
.field { display: block; margin-bottom: 16px; }
.field > .fl { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.input, .select, textarea.input {
  width: 100%; font-family: var(--font-ui); font-size: .94rem; color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 14px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--sage); box-shadow: 0 0 0 4px var(--sage-tint); }

/* ─── Segmented control ─── */
.seg { display: inline-flex; background: var(--cream-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: none; font-family: var(--font-ui); font-weight: 600; font-size: .85rem; color: var(--ink-2); padding: 7px 16px; border-radius: 999px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--paper); color: var(--sage-deep); box-shadow: var(--sh-1); }

/* ════════════ MOTION VOCABULARY ════════════ */
/* Three reusable, restrained patterns — the "house style" of movement. */
@media (prefers-reduced-motion: no-preference){
  [data-rise]  { opacity: 0; transform: translateY(22px); }
  [data-fade]  { opacity: 0; }
  [data-scale] { opacity: 0; transform: scale(.96); }
}
.in { opacity: 1 !important; transform: none !important; transition: opacity .7s cubic-bezier(.2,.7,.3,1), transform .7s cubic-bezier(.2,.7,.3,1); }

/* soft floating accent used sparingly behind heroes */
@keyframes floaty { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-14px); } }
.floaty { animation: floaty 9s ease-in-out infinite; }

/* ════════════ UX AFFORDANCE LAYER (uniform on every page) ════════════ */
/* consistent page header: title + subtitle + primary action */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .ph-t h1 { font-size: 1.9rem; }
.page-head .ph-t .sub { color: var(--ink-2); font-size: .92rem; margin-block-start: 4px; }
.page-head .ph-act { margin-inline-start: auto; display: flex; gap: 10px; align-items: center; }

/* keyboard hint chip */
.kbd { font-family: var(--font-ui); font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--cream-2); border: 1px solid var(--line); border-radius: 6px; padding: .12em .45em; line-height: 1; }

/* alert card (keeps real warnings like series-ending) */
.alert { display: flex; gap: 13px; align-items: flex-start; padding: 16px 18px; border-radius: 14px; border: 1px solid; margin-bottom: 14px; }
.alert .ai { flex: none; width: 24px; height: 24px; margin-block-start: 1px; }
.alert.warn { background: #FAF4E6; border-color: #EBD9A8; color: #7A5E1E; }
.alert.bad  { background: #F7E7E1; border-color: #E6C2B5; color: #8A4030; }
.alert h4 { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin-bottom: 6px; color: inherit; }
.alert .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 6px; }
.alert .chips .c { background: rgba(255,255,255,.65); border-radius: 999px; padding: .22em .7em; font-size: .78rem; font-weight: 600; }

/* tooltip on any [data-tip] */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; inset-block-end: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(50%); background: var(--sage-deep); color: #fff; font-size: .72rem; font-weight: 500; padding: .4em .7em; border-radius: 8px; white-space: nowrap; z-index: 60; box-shadow: var(--sh-2); pointer-events: none; }

/* clickable stat card → reveals a go-arrow on hover */
.stat.clickable { cursor: pointer; }
.stat .go { position: absolute; inset-block-start: 18px; inset-inline-start: 18px; opacity: 0; color: var(--sage); transition: opacity .2s, transform .2s; }
.stat .go svg { width: 18px; height: 18px; }
.stat.clickable:hover .go { opacity: 1; transform: translateX(-3px); }

/* designed empty-state */
.empty { text-align: center; padding: 48px 20px; }
.empty .ei { width: 64px; height: 64px; border-radius: 20px; background: var(--sage-tint); color: var(--sage); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .ei svg { width: 30px; height: 30px; }
.empty p { color: var(--muted); font-size: 1rem; margin-bottom: 16px; }
