/* attendance_kiosk — touch-friendly kiosk styles.
   Designed for a 10" Samsung tablet in landscape. Buttons are large
   enough for thumb taps; colour palette mirrors the Streamlit kiosk
   so the guard's mental model doesn't have to re-learn anything. */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #F3F4F6;
  color: #111827;
  -webkit-tap-highlight-color: transparent;
}
body { padding: 12px; max-width: 1200px; margin: 0 auto; }

/* ── Header ───────────────────────────────────────────────────── */
.hdr {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 8px;
  background: linear-gradient(135deg, #1B3F6E, #2E6DA4);
  color: #fff;
}
.hdr-title { font-size: 18px; font-weight: 700; }
.hdr-sub   { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.hdr-ctx   { display: flex; gap: 8px; align-items: center; }
.hdr-ctx input[type=date] {
  border: 0; border-radius: 6px; padding: 8px 10px; font-size: 14px;
}
.seg {
  background: rgba(255,255,255,0.15); padding: 8px 14px; border-radius: 6px;
  cursor: pointer; user-select: none;
  transition: background 0.1s, color 0.1s;
}
.seg input { display: none; }
/* Server-side initial state */
.seg.on { background: #fff; color: #1B3F6E; font-weight: 700; }
/* Client-side highlight when the radio inside is checked — :has is
   widely supported in modern browsers (Chrome 105+, Safari 15.4+).
   Without this, tapping Day/Night doesn't repaint until Go is pressed. */
.seg:has(input:checked) { background: #fff; color: #1B3F6E; font-weight: 700; }
.btn-go {
  background: #15803D; color: #fff; border: 0; border-radius: 6px;
  padding: 8px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-go:active { transform: translateY(1px); }

/* ── Filter strip ─────────────────────────────────────────────── */
.filter-strip {
  display: flex; gap: 8px; margin: 12px 0;
  background: #fff; padding: 10px; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.filter-strip select,
.filter-strip input[type=search] {
  border: 1px solid #D1D5DB; border-radius: 6px;
  padding: 10px 12px; font-size: 14px; background: #fff;
}
.filter-strip select { min-width: 200px; }
.filter-strip input[type=search] { flex: 1; min-width: 200px; }

/* ── Tabs (pure CSS via :checked radios) ──────────────────────── */
.tabs { background: #fff; border-radius: 8px; overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.tab-radio { display: none; }
.tab-bar { display: flex; border-bottom: 1px solid #E5E7EB; }
.tab-bar label {
  flex: 1; padding: 14px 8px; text-align: center;
  font-weight: 600; cursor: pointer; user-select: none;
  border-bottom: 3px solid transparent; color: #6B7280;
}
.tab-bar label:hover { background: #F9FAFB; }
.tab-bar .cnt {
  display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px;
  font-size: 12px; background: #E5E7EB; color: #374151; border-radius: 10px;
}
.tab-panel { display: none; padding: 14px; }
#t-in:checked    ~ .tab-bar label[for=t-in]    { color: #1B3F6E; border-bottom-color: #2E6DA4; }
#t-out:checked   ~ .tab-bar label[for=t-out]   { color: #1B3F6E; border-bottom-color: #2E6DA4; }
#t-staff:checked ~ .tab-bar label[for=t-staff] { color: #1B3F6E; border-bottom-color: #2E6DA4; }
#t-gate:checked  ~ .tab-bar label[for=t-gate]  { color: #1B3F6E; border-bottom-color: #2E6DA4; }
#t-cash:checked  ~ .tab-bar label[for=t-cash]  { color: #1B3F6E; border-bottom-color: #2E6DA4; }
#t-in:checked    ~ #panel-in    { display: block; }
#t-out:checked   ~ #panel-out   { display: block; }
#t-staff:checked ~ #panel-staff { display: block; }
#t-gate:checked  ~ #panel-gate  { display: block; }
#t-cash:checked  ~ #panel-cash  { display: block; }

/* ── Gate-pass board ──────────────────────────────────────────── */
.gp-row { border-left: 4px solid #E5E7EB; }
.gp-row.gp-approved { border-left-color: #16A34A; }
.gp-row.gp-pending  { border-left-color: #D97706; }
.gp-row.gp-rejected { border-left-color: #DC2626; opacity: 0.7; }
.gp-punch {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #F1F5F9;
}
.gp-punch form { margin: 0; }
.gp-state { font-weight: 600; color: #1B3F6E; }

/* ── Shared bits ──────────────────────────────────────────────── */
.empty {
  padding: 24px; text-align: center; color: #6B7280;
  background: #F9FAFB; border-radius: 6px;
}
.hint { font-size: 13px; color: #4B5563; margin: 4px 0 12px 0; }
.muted { color: #6B7280; font-size: 13px; }
.card {
  background: #fff; border: 1px solid #E5E7EB; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.section-hdr {
  font-size: 13px; font-weight: 700; color: #1B3F6E;
  text-transform: uppercase; letter-spacing: 1px;
  margin: 16px 0 8px 0; padding: 8px 12px;
  background: #EFF6FF; border-left: 4px solid #2E6DA4; border-radius: 4px;
}
.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who b { font-size: 15px; }
.money { font-weight: 700; color: #15803D; font-size: 16px; }

/* Status pills */
.pill {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.p-in   { background: #DCFCE7; color: #15803D; }
.p-out  { background: #E0E7FF; color: #3730A3; }
.p-abs  { background: #FEE2E2; color: #B91C1C; }
.p-pres { background: #DCFCE7; color: #15803D; }

/* KPI strip */
.kpis { display: flex; gap: 8px; margin: 8px 0 12px 0; flex-wrap: wrap; }
.kpi {
  flex: 1; background: #fff; border: 1px solid #E5E7EB; border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
  min-width: 140px;
}
.kpi-lbl { font-size: 12px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-val { font-size: 22px; font-weight: 700; color: #1B3F6E; }

/* ── IN tab grid ──────────────────────────────────────────────── */
.in-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.in-btn {
  background: linear-gradient(135deg, #2E6DA4, #1B3F6E); color: #fff;
  border: 0; border-radius: 8px; padding: 14px 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 64px;
  transition: transform 0.08s;
}
.in-btn .bn { font-size: 15px; line-height: 1.2; }
.in-btn .bc { font-size: 11px; opacity: 0.85; }
.in-btn:active { transform: scale(0.97); }
.htmx-request.in-btn { opacity: 0.5; pointer-events: none; }

/* ── OUT tab rows ─────────────────────────────────────────────── */
.out-row .row-top {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.out-row .who { flex: 1; min-width: 160px; }
.out-form { margin-left: auto; }
.btn-out {
  background: #DC2626; color: #fff; border: 0; border-radius: 6px;
  padding: 12px 24px; font-size: 16px; font-weight: 700; cursor: pointer;
  min-width: 90px;
}
.btn-out:active { transform: translateY(1px); }
.undo-form { margin-left: auto; }
.out-form  { margin-left: 0; }
.btn-undo {
  background: #F3F4F6; color: #374151; border: 1px solid #D1D5DB;
  border-radius: 6px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.btn-undo:hover  { background: #E5E7EB; }
.btn-undo:active { transform: translateY(1px); }
.assign-form {
  display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap;
}
.assign-form label {
  display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px;
  font-size: 12px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px;
}
.assign-form select {
  border: 1px solid #D1D5DB; border-radius: 6px;
  padding: 10px 12px; font-size: 14px; background: #fff; color: #111827;
  text-transform: none; letter-spacing: 0;
}
.done-list { margin-top: 16px; }
.done-list summary {
  cursor: pointer; font-weight: 600; color: #4B5563;
  padding: 8px 12px; background: #F9FAFB; border-radius: 6px;
}
.done-row { display: flex; gap: 12px; align-items: center; opacity: 0.75; }
.done-row .who { flex: 1; }

/* ── Staff tab ────────────────────────────────────────────────── */
.staff-row {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.staff-row .who { flex: 1; min-width: 160px; }
.staff-row.row-abs { background: #FEF2F2; }
.btn-secondary {
  background: #F3F4F6; color: #1B3F6E; border: 1px solid #D1D5DB;
  border-radius: 6px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-warn {
  background: #B91C1C; color: #fff; border: 0; border-radius: 6px;
  padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ── Cash tab ─────────────────────────────────────────────────── */
.cash-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px;
}
.cash-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px;
}
.cash-grid input, .cash-grid select {
  border: 1px solid #D1D5DB; border-radius: 6px;
  padding: 10px 12px; font-size: 14px;
  text-transform: none; letter-spacing: 0; color: #111827;
}
.cash-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cash-row .who { flex: 1; min-width: 200px; }

/* HTMX in-flight feedback — small dim while waiting for server. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ── Login screen ─────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, #1B3F6E, #2E6DA4);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; max-width: none; margin: 0;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 32px 24px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-title { font-size: 20px; font-weight: 700; color: #1B3F6E; }
.login-sub   { font-size: 14px; color: #6B7280; margin: 6px 0 24px 0; }
.pin-input {
  width: 100%; padding: 18px; font-size: 32px; text-align: center;
  letter-spacing: 12px; border: 2px solid #D1D5DB; border-radius: 8px;
  margin-bottom: 12px; box-sizing: border-box;
}
.pin-input:focus { border-color: #2E6DA4; outline: none; }
.login-err {
  background: #FEE2E2; color: #B91C1C; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; margin-bottom: 12px;
}
.logout-btn {
  background: rgba(255,255,255,0.15); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 12px; font-size: 13px; cursor: pointer; margin-left: 6px;
}
.logout-btn:hover { background: rgba(255,255,255,0.25); }

/* Cash live-preview box */
.cash-preview {
  margin: 8px 0 12px 0; padding: 10px 14px; background: #F0FDF4;
  border-left: 4px solid #15803D; border-radius: 4px; font-size: 14px;
}

/* Tablet portrait tweaks */
@media (max-width: 800px) {
  .hdr { flex-direction: column; align-items: stretch; }
  .hdr-ctx { justify-content: space-between; }
  .in-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cash-grid { grid-template-columns: repeat(2, 1fr); }
}
