/* Daycare Check-In Kiosk styles.
   High contrast, big type, big touch targets. No external fonts. */

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

/* overscroll-behavior must sit on the root element for Chrome 115+ to block
   pull-to-refresh; the body copy covers older versions. */
html { height: 100%; overscroll-behavior: none; }
body { height: 100%; }

body {
  /* position:fixed blocks iOS rubber-banding and pull-to-refresh */
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

input, textarea, select {
  -webkit-user-select: auto;
  user-select: auto;
  font: inherit;
}

button { font: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* Hidden scan input: kept technically visible so iOS still delivers key events */
#scan-form { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; }
#scan-input {
  position: absolute; top: 0; left: 0;
  width: 2px; height: 2px;
  opacity: 0.01;
  border: 0; padding: 0;
  background: transparent; color: transparent;
  caret-color: transparent;
  outline: none;
}

/* ============ Screens ============ */

.screen {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ============ Idle ============ */

#screen-idle { align-items: center; justify-content: space-between; padding: 4vh 4vw; }

.idle-clock { text-align: center; margin-top: 2vh; }
#clock-time { font-size: min(16vw, 9rem); font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
#clock-date { font-size: min(3.5vw, 1.6rem); color: #94a3b8; margin-top: 0.6rem; }

.idle-prompt { text-align: center; }
.idle-prompt h1 { font-size: min(6vw, 2.6rem); font-weight: 600; }
.idle-hint { margin-top: 1rem; font-size: 1.2rem; color: #fbbf24; }

.idle-bottom { width: 100%; text-align: center; }

.present-title {
  font-size: 1rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: #94a3b8; margin-bottom: 0.6rem;
}
/* iOS Safari before 14.5 ignores gap in flexbox (it worked in grid only), so
   every flex container spaces its children with margins instead. */
.present-list {
  display: flex; flex-wrap: wrap; justify-content: center;
  max-height: 22vh; overflow: hidden; margin-bottom: 0.9rem;
}
.chip {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 999px; padding: 10px 18px;
  font-size: 1.25rem; white-space: nowrap;
  margin: 5px;
}
.chip .chip-time { color: #94a3b8; font-size: 1rem; margin-left: 6px; }

.btn-ghost {
  background: transparent; color: #94a3b8;
  border: 1px solid #334155; border-radius: 10px;
  padding: 12px 22px; font-size: 1.05rem; min-height: 48px;
}

.gear {
  position: absolute; right: 14px; bottom: 14px;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: #475569;
  border-radius: 50%;
}

.sync-pill {
  position: absolute; left: 14px; bottom: 22px;
  background: #1e293b; color: #94a3b8;
  border-radius: 999px; padding: 6px 14px; font-size: 0.9rem;
}

.alert-pill {
  position: absolute; top: 12px; left: 50%;
  transform: translateX(-50%);
  background: #b91c1c; color: #ffffff;
  border-radius: 999px; padding: 8px 18px; font-size: 1rem;
  white-space: nowrap; z-index: 30;
}

/* ============ Confirmation ============ */

#screen-confirm, #screen-error {
  align-items: center; justify-content: center;
  text-align: center; padding: 4vw;
}
#screen-confirm.confirm-in  { background: #15803d; }
#screen-confirm.confirm-out { background: #c2410c; }
#screen-error { background: #b91c1c; }

.confirm-name {
  font-size: min(17vw, 10rem); font-weight: 800; line-height: 1.05;
  word-break: break-word; max-width: 96vw;
}
.confirm-status {
  font-size: min(8vw, 4rem); font-weight: 700;
  letter-spacing: 0.12em; margin-top: 2vh;
}
.confirm-time { font-size: min(6vw, 3rem); margin-top: 2vh; opacity: 0.9; }
.error-sub { font-size: min(4vw, 1.6rem); margin-top: 3vh; opacity: 0.9; }

/* ============ PIN pad ============ */

#screen-pin { align-items: center; justify-content: center; }
.pin-box { text-align: center; }
.pin-box h2 { font-size: 1.6rem; margin-bottom: 1rem; font-weight: 600; }
.pin-dots { min-height: 28px; font-size: 1.8rem; letter-spacing: 0.35em; margin-bottom: 0.4rem; }
.pin-msg { color: #fca5a5; font-size: 1rem; min-height: 1.4rem; margin-bottom: 0.8rem; }
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 84px);
  grid-gap: 14px; gap: 14px; justify-content: center;
}
.pin-pad button {
  width: 84px; height: 84px; border-radius: 50%;
  background: #1e293b; color: #f8fafc; border: 1px solid #334155;
  font-size: 1.9rem;
}
.pin-pad button.pin-alt { font-size: 1.05rem; color: #94a3b8; }
.pin-pad button:active { background: #334155; }

/* ============ Settings ============ */

#screen-settings { background: #f1f5f9; color: #0f172a; }

.settings-header {
  display: flex; align-items: center;
  padding: 12px 16px; background: #ffffff;
  border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.settings-header .btn-back { margin-right: 16px; }
.settings-header h1 { font-size: 1.3rem; }
.btn-back {
  background: transparent; border: none; color: #2563eb;
  font-size: 1.05rem; padding: 10px 6px; min-height: 48px;
}

.settings-tabs {
  display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: #ffffff; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.settings-tabs .tab {
  flex: 0 0 auto; padding: 14px 18px; min-height: 48px;
  background: transparent; border: none; border-bottom: 3px solid transparent;
  font-size: 1rem; color: #475569; white-space: nowrap;
}
.settings-tabs .tab.active { color: #0f172a; border-bottom-color: #2563eb; font-weight: 600; }

.settings-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px; padding-bottom: 60px;
}

.tab-pane { display: none; max-width: 640px; margin: 0 auto; }
.tab-pane.active { display: block; }

.banner {
  background: #fef3c7; border: 1px solid #fcd34d; color: #92400e;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
  max-width: 640px; margin-left: auto; margin-right: auto;
}
.btn-link { background: none; border: none; color: #2563eb; font-size: 1rem; text-decoration: underline; padding: 4px; }

.form-card, .list-row {
  background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.form-card h3 { margin-bottom: 10px; font-size: 1.05rem; }
.form-card h3.spaced { margin-top: 18px; }
.form-card label { display: block; margin-bottom: 12px; font-size: 0.95rem; color: #334155; }
.form-card input[type="text"], .form-card input[type="url"],
.form-card input[type="password"], .form-card input[type="date"],
.form-card input[type="time"], .form-card select, .form-card textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 12px; font-size: 1.05rem;
  border: 1px solid #cbd5e1; border-radius: 8px; background: #ffffff;
  color: #0f172a;
}
.form-card textarea { font-family: Menlo, Consolas, monospace; font-size: 0.8rem; margin-bottom: 10px; }

.code-row { display: flex; align-items: stretch; }
.code-row input { flex: 1; margin-right: 8px; }

.check-row { display: flex; align-items: center; padding: 10px 0; font-size: 1rem; }
.check-row input { width: 22px; height: 22px; flex-shrink: 0; margin-right: 10px; }
.check-list .check-row { border-bottom: 1px solid #f1f5f9; margin: 0; }

.form-actions { display: flex; flex-wrap: wrap; margin-top: 6px; }
.form-actions > * { margin: 0 10px 10px 0; }

.btn {
  background: #e2e8f0; color: #0f172a; border: none; border-radius: 10px;
  padding: 12px 20px; font-size: 1rem; min-height: 48px;
}
.btn.primary { background: #2563eb; color: #ffffff; font-weight: 600; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 0.9rem; }
.btn.big { font-size: 1.2rem; padding: 14px 28px; }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn:active { opacity: 0.8; }

.form-error { color: #b91c1c; margin: 8px 0; }
.ok-msg { color: #15803d; margin-top: 8px; min-height: 1.2rem; }
.fine-print { color: #64748b; font-size: 0.85rem; margin-top: 10px; line-height: 1.45; }
.fine-print a { color: #2563eb; }

.steps { margin: 0 0 12px 20px; line-height: 1.7; font-size: 0.95rem; }

.row-split { display: flex; align-items: flex-end; flex-wrap: wrap; margin-bottom: 2px; }
.row-split > * { margin: 0 12px 12px 0; }
.inline-label { font-size: 0.95rem; color: #334155; }
.inline-label input { display: block; margin-top: 6px; padding: 10px; font-size: 1rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #0f172a; }

/* List rows (children, events) */
.list-row { display: flex; align-items: center; justify-content: space-between; }
.row-main { flex: 1; min-width: 0; margin-right: 12px; }
.row-title { font-size: 1.1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: #64748b; font-size: 0.9rem; margin-top: 2px; }
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 600;
  border-radius: 6px; padding: 2px 8px; margin-left: 8px; vertical-align: middle;
}
.badge.off { background: #f1f5f9; color: #64748b; }
.badge.in  { background: #dcfce7; color: #15803d; }
.badge.out { background: #ffedd5; color: #c2410c; }

.row-editor { margin-top: 10px; }
.row-editor .form-actions { margin-top: 10px; }

.empty-note { color: #64748b; text-align: center; padding: 24px 0; }

/* ============ Camera overlay ============ */

.overlay {
  display: none;
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(3, 7, 18, 0.96); z-index: 40;
  align-items: center; justify-content: center;
}
.overlay.open { display: flex; }
.overlay-inner { text-align: center; width: 100%; padding: 16px; }
#camera-view { max-width: 480px; margin: 0 auto 18px; }
#camera-view video { max-width: 100%; border-radius: 12px; }

/* ============ Toast ============ */

.toast {
  position: absolute; left: 50%; bottom: 90px;
  transform: translateX(-50%);
  background: #1e293b; color: #f8fafc;
  border-radius: 10px; padding: 12px 20px;
  font-size: 1rem; z-index: 60; max-width: 88vw; text-align: center;
}

/* ============ Print sheet ============ */

#print-area { display: none; }

@media print {
  body { position: static; overflow: visible; background: #ffffff; color: #000000; }
  .screen, .overlay, .toast, #scan-form { display: none !important; }
  #print-area { display: block; }

  .card-grid { display: flex; flex-wrap: wrap; }
  .card {
    width: 3.375in; height: 2.125in;
    border: 1px dashed #999999;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 0.15in;
    page-break-inside: avoid;
    overflow: hidden;
  }
  /* QR cards print portrait, six to a page, with the critter artwork. */
  .qr-grid .card.qr-card {
    width: 2.6in; height: 3.25in;
    padding: 0.08in;
    display: flex; align-items: center; justify-content: center;
  }
  .card.qr-card img { max-width: 100%; max-height: 100%; }

  .card-name { font-size: 18pt; font-weight: 700; margin-bottom: 0.08in; text-align: center; }
  .card .bars svg { width: 2.7in; height: 0.65in; }
  .card .qr svg { width: 1.15in; height: 1.15in; }
  .card-code { font-family: Menlo, Consolas, monospace; font-size: 9pt; color: #444444; margin-top: 0.06in; }
}

/* Live camera preview on the idle screen (watch mode). Sized small: it is an
   aiming aid for the provider, not the main event. */
.watch-view {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 50;
  width: min(26vw, 190px);
  min-height: 110px;
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
  border: 2px solid rgba(248, 250, 252, 0.55);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.watch-view video, .watch-view canvas { display: block; width: 100% !important; height: auto !important; }
.watch-view img { display: none; }
#btn-watch-retry { margin-top: 10px; background: #1e293b; color: #f8fafc; border-color: #475569; }

/* Animal picker in the child form */
.critter-row { display: flex; flex-wrap: wrap; margin-top: 8px; }
.critter-row button {
  width: 64px; height: 74px; margin: 0 8px 8px 0; padding: 2px;
  border: 2px solid #cbd5e1; border-radius: 12px;
  background: #ffffff; overflow: hidden;
}
.critter-row button.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
.critter-row button canvas { display: block; width: 100%; height: 100%; }

/* ===== Multi-child confirmation (families) ===== */

#screen-confirm.confirm-empty { background: #475569; }

.confirm-family {
  font-size: min(9vw, 4.2rem); font-weight: 800; line-height: 1.05;
  margin-bottom: 2vh; word-break: break-word;
}

.confirm-rows {
  width: min(92vw, 760px);
  margin: 0 auto;
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.confirm-row {
  display: flex; align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  text-align: left;
}
.confirm-row.removed { opacity: 0.55; }
.cr-name {
  flex: 1; min-width: 0;
  font-size: min(6vw, 2.6rem); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cr-status {
  font-size: min(3.4vw, 1.4rem); text-transform: uppercase;
  letter-spacing: 0.1em; opacity: 0.9; margin: 0 14px;
}
.cr-x, .cr-undo {
  flex-shrink: 0;
  min-width: 64px; height: 64px;
  border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.18); color: #ffffff;
}
.cr-x { font-size: 2.4rem; line-height: 1; }
.cr-undo { font-size: 1.1rem; padding: 0 14px; }
.cr-x:active, .cr-undo:active { background: rgba(0, 0, 0, 0.35); }

.confirm-hint { margin-top: 1vh; font-size: min(3.4vw, 1.3rem); opacity: 0.85; }

/* ===== Manual pick screen ===== */

#screen-pick { align-items: center; justify-content: center; padding: 4vh 4vw; }
.pick-title { font-size: min(7vw, 2.4rem); margin-bottom: 2vh; font-weight: 600; }
.pick-list {
  width: min(92vw, 640px);
  max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  margin-bottom: 2vh;
}
.pick-item {
  display: block; width: 100%; text-align: left;
  background: #1e293b; color: #f8fafc;
  border: 1px solid #334155; border-radius: 14px;
  padding: 16px 18px; margin-bottom: 10px; min-height: 64px;
}
.pick-item:active { background: #334155; }
.pick-name { display: block; font-size: 1.5rem; font-weight: 600; }
.pick-kids { display: block; font-size: 1rem; color: #94a3b8; margin-top: 2px; }
.pick-empty { color: #94a3b8; text-align: center; padding: 20px; }

/* Family cards in settings */
.family-card {
  background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px; margin-bottom: 14px;
}
.family-head { display: flex; align-items: center; justify-content: space-between; }
.family-head .row-main { margin-right: 12px; }
.kid-list { margin: 10px 0 8px; }
.kid-row {
  display: flex; align-items: center;
  border-top: 1px solid #f1f5f9; padding: 10px 0;
}
.kid-name { flex: 1; font-size: 1.02rem; font-weight: 600; min-width: 0; }
.kid-full { color: #64748b; font-size: 0.85rem; margin: 0 12px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kid-row.empty-note { display: block; padding: 10px 0; text-align: left; }
