/* Time Tracking Web — iPad-first kiosk + admin styles */
:root {
  --bg: #0f1626;
  --bg-2: #16213e;
  --bg-3: #1a1a2e;
  --accent: #0d6efd;
  --accent-2: #198754;
  --danger: #dc3545;
  --warn: #ffc107;
  --text: #f5f6fa;
  --muted: #aab1c2;
  --border: #2a3554;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Flash messages ---------- */
.flash-stack { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 18px; border-radius: 10px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.flash-success { background: var(--accent-2); }
.flash-error { background: var(--danger); }

/* ---------- Kiosk ---------- */
body.kiosk { overflow-x: hidden; user-select: none; min-height: 100dvh; min-height: 100vh; }

.kiosk-header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 24px; background: var(--bg-3); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 4;
}
.header-left { font-size: clamp(14px, 2.4vw, 22px); font-weight: 600; justify-self: end; padding-right: 18px; }
.clock { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: clamp(20px, 3.4vw, 30px); color: var(--warn); letter-spacing: 1px; justify-self: center; }
.admin-link { color: var(--muted); font-size: 26px; padding: 6px 12px; justify-self: end; line-height: 1; }

.powered-by {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-top: 18px; color: var(--muted);
}
.powered-by-label { font-size: 13px; letter-spacing: 1px; text-transform: lowercase; opacity: .8; }
.powered-by img { height: clamp(80px, 14vw, 160px); max-width: 90%; object-fit: contain; }

.kiosk-main {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px; gap: 14px;
  /* fill viewport but allow scroll if content gets larger */
  min-height: calc(100dvh - 70px); min-height: calc(100vh - 70px);
}

/* Camera area: portrait-oriented oval like the desktop app */
.camera-wrap {
  position: relative; width: 100%;
  /* portrait camera: taller than wide so the oval feels natural */
  max-width: min(520px, 92vw);
  aspect-ratio: 3 / 4;
  background: #000; border-radius: 24px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#video { transform: scaleX(-1); /* mirror, like a selfie */ }

/* Vignette mask cut out as a vertical ellipse (true oval, not a circle) */
.oval-mask,
.circle-mask {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 36% 48% at 50% 50%, transparent 96%, rgba(0,0,0,.7) 100%);
  pointer-events: none;
}

/* Live face-position feedback ring drawn as a vertical ellipse to match the mask */
.face-ring {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 72%; height: 96%;
  border-radius: 50% / 50%;
  border: 6px solid var(--muted);
  box-shadow: 0 0 0 2px rgba(0,0,0,.35) inset;
  pointer-events: none;
  transition: border-color .25s, box-shadow .25s;
  opacity: .9;
}
.face-ring.ring-good { border-color: #22c55e; box-shadow: 0 0 24px rgba(34,197,94,.55); }
.face-ring.ring-warn { border-color: #f59e0b; box-shadow: 0 0 24px rgba(245,158,11,.55); }
.face-ring.ring-bad  { border-color: #ef4444; box-shadow: 0 0 24px rgba(239,68,68,.55); }

.status {
  width: 100%; max-width: 720px; padding: 14px 18px; border-radius: 14px;
  text-align: center; font-size: clamp(15px, 2.2vw, 20px); font-weight: 500;
  background: var(--bg-2); border: 1px solid var(--border); min-height: 56px;
}
.status-idle    { color: var(--muted); }
.status-info    { color: var(--accent); border-color: var(--accent); }
.status-warn    { color: var(--warn);   border-color: var(--warn); }
.status-error   { color: var(--danger); border-color: var(--danger); }
.status-success { color: var(--accent-2); border-color: var(--accent-2); }

.actions { display: flex; gap: 16px; width: 100%; max-width: 720px; }
.btn {
  flex: 1; font-size: clamp(18px, 3vw, 28px); font-weight: 700; padding: 22px 18px;
  border: none; border-radius: 18px; cursor: pointer; color: white;
  background: var(--accent); transition: transform .05s, opacity .15s;
  letter-spacing: 1px; min-height: 64px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-checkin  { background: linear-gradient(135deg, #198754, #28a86d); }
.btn-checkout { background: linear-gradient(135deg, #dc3545, #ff6b7d); }
.btn-primary  { background: var(--accent); }
.btn-secondary{ background: #6c757d; }
.btn-danger   { background: var(--danger); }
.btn.small    { font-size: 14px; padding: 8px 14px; border-radius: 8px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; max-width: 720px; width: 100%; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-card h2 { margin-top: 0; }
.gdpr-text {
  flex: 1; overflow: auto; background: var(--bg-3); padding: 16px; border-radius: 10px;
  font-family: inherit; white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: #d6dcec;
}
.consent { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 16px; }
.consent input { width: 22px; height: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }
#name-input { width: 100%; padding: 14px; font-size: 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); margin: 12px 0; }

/* ---------- Admin ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; padding: 32px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { margin: 0 0 8px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; }
.auth-card input { padding: 14px; font-size: 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); }
.auth-card .back { margin-top: 8px; text-align: center; color: var(--muted); }
.auth-card .hint { color: var(--muted); font-size: 14px; margin: 0; }

.admin-nav {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--bg-3); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.admin-nav a { color: var(--text); padding: 6px 10px; border-radius: 6px; }
.admin-nav a:hover { background: var(--bg-2); text-decoration: none; }
.admin-nav .spacer { flex: 1; }
.admin-nav .inline { display: inline; }
.admin-nav .link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: inherit; }

.admin-wrap { padding: 24px; max-width: 1400px; margin: 0 auto; }
.admin-wrap h1 { margin-top: 0; }

.cards { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 20px; min-width: 220px; }
.card h3 { margin: 0 0 8px; color: var(--muted); font-size: 14px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; }
.card .big { font-size: 42px; font-weight: 700; }
.quick-links { display: flex; flex-wrap: wrap; gap: 12px; }

.warn { background: rgba(255,193,7,.15); border: 1px solid var(--warn); color: var(--warn); padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }

.filter-bar { display: flex; gap: 12px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filter-bar input { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); }

.form-grid { display: flex; flex-direction: column; gap: 18px; max-width: 600px; }
.form-grid fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.form-grid legend { padding: 0 8px; color: var(--warn); font-weight: 600; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-grid label span { color: var(--muted); font-size: 13px; }
.form-grid input, .form-grid textarea { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); font-size: 15px; }
.form-grid textarea.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; }
.form-grid .row { display: flex; gap: 12px; }
.form-grid .hint { color: var(--muted); font-size: 13px; }

table.data { width: 100%; border-collapse: collapse; background: var(--bg-2); border-radius: 12px; overflow: hidden; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { background: var(--bg-3); color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
table.data tr:last-child td { border-bottom: none; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.thumb.circle { border-radius: 50%; }
.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; }
.empty { color: var(--muted); padding: 40px; text-align: center; background: var(--bg-2); border-radius: 12px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 12px; }
.badge.open { background: var(--warn); color: #000; }
.inline { display: inline; }
.inline input[type=text] { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); }

/* ---------- Responsive breakpoints ---------- */

/* Tablets in landscape: side-by-side camera + actions to make use of width */
@media (min-width: 1024px) and (orientation: landscape) {
  .kiosk-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "camera status"
      "camera actions"
      "camera powered";
    column-gap: 32px; row-gap: 16px;
    align-items: center; justify-items: center;
    max-width: 1200px; margin: 0 auto;
  }
  .camera-wrap { grid-area: camera; max-width: 480px; }
  .status      { grid-area: status; }
  .actions     { grid-area: actions; }
  .powered-by  { grid-area: powered; margin-top: 0; }
}

/* Tablet portrait + small desktop */
@media (max-width: 900px) {
  .kiosk-header { padding: 10px 14px; }
  .header-left { padding-right: 8px; }
  .admin-link { padding: 4px 8px; }
  .kiosk-main { padding: 12px; gap: 12px; }
  .camera-wrap { max-width: min(420px, 86vw); }
  .actions { gap: 12px; }
  .btn { padding: 20px 14px; min-height: 60px; }
}

/* Phones */
@media (max-width: 600px) {
  .kiosk-header { padding: 8px 10px; }
  .header-left { font-size: 14px; padding-right: 6px; }
  .clock { font-size: 18px; }
  .admin-link { font-size: 22px; }
  .kiosk-main { padding: 10px; gap: 10px; }
  .camera-wrap { max-width: min(360px, 92vw); border-radius: 18px; }
  .actions { flex-direction: column; gap: 10px; }
  .btn { font-size: 20px; padding: 18px; min-height: 56px; border-radius: 14px; }
  .status { font-size: 15px; padding: 12px 14px; min-height: 48px; }
  .powered-by { margin-top: 10px; }
  .powered-by img { height: 72px; }
  .powered-by-label { font-size: 11px; }
  .modal-card { padding: 18px; border-radius: 14px; }
  .gdpr-text { font-size: 13px; padding: 12px; }
}

/* Very short screens (phone landscape) — keep camera reachable */
@media (max-height: 520px) and (orientation: landscape) {
  .kiosk-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "camera status"
      "camera actions"
      "camera powered";
    gap: 10px;
    padding: 8px;
  }
  .camera-wrap { grid-area: camera; max-width: 280px; }
  .status      { grid-area: status; padding: 10px; min-height: 0; font-size: 14px; }
  .actions     { grid-area: actions; flex-direction: row; gap: 8px; }
  .btn         { padding: 14px; min-height: 48px; font-size: 16px; }
  .powered-by  { grid-area: powered; margin-top: 0; }
  .powered-by img { height: 48px; }
}
