/* صيدلية الجود — the whole design system.
 *
 * The shape of this comes from the iOS build of the City Eye app, which is the
 * one Omar liked: an instrument panel rather than a form. Personality comes
 * from CONTRAST, not from an exotic typeface — oversized hairline readouts in
 * monospaced digits, set against tiny wide-tracked uppercase labels. Numerals
 * are always tabular so a ticking clock never makes the layout jump.
 *
 * The colour is NOT the clinic's. City Eye's blues are taken from the eye in
 * its logo and belong to it; a pharmacy reading as a branch of the eye clinic
 * would be wrong, and two apps in the same family that look identical get
 * mixed up. So: a pharmacy green, with a dark green field for the punch card.
 *
 * Built for one hand on a phone, in Arabic, right to left.
 */

:root {
  /* The field — the dark card the punch dial sits in. */
  --field:    #06211A;
  --field-lo: #0C332A;
  --field-hi: #14453A;

  /* Signature green: the pharmacy cross. Used for "in", active, primary. */
  --leaf:   #0E9F6E;
  --leaf-lo:#0B7C55;
  --mint:   #2DD4A7;   /* accents, progress, the live ring */

  --bg:      #F3F8F5;
  --surface: #FFFFFF;
  --ink:     #0B1F1A;
  --muted:   #5F7A72;
  --hair:    #E2EBE7;

  --good: #12A05C;
  --warn: #E2912A;
  --bad:  #D64550;

  --radius: 22px;
  --radius-sm: 14px;
  --gap: 14px;
  --card: 20px;

  /* Safe areas, so the tab bar clears the home indicator. */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #04120E;
    --surface: #0A1D18;
    --ink:     #E8F3EF;
    --muted:   #8AA8A0;
    --hair:    #16302A;
    --field:   #04150F;
    --field-lo:#0A2720;
    --field-hi:#113429;
  }
}
:root[data-theme="dark"] {
  --bg: #04120E; --surface: #0A1D18; --ink: #E8F3EF;
  --muted: #8AA8A0; --hair: #16302A;
  --field: #04150F; --field-lo: #0A2720; --field-hi: #113429;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The `hidden` attribute must actually hide. Without this, .login-wrap's own
   `display: flex` beats the browser's `[hidden] { display: none }` and every
   signed-in person gets a dead sign-in form sitting above the app. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  /* Never let a mis-swipe bounce the whole page; the lists scroll, not the app. */
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

/* Digits that do not jitter. Every time, duration and count uses this. */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ------------------------------------------------------------- typography */

.readout { font-size: 54px; font-weight: 200; letter-spacing: -1px; line-height: 1.05; }
.figure  { font-size: 30px; font-weight: 200; line-height: 1.1; }
.figure-s{ font-size: 21px; font-weight: 300; line-height: 1.15; }

.eyebrow {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--muted);
  text-transform: uppercase;
}
.display { font-size: 25px; font-weight: 600; letter-spacing: -0.3px; }
.title   { font-size: 16px; font-weight: 600; }
.small   { font-size: 13px; }
.tiny    { font-size: 11.5px; }
.muted   { color: var(--muted); }

/* ------------------------------------------------------------------ shell */

#app { min-height: 100vh; min-height: 100dvh; }

.screen { display: none; }
.screen.on { display: block; }

.scroll {
  padding: calc(var(--safe-t) + 10px) 16px calc(78px + var(--safe-b));
  max-width: 560px;
  margin: 0 auto;
}

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin: 6px 2px 18px;
}
.topbar .sub { margin-top: 2px; }

/* The tab bar. Five is too many to read at a glance, so the owner's extra
   screens live behind the staff tab rather than as tabs of their own. */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--hair);
}
.tab {
  flex: 1 1 0; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px 4px;
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600;
  border-radius: 12px;
  transition: color .18s;
}
.tab svg { width: 23px; height: 23px; stroke-width: 1.7; }
.tab.on { color: var(--leaf); }
.tab:active { background: var(--hair); }

/* ------------------------------------------------------------------ cards */

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--card);
  margin-bottom: var(--gap);
}
.panel.tight { padding: 14px 16px; }
.panel.flush { padding: 6px 0; }

.field {
  background: linear-gradient(170deg, var(--field-hi), var(--field) 58%);
  border-radius: 26px;
  padding: 26px 20px 22px;
  margin-bottom: var(--gap);
  color: #EAF6F1;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.field .eyebrow { color: #7FB9A5; }

/* ------------------------------------------------------- the punch dial */

.dial { position: relative; width: 212px; height: 212px; margin: 4px auto 14px; }
.dial svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.dial .track { fill: none; stroke: rgba(255,255,255,.09); stroke-width: 6; }
.dial .arc {
  fill: none; stroke: var(--mint); stroke-width: 6; stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.3,.8,.3,1);
}
.dial .hit {
  position: absolute; inset: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  border: 0; border-radius: 50%;
  background: var(--field-lo);
  color: #EAF6F1; font: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: transform .12s, background .2s;
}
.dial .hit:active { transform: scale(.965); }
.dial .hit:disabled { opacity: .55; cursor: default; }
.dial.in .hit { background: var(--leaf-lo); }

/* A quiet pulse while clocked in: alive, but it is one element with one
   compositor-only property. The Android build once drew a breathing iris on
   every frame and the app froze outright; this is the lesson from it. */
.dial.in .halo {
  position: absolute; inset: 14px; border-radius: 50%;
  border: 1px solid var(--mint); opacity: .5;
  animation: halo 2.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes halo {
  0%, 100% { transform: scale(1);    opacity: .45; }
  50%      { transform: scale(1.04); opacity: .12; }
}
@media (prefers-reduced-motion: reduce) {
  .dial.in .halo { animation: none; }
  .dial .arc { transition: none; }
}

.dial .verb { font-size: 13px; font-weight: 600; letter-spacing: .4px; }

/* -------------------------------------------------------------- the chips */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--hair); color: var(--muted);
  white-space: nowrap;
}
.chip.ok   { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.chip.warn { background: color-mix(in srgb, var(--warn) 17%, transparent); color: var(--warn); }
.chip.bad  { background: color-mix(in srgb, var(--bad) 14%, transparent);  color: var(--bad); }
.chip.leaf { background: color-mix(in srgb, var(--leaf) 15%, transparent); color: var(--leaf); }
.chip.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
.field .chip { background: rgba(255,255,255,.1); color: #BFE4D6; }
.field .chip.ok  { background: rgba(45,212,167,.16); color: var(--mint); }
.field .chip.bad { background: rgba(214,69,80,.2);  color: #FFB3B8; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* --------------------------------------------------------------- the rows */

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hair);
  text-align: start;
}
.row:last-child { border-bottom: 0; }
.row .lead { flex: 1 1 auto; min-width: 0; }
.row .trail { text-align: end; flex: none; }
.row.tap { cursor: pointer; border: 0; background: none; width: 100%; font: inherit; color: inherit;
           border-bottom: 1px solid var(--hair); }
.row.tap:last-child { border-bottom: 0; }
.row.tap:active { background: var(--bg); }
.row .name { font-weight: 500; }
.row .chev { color: var(--muted); flex: none; }
.row.off .lead { color: var(--muted); }

/* A day in the attendance list. */
.day-date { width: 52px; flex: none; }
.day-date .d { font-size: 19px; font-weight: 300; line-height: 1; }
.day-date .m { font-size: 10.5px; color: var(--muted); }

/* ----------------------------------------------------------- stat cluster */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat { text-align: center; padding: 4px 2px; }
.stat .v { font-size: 20px; font-weight: 300; line-height: 1.2; }
.stat .k { font-size: 10px; color: var(--muted); letter-spacing: .3px; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v  { color: var(--bad); }
.stat.good .v { color: var(--good); }

/* ------------------------------------------------------------- the inputs */

label.lbl { display: block; margin: 0 2px 6px; }
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  margin-bottom: 12px;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--leaf) 45%, transparent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--leaf); color: #fff;
  font-weight: 600; cursor: pointer;
  transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--leaf); border: 1px solid var(--hair); }
.btn.quiet { background: var(--hair); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 11px; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { width: auto; flex: 1 1 0; }

/* --------------------------------------------------------------- the login */

.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 32px 22px calc(32px + var(--safe-b));
  background: linear-gradient(165deg, var(--field-hi), var(--field) 60%);
  color: #EAF6F1;
}
.login-wrap .card {
  width: 100%; max-width: 380px; margin: 0 auto;
  background: var(--surface); color: var(--ink);
  border-radius: 24px; padding: 24px 20px 20px;
}
.login-wrap .mark { text-align: center; margin-bottom: 22px; }
.login-wrap .mark svg { width: 56px; height: 56px; }
.login-wrap .mark .nm { font-size: 20px; font-weight: 600; margin-top: 8px; }
.login-wrap .mark .tl { font-size: 12.5px; color: #8FC4B2; }

/* Login inputs must read as inputs even on the dark card behind them —
   staff reported typing into what looked like plain text on the clinic app. */
.login-wrap .card input { background: var(--bg); border-color: var(--hair); }

/* ---------------------------------------------------------------- sheets */

.sheet-bg {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4,18,14,.45);
  backdrop-filter: blur(2px);
  display: none;
}
.sheet-bg.on { display: block; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 61;
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b));
  max-height: 88vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.3,.9,.3,1);
}
.sheet.on { transform: translateY(0); }
.sheet .grab { width: 38px; height: 4px; border-radius: 99px; background: var(--hair); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }

/* ---------------------------------------------------------------- toasts */

#toast {
  position: fixed; inset-inline: 0; bottom: calc(92px + var(--safe-b)); z-index: 80;
  display: flex; justify-content: center; pointer-events: none;
}
#toast .t {
  background: var(--field); color: #EAF6F1;
  padding: 11px 18px; border-radius: 14px;
  font-size: 13.5px; font-weight: 500;
  max-width: 88%;
  box-shadow: 0 8px 28px rgba(4,18,14,.3);
  animation: rise .26s ease both;
}
#toast .t.bad { background: var(--bad); }
#toast .t.ok  { background: var(--leaf-lo); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------ empty/load */

.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .45; margin-bottom: 8px; }

.skel {
  background: linear-gradient(90deg, var(--hair), color-mix(in srgb, var(--hair) 45%, var(--surface)), var(--hair));
  background-size: 220% 100%;
  border-radius: 8px; height: 13px;
  animation: slide 1.3s linear infinite;
}
@keyframes slide { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

.mono-s { font-size: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--hair); margin: 14px 0; }

/* The audit trail's before/after. Deliberately plain and dense: it is read
   when something has gone wrong and the question is exactly what changed. */
.diff { font-size: 12px; margin-top: 6px; }
.diff div { display: flex; gap: 8px; }
.diff .k { color: var(--muted); min-width: 64px; }
.diff .was { color: var(--bad); text-decoration: line-through; }
.diff .now { color: var(--good); }
