/* =====================================================================
   IDIEQ Makerspace · Attendance
   Theme: clean, precise, premium, architectural, airy, glassmorphism
   Accent: #1EA9FE (used sparingly)
   ===================================================================== */

/* ----------------------------- Tokens ----------------------------- */
:root {
  /* Brand */
  --accent: #1EA9FE;
  --accent-ink: #0a6dad;      /* darker accent for text on light */
  --accent-soft: rgba(30, 169, 254, 0.12);
  --accent-line: rgba(30, 169, 254, 0.35);

  /* Neutrals (light, airy) */
  --bg: #f6f7f9;
  --ink: #14171c;             /* primary text */
  --ink-2: #5c636e;           /* secondary text */
  --ink-3: #9aa1ab;           /* tertiary / hints */
  --line: rgba(20, 23, 28, 0.08);
  --line-strong: rgba(20, 23, 28, 0.14);

  /* Glass surfaces */
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.70);
  --glass-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.08);
  --card-bg: #ffffff;

  /* Status colors */
  --ok: #1f9d5b;
  --ok-soft: rgba(31, 157, 91, 0.12);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, 0.12);
  --danger: #d1393b;
  --danger-soft: rgba(209, 57, 59, 0.10);

  /* Geometry */
  --r-card: 22px;
  --r-btn: 14px;
  --r-input: 13px;
  --r-pill: 999px;

  /* Spacing scale (8px grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Safe areas (notches) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --ink: #eef1f5;
    --ink-2: #aab1bd;
    --ink-3: #6b7280;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --glass-bg: rgba(28, 32, 38, 0.55);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
    --card-bg: #16191e;
    --accent-soft: rgba(30, 169, 254, 0.18);
  }
}

/* ----------------------------- Reset ----------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

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

/* --------------------------- Backdrop --------------------------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.backdrop__grid {
  position: absolute; inset: -2px;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 78%);
          mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 78%);
  opacity: 0.7;
}
.backdrop__glow {
  position: absolute; top: -22vh; right: -18vw;
  width: 70vw; height: 70vw; max-width: 620px; max-height: 620px;
  background: radial-gradient(circle at 50% 50%, var(--accent-soft), transparent 62%);
  filter: blur(8px);
}

/* ----------------------------- App ----------------------------- */
.app { min-height: 100dvh; }
.screen { min-height: 100dvh; }
[hidden] { display: none !important; }

/* ------------------------- Glass + Card ------------------------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
          backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.card { border-radius: var(--r-card); }

/* ----------------------------- Login ----------------------------- */
.screen--login {
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--s-6) + var(--safe-t)) var(--s-5) calc(var(--s-6) + var(--safe-b));
}
.login { width: 100%; max-width: 400px; }
.brand {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-6); padding-left: var(--s-1);
}
.brand__logo {
  width: 48px; height: 48px; object-fit: contain; border-radius: 12px;
}
.brand__name { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.brand__tag { font-size: 0.8rem; color: var(--ink-2); letter-spacing: 0.06em; text-transform: uppercase; }

.login__card { padding: var(--s-6) var(--s-5); }
.login__title { font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; }
.login__subtitle { margin-top: var(--s-2); color: var(--ink-2); font-size: 0.92rem; }
.login__card .field:first-of-type { margin-top: var(--s-5); }
.login__hint {
  margin-top: var(--s-4); text-align: center;
  color: var(--ink-3); font-size: 0.8rem; line-height: 1.6;
}

/* ----------------------------- Fields ----------------------------- */
.field { margin-bottom: var(--s-4); }
.field__label {
  display: block; margin-bottom: var(--s-2);
  font-size: 0.82rem; font-weight: 500; color: var(--ink-2);
}
.field__wrap { position: relative; }
.field__input {
  width: 100%; padding: 13px 15px; font-size: 16px; /* 16px avoids iOS zoom */
  color: var(--ink); background: var(--card-bg);
  border: 1px solid var(--line-strong); border-radius: var(--r-input);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field__input::placeholder { color: var(--ink-3); }
.field__input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.field__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  padding: 8px 10px; border: none; background: transparent;
  color: var(--ink-2); font-size: 0.8rem; font-weight: 500; border-radius: 8px;
}
.field__toggle:hover { color: var(--ink); }

.form-error {
  margin: calc(var(--s-2) * -1) 0 var(--s-4); padding: 10px 12px;
  font-size: 0.85rem; color: var(--danger);
  background: var(--danger-soft); border-radius: 10px;
}

/* ----------------------------- Buttons ----------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2); padding: 12px 18px; border: 1px solid transparent;
  border-radius: var(--r-btn); font-size: 0.95rem; font-weight: 600;
  color: var(--ink); background: transparent; letter-spacing: -0.01em;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease),
              border-color 0.18s var(--ease), opacity 0.18s var(--ease), color 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn--block { width: 100%; }
.btn--lg { padding: 16px 20px; font-size: 1rem; }
.btn--sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }

.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(30,169,254,0.28); }
.btn--primary:hover:not(:disabled) { background: #14a0f7; }

.btn--outline { background: var(--card-bg); color: var(--ink); border-color: var(--line-strong); }
.btn--outline:hover:not(:disabled) { border-color: var(--ink-3); }

.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--line); color: var(--ink); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Inline icon inside a button (e.g. the WhatsApp glyph) */
.btn__icon { width: 18px; height: 18px; flex: none; }

/* Loading state on buttons */
.btn .spinner { display: none; }
.btn.is-loading .btn__label { visibility: hidden; }
.btn.is-loading .spinner {
  display: block; position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------- Dashboard --------------------------- */
.screen--dashboard { display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--s-3) + var(--safe-t)) var(--s-4) var(--s-3);
  border-radius: 0; border-left: none; border-right: none; border-top: none;
}
.topbar__brand { display: flex; align-items: center; gap: var(--s-2); }
.topbar__logo { width: 26px; height: 26px; object-fit: contain; border-radius: 7px; }
.topbar__name { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }

.dash {
  flex: 1; width: 100%; max-width: 480px; margin: 0 auto;
  padding: var(--s-5) var(--s-4) var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.dash__greeting { padding: 0 var(--s-1); }
.dash__hello { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.dash__role { margin-top: 2px; color: var(--ink-2); font-size: 0.9rem; }

/* Clock */
.clock { padding: var(--s-5); text-align: center; }
.clock__label {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.clock__time {
  margin-top: var(--s-2); font-size: 2.7rem; font-weight: 600;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.clock__date { margin-top: var(--s-1); color: var(--ink-2); font-size: 0.92rem; }

/* Status */
.status { padding: var(--s-5); }
.status__head { display: flex; align-items: center; justify-content: space-between; }
.status__title { font-size: 1.05rem; font-weight: 600; }
.status__body { margin-top: var(--s-4); display: flex; align-items: stretch; gap: var(--s-4); }
.stamp { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.stamp__label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.stamp__value { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.divider { width: 1px; background: var(--line); align-self: stretch; }

/* Status pill */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: var(--r-pill);
  font-size: 0.78rem; font-weight: 600;
  background: var(--line); color: var(--ink-2);
}
.pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.pill[data-state="none"]    { background: var(--warn-soft);   color: var(--warn); }
.pill[data-state="none"] .pill__dot   { background: var(--warn); }
.pill[data-state="in"]      { background: var(--accent-soft); color: var(--accent-ink); }
.pill[data-state="in"] .pill__dot     { background: var(--accent); animation: pulse 2s var(--ease) infinite; }
.pill[data-state="out"]     { background: var(--ok-soft);     color: var(--ok); }
.pill[data-state="out"] .pill__dot    { background: var(--ok); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Inline error */
.inline-error {
  margin-top: var(--s-4); display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); padding: 12px 14px; border-radius: 12px;
  background: var(--danger-soft);
}
.inline-error__text { font-size: 0.85rem; color: var(--danger); }

/* Actions */
.actions { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-1); }
.actions__note { text-align: center; color: var(--ink-2); font-size: 0.88rem; padding-top: var(--s-1); }

/* Dock (More options) */
.dock {
  position: sticky; bottom: 0; z-index: 9;
  padding: var(--s-3) var(--s-4) calc(var(--s-3) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}
.dock__btn { border: 1px solid var(--line-strong); background: var(--card-bg); color: var(--ink); }
.dock__btn:hover { border-color: var(--ink-3); background: var(--card-bg); }

/* --------------------------- Skeletons --------------------------- */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--line) 30%, var(--line-strong) 50%, var(--line) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s var(--ease) infinite;
}
.skeleton--row { height: 34px; flex: 1; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ------------------------- Bottom sheet ------------------------- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 13, 18, 0.42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.sheet-overlay.is-open { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  padding: 0 var(--s-3) calc(var(--s-3) + var(--safe-b));
  transform: translateY(102%); transition: transform 0.32s var(--ease);
}
.sheet.is-open { transform: translateY(0); }
.sheet__panel {
  max-width: 480px; margin: 0 auto;
  padding: var(--s-3) var(--s-4) var(--s-4);
  border-radius: 24px 24px 0 0;
}
@media (min-width: 520px) { .sheet__panel { border-radius: 24px; margin-bottom: var(--s-3); } }
.sheet__grab {
  width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong);
  margin: 2px auto var(--s-3);
}
.sheet__title { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); padding: 0 var(--s-1) var(--s-3); }

.sheet__item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-4); margin-bottom: var(--s-2);
  background: var(--card-bg); border: 1px solid var(--line); border-radius: 16px;
  text-align: left; transition: border-color 0.18s var(--ease), transform 0.12s var(--ease);
}
.sheet__item:hover { border-color: var(--line-strong); }
.sheet__item:active { transform: scale(0.99); }
.sheet__item-main { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sheet__item-title { font-size: 0.98rem; font-weight: 600; color: var(--ink); }
.sheet__item-sub { font-size: 0.82rem; color: var(--ink-2); }
.sheet__item-chevron { font-size: 1.4rem; color: var(--ink-3); line-height: 1; }
.sheet__cancel { margin-top: var(--s-2); }

/* ------------------- Checkout work-log modal ------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 13, 18, 0.46);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.modal-overlay.is-open { opacity: 1; }

.modal {
  position: fixed; inset: 0; z-index: 51;
  display: flex; align-items: flex-end; justify-content: center;
  padding: var(--s-4) var(--s-3) calc(var(--s-3) + var(--safe-b));
  pointer-events: none;
}
@media (min-width: 520px) { .modal { align-items: center; padding-bottom: var(--s-4); } }

.modal__panel {
  pointer-events: auto; position: relative;
  width: 100%; max-width: 480px;
  padding: var(--s-5);
  border-radius: 24px;
  transform: translateY(16px) scale(0.985); opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.modal.is-open .modal__panel { transform: translateY(0) scale(1); opacity: 1; }

.modal__close {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: transparent; color: var(--ink-3); font-size: 1.5rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.modal__close:hover:not(:disabled) { background: var(--line); color: var(--ink); }

.modal__title { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; padding-right: var(--s-5); }
.modal__sub { margin-top: var(--s-2); color: var(--ink-2); font-size: 0.9rem; }
.modal__field { margin-top: var(--s-4); margin-bottom: 0; }

.field__textarea {
  display: block; width: 100%; min-height: 124px;
  resize: vertical; line-height: 1.5; font-family: inherit;
}

.modal__meta {
  margin-top: var(--s-2);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  min-height: 18px;
}
.modal__nudge { font-size: 0.82rem; line-height: 1.45; color: var(--warn); flex: 1; }
.modal__count {
  font-size: 0.8rem; color: var(--ink-3);
  font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px;
}
.modal__count.is-over { color: var(--danger); font-weight: 600; }

.modal__actions { margin-top: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
/* Soft hint that the note is over the limit (Save is blocked in JS too). */
.modal.is-over #checkout-save { opacity: 0.5; }

/* ----------------------------- Toasts ----------------------------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-4) calc(var(--s-5) + var(--safe-b)); pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 440px; width: 100%;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 13px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  transform: translateY(14px); opacity: 0;
  transition: transform 0.28s var(--ease), opacity 0.28s var(--ease);
}
.toast.is-in { transform: translateY(0); opacity: 1; }
.toast--ok   { background: var(--ok); }
.toast--err  { background: var(--danger); }
.toast--warn { background: var(--warn); }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.85); flex: none; }

/* ------------------- More-options accordion ------------------- */
.acc-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.acc-item {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.18s var(--ease);
}

.acc-item:focus-within {
  border-color: var(--accent-line);
}

.acc-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 64px;
  padding: var(--s-4);
  background: transparent;
  border: none;
  text-align: left;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease);
}

.acc-trigger:hover:not(:disabled) { background: var(--line); }
.acc-trigger:active:not(:disabled) { transform: scale(0.99); }

.acc-trigger__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.acc-trigger__title { font-size: 0.98rem; font-weight: 600; color: var(--ink); }
.acc-trigger__sub   { font-size: 0.82rem; color: var(--ink-2); }

.acc-chevron {
  flex-shrink: 0;
  color: var(--ink-3);
  transition: transform 0.2s var(--ease);
}

.acc-trigger[aria-expanded="true"] .acc-chevron { transform: rotate(180deg); }

/* Grid-based smooth expand / collapse */
.acc-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s var(--ease);
}

.acc-panel.is-open { grid-template-rows: 1fr; }

.acc-panel__inner {
  overflow: hidden;
  padding: 0 var(--s-4) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Reset field margin inside accordion (gap handles spacing) */
.acc-panel__inner .field { margin-bottom: 0; }

.acc-panel__counter {
  float: right;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  transition: color 0.18s var(--ease);
}
.acc-panel__counter.is-near { color: var(--warn); }
.acc-panel__counter.is-max  { color: var(--danger); font-weight: 600; }

.acc-panel__error {
  margin: 0;
  padding: 9px 12px;
  font-size: 0.84rem;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
}

.field__textarea--sm {
  display: block;
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
  font-family: inherit;
}

/* --------------------------- Desktop --------------------------- */
@media (min-width: 720px) {
  .clock__time { font-size: 3rem; }
}

/* ----------------------- Reduced motion ----------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
