/* ============================================================
   SPOJAK Dochádzka — design system v2.0
   Tmavá téma · kioskový režim · brutálne jednoduché Swiss UX
   ============================================================ */

:root {
  /* Farby */
  --bg:            #09090b;   /* zinc-950 */
  --text:          #f4f4f5;   /* zinc-100 */
  --muted:         #71717a;   /* zinc-500 */
  --muted-2:       #52525b;   /* zinc-600 */
  --accent:        #1D9E75;   /* emerald */
  --accent-soft:   rgba(29,158,117,0.12);
  --accent-glow:   rgba(29,158,117,0.30);
  --work-dot:      #34d399;   /* emerald-400 — "v práci" */
  --border:        rgba(255,255,255,0.04);
  --border-strong: rgba(255,255,255,0.08);
  --surface:       rgba(255,255,255,0.018);
  --surface-2:     rgba(255,255,255,0.035);

  /* Kategórie dlaždíc */
  --cat-work:      #1D9E75;   /* zelená  — pracovné */
  --cat-plan:      #38bdf8;   /* modrá   — plánované */
  --cat-health:    #fbbf24;   /* jantár  — zdravotné */
  --cat-other:     #a1a1aa;   /* sivá    — ostatné */

  --radius:    20px;
  --radius-sm: 14px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

::selection { background: var(--accent-glow); color: #fff; }

.mono { font-family: 'DM Mono', ui-monospace, monospace; }

/* ---------- Pozadie ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-glow-top, .bg-glow-bottom {
  position: fixed; left: 50%; transform: translateX(-50%);
  z-index: 0; pointer-events: none; width: 120vw; height: 70vh;
}
.bg-glow-top    { top: -25vh;    background: radial-gradient(ellipse at center, rgba(29,158,117,0.08), transparent 60%); }
.bg-glow-bottom { bottom: -30vh; background: radial-gradient(ellipse at center, rgba(56,189,248,0.04), transparent 60%); }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100dvh;
  padding: clamp(16px, 2.2vw, 32px);
  padding-top: max(clamp(16px,2.2vw,32px), env(safe-area-inset-top));
  gap: clamp(14px, 1.8vh, 26px);
}

/* ---------- Hlavička ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: clamp(15px, 1.4vw, 20px); letter-spacing: .2px; }
.brand-name { color: var(--muted); font-weight: 500; }
.brand-name strong { color: var(--text); font-weight: 700; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 16px var(--accent-glow);
}
.clock {
  font-family: 'DM Mono', monospace; font-weight: 500;
  font-size: clamp(26px, 3.4vw, 46px); letter-spacing: 1px;
  margin: 0 auto; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.net-pill, .sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
}
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--work-dot); box-shadow: 0 0 8px var(--work-dot); }
.net-pill.is-offline { color: #fca5a5; }
.net-pill.is-offline .net-dot { background: #f87171; box-shadow: 0 0 8px #f87171; }
.sync-pill { color: var(--cat-plan); }
.sync-pill.is-zero { opacity: .45; color: var(--muted); }

.admin-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 20px; cursor: pointer;
  transition: transform .12s ease, background .2s ease, color .2s ease;
}
.admin-btn:active { transform: scale(.92); background: var(--surface-2); color: var(--text); }

/* ---------- Obrazovky (prepínanie) ---------- */
.screen { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; gap: clamp(14px,1.8vh,24px); }
.screen.is-active { display: flex; animation: screenIn .28s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex: 0 0 auto; }
.screen-title { font-size: clamp(26px, 3.2vw, 44px); font-weight: 700; letter-spacing: -.5px; }
.screen-sub { color: var(--muted); font-size: clamp(13px, 1.2vw, 17px); margin-top: 4px; font-weight: 400; }

.present-counter {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 10px 20px; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid rgba(29,158,117,0.22);
}
.present-num { font-family: 'DM Mono', monospace; font-weight: 500; font-size: clamp(28px,3vw,40px); color: var(--work-dot); line-height: 1; }
.present-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 4px; }

/* ---------- Vyhľadávanie ---------- */
.search-wrap { position: relative; flex: 0 0 auto; }
.search-icon { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--muted-2); }
.search-input {
  width: 100%; padding: clamp(14px,1.6vh,20px) 56px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: clamp(16px,1.6vw,21px);
  outline: none; transition: border-color .2s ease, background .2s ease;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus { border-color: var(--accent); background: var(--surface-2); }
.search-clear {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--muted); font-size: 15px; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.search-wrap.has-text .search-clear { opacity: 1; pointer-events: auto; }

/* ---------- Grid zamestnancov ---------- */
.employee-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: grid; gap: clamp(10px, 1.2vw, 16px);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start; padding-right: 4px; padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.emp-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: clamp(16px,1.8vw,22px); min-height: clamp(96px, 12vh, 128px);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  color: var(--text); font-family: inherit;
  transition: transform .12s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.emp-card:active { transform: scale(.97); border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent), 0 0 28px var(--accent-glow); }
.emp-name { font-size: clamp(17px,1.5vw,22px); font-weight: 600; letter-spacing: -.2px; }
.emp-status { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); margin-top: auto; }
.emp-status .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.emp-status .time { font-family: 'DM Mono', monospace; color: var(--text); }

/* stavové farby bodiek */
.dot.work     { background: var(--work-dot);  box-shadow: 0 0 8px var(--work-dot); }
.dot.lunch    { background: var(--cat-work); }
.dot.smoke    { background: var(--cat-work); opacity:.8; }
.dot.doctor   { background: var(--cat-health); box-shadow: 0 0 8px rgba(251,191,36,.5); }
.dot.plan     { background: var(--cat-plan); box-shadow: 0 0 8px rgba(56,189,248,.4); }
.dot.vacation { background: var(--cat-plan); }
.dot.other    { background: var(--cat-other); }
.dot.out      { background: var(--muted-2); }

.emp-card .chev {
  position: absolute; right: 16px; top: 16px; width: 18px; height: 18px;
  color: var(--muted-2); transition: transform .15s ease, color .15s ease;
}
.emp-card:active .chev { transform: translateX(4px); color: var(--accent); }

.empty-hint { color: var(--muted); text-align: center; padding: 40px; font-size: 16px; }

/* ---------- Obrazovka 2: skupiny akcií ---------- */
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: 16px; font-weight: 500;
  padding: 12px 18px 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  transition: transform .12s ease, background .2s ease;
}
.back-btn:active { transform: scale(.95); background: var(--surface-2); }
.back-btn svg { width: 20px; height: 20px; }
.selected-emp { text-align: center; flex: 1; }
.selected-emp-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted-2); }
.selected-emp-name { font-size: clamp(22px,2.4vw,34px); font-weight: 700; letter-spacing: -.4px; }
.countdown-mini { width: 70px; text-align: right; font-family: 'DM Mono', monospace; color: var(--muted); }

.action-groups {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: clamp(14px,1.8vh,22px);
  padding-right: 4px; padding-bottom: 6px; -webkit-overflow-scrolling: touch;
}
.action-group-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--muted); margin-bottom: 10px; font-weight: 600;
}
.action-group-label::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--g-color); }
.action-group-label::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }

.action-grid { display: grid; gap: clamp(10px,1.2vw,16px); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.action-tile {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: clamp(16px,1.8vw,24px); min-height: clamp(84px,11vh,112px);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  color: var(--text); font-family: inherit;
  background: color-mix(in srgb, var(--g-color) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--g-color) 22%, transparent);
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.action-tile:active {
  transform: scale(.96);
  background: color-mix(in srgb, var(--g-color) 16%, var(--surface));
  border-color: var(--g-color);
  box-shadow: 0 0 0 1px var(--g-color), 0 0 30px color-mix(in srgb, var(--g-color) 40%, transparent);
}
.action-tile .ic {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--g-color) 18%, transparent);
  color: var(--g-color);
}
.action-tile .label { font-size: clamp(16px,1.5vw,21px); font-weight: 600; line-height: 1.15; letter-spacing: -.2px; }
.action-tile .chev { margin-left: auto; width: 20px; height: 20px; color: color-mix(in srgb, var(--g-color) 70%, var(--muted)); transition: transform .15s ease; }
.action-tile:active .chev { transform: translateX(5px); }

/* ---------- Obrazovka FOTO: overenie identity ---------- */
.screen--photo { align-items: center; justify-content: center; }
.photo-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: clamp(24px,3vw,40px); width: min(520px, 92vw);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 28px; box-shadow: 0 0 60px rgba(29,158,117,0.10);
  animation: cardPop .3s ease;
}
.photo-title { font-size: clamp(22px,2.6vw,32px); font-weight: 700; }
.photo-sub { color: var(--muted); font-size: 15px; margin-top: -8px; }
.photo-frame {
  position: relative; width: min(400px, 80vw); aspect-ratio: 4/3;
  border-radius: 20px; overflow: hidden;
  border: 2px solid var(--accent); box-shadow: 0 0 30px var(--accent-glow);
  background: #000;
}
.photo-frame video {
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1);  /* zrkadlový náhľad */
}
.photo-count {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: 'DM Mono', monospace; font-weight: 500;
  font-size: clamp(64px, 10vw, 110px); color: #fff;
  text-shadow: 0 0 24px rgba(0,0,0,.8); pointer-events: none;
}
.photo-cancel { min-width: 160px; }

/* ---------- Obrazovka 3: potvrdenie ---------- */
.screen--confirm { align-items: center; justify-content: center; }
.confirm-card {
  width: min(560px, 92vw); padding: clamp(32px,4vw,56px); text-align: center;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 28px; box-shadow: 0 0 60px rgba(29,158,117,0.10);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: cardPop .35s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes cardPop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.confirm-check { width: 92px; height: 92px; color: var(--accent); }
.confirm-check svg { width: 100%; height: 100%; }
.confirm-check svg circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: drawC .5s ease forwards; }
.confirm-check svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: drawC .4s .35s ease forwards; }
@keyframes drawC { to { stroke-dashoffset: 0; } }
.confirm-time { font-family: 'DM Mono', monospace; font-weight: 500; font-size: clamp(40px,6vw,72px); letter-spacing: 1px; line-height: 1; }
.confirm-name { font-size: clamp(22px,2.6vw,32px); font-weight: 700; }
.confirm-action {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-radius: 999px; font-size: 18px; font-weight: 600;
  background: color-mix(in srgb, var(--g-color, var(--accent)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--g-color, var(--accent)) 35%, transparent);
  color: var(--g-color, var(--accent));
}
.confirm-action-dot { width: 11px; height: 11px; border-radius: 50%; background: currentColor; }
.confirm-status { color: var(--muted); font-size: 15px; }
.confirm-return {
  margin-top: 8px; padding: 14px 28px; border-radius: var(--radius-sm);
  background: var(--accent); color: #04140d; border: none; cursor: pointer;
  font-family: inherit; font-size: 17px; font-weight: 700;
  transition: transform .12s ease, box-shadow .2s ease;
}
.confirm-return:active { transform: scale(.95); box-shadow: 0 0 24px var(--accent-glow); }
.confirm-progress { width: 100%; height: 4px; border-radius: 999px; background: var(--border-strong); overflow: hidden; margin-top: 6px; }
.confirm-progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; animation: shrink 5s linear forwards; }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Footer ---------- */
.footer { flex: 0 0 auto; text-align: center; color: var(--muted-2); font-size: 12.5px; letter-spacing: .4px; padding-top: 2px; }

/* ---------- Admin modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}
/* Atribút hidden musí prebiť display:grid vyššie (inak sa modal nezavrie) */
.modal-overlay[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 94vw); max-height: 90dvh; overflow-y: auto;
  background: #0e0e11; border: 1px solid var(--border-strong); border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 21px; font-weight: 700; }
.modal-close { width: 38px; height: 38px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 17px; cursor: pointer; }
.modal-close:active { background: var(--surface-2); }
.modal-body { padding: 26px; display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field-input {
  padding: 13px 16px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; color: var(--text); font-family: inherit; font-size: 16px; outline: none;
  transition: border-color .2s ease;
}
.field-input:focus { border-color: var(--accent); }

.btn {
  padding: 13px 22px; border-radius: 12px; border: none; cursor: pointer;
  font-family: inherit; font-size: 15.5px; font-weight: 600;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.96); }
.btn--primary { background: var(--accent); color: #04140d; }
.btn--primary:active { box-shadow: 0 0 24px var(--accent-glow); }
.btn--ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn--danger { background: rgba(248,113,113,.12); color: #fca5a5; border: 1px solid rgba(248,113,113,.3); }

.admin-error { color: #fca5a5; font-size: 14px; }
.period-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-stats > div { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-family: 'DM Mono', monospace; font-size: 30px; font-weight: 500; color: var(--text); }
.stat-lbl { font-size: 12.5px; color: var(--muted); }
.export-row, .admin-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.export-row .btn, .admin-actions .btn { flex: 1; min-width: 140px; }
.admin-config { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.admin-config summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
.cfg-note { font-size: 12.5px; color: var(--muted-2); line-height: 1.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #16161a; border: 1px solid var(--border-strong); color: var(--text);
  padding: 14px 22px; border-radius: 14px; font-size: 15px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(29,158,117,.4); }
.toast.err { border-color: rgba(248,113,113,.4); color: #fca5a5; }

/* ---------- Responsivita ---------- */
@media (max-width: 620px) {
  .employee-grid { grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); }
  .action-grid { grid-template-columns: 1fr; }
  .clock { font-size: 24px; }
  .sync-pill { display: none; }
}
@media (min-width: 1400px) {
  .employee-grid { grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); }
}
