/* Mobile-only styles. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --past: #e5e7eb;
  --past-text: #9ca3af;
  --free: #ecfdf5;
  --free-border: #a7f3d0;
  --booked: #fee2e2;
  --booked-border: #fca5a5;
  --booked-text: #7f1d1d;
  --selected: #2563eb;
  --selected-text: #ffffff;
  --in-range: #93c5fd;
  --in-range-text: #1e3a8a;
  --bottom-h: 92px;
}

html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

.topbar {
  background: #1f2937;
  color: #f9fafb;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .link {
  color: #93c5fd;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
}
.topbar .link:active { background: rgba(255,255,255,0.1); }

.container {
  padding: 12px 12px calc(var(--bottom-h) + 16px);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.date-tabs { margin-bottom: 14px; }

.tab-btn {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.tab-btn:active { transform: scale(0.97); }
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 4px 12px;
  text-align: center;
}

/* Slot grid: 3 columns on phone */
.timeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  touch-action: none;
  user-select: none;
}

.slot {
  position: relative;
  padding: 14px 6px;
  text-align: center;
  border-radius: 10px;
  background: var(--free);
  border: 1.5px solid var(--free-border);
  font-size: 15px;
  font-weight: 500;
  user-select: none;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.1s;
  min-height: 64px;
}
.slot:active { transform: scale(0.96); }

.slot .label {
  display: block;
  font-variant-numeric: tabular-nums;
}
.slot .who {
  display: block;
  font-size: 11px;
  font-weight: 400;
  margin-top: 4px;
  color: var(--booked-text);
}

.slot.past {
  background: var(--past);
  border-color: var(--past);
  color: var(--past-text);
  cursor: not-allowed;
}
.slot.past:active { transform: none; }

.slot.booked {
  background: var(--booked);
  border-color: var(--booked-border);
  color: var(--booked-text);
}

.slot.start, .slot.end {
  background: var(--selected);
  border-color: var(--selected);
  color: var(--selected-text);
  font-weight: 700;
}
.slot.in-range {
  background: var(--in-range);
  border-color: var(--in-range);
  color: var(--in-range-text);
}

/* Bottom action bar (fixed) */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.bb-info {
  font-size: 14px;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
  min-height: 20px;
  font-variant-numeric: tabular-nums;
}
.bb-info.empty { color: var(--muted); }
.bb-info.error { color: var(--danger); }
.bb-buttons {
  display: flex;
  gap: 8px;
}
.bb-buttons button { flex: 1; }

button.primary, button.ghost, button.danger {
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:active { transform: none; }
button.primary { background: var(--primary); color: #fff; }
button.ghost { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); color: #fff; }

/* Modal: bottom-sheet style on phone */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--card);
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal h2 { margin: 0 0 12px; font-size: 18px; text-align: center; }
.modal-summary {
  background: #f9fafb;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 0 0 14px;
  text-align: center;
}
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.modal-body input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 17px;            /* >=16px to prevent iOS zoom */
  font-family: inherit;
  color: var(--text);
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.modal-body input:focus {
  outline: none;
  border-color: var(--primary);
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions button { flex: 1; }
.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 0;
  text-align: center;
}

/* Desk page table → cards on phone */
.desk-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.desk-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.desk-card .row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.desk-card .res-name { font-weight: 600; font-size: 15px; }
.desk-card .time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.desk-card .user-id { font-size: 18px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.desk-card button { margin-top: 4px; padding: 10px; }

.muted { color: var(--muted); font-size: 13px; }
.result { font-size: 14px; min-height: 20px; margin: 0; text-align: center; }
.result.ok { color: #047857; font-weight: 600; }
.result.fail { color: var(--danger); font-weight: 600; }

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.action-bar button { padding: 8px 14px; }
.action-bar .muted { flex: 1; }

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  margin: 24px auto 0;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card label {
  font-size: 13px;
  color: var(--muted);
}
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
}
.login-card button { padding: 12px; }

/* ===== PIN lookup card (desk page) ===== */
.pin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  margin-bottom: 20px;
}
.pin-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 6px;
}
.pin-row input {
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 22px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 5px;
  color: var(--text);
  background: #fff;
}
.pin-row input:focus { outline: none; border-color: var(--primary); }
.pin-row button { padding: 12px 20px; flex-shrink: 0; }

.pin-ok {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 2px;
}
.pin-ok-check  { font-size: 13px; font-weight: 700; color: #047857; margin-bottom: 5px; }
.pin-ok-detail { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.pin-ok-user   { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 4px; }

.pin-fail {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 2px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* ===== Wheel Picker ===== */

.picker-card {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

/* Each picker pane: label + wheel */
.picker-pane { padding: 8px 0 0; }

.picker-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 0 0 2px;
  text-align: center;
}

.picker-hr {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* Hour + minute side-by-side */
.picker-time-row {
  display: flex;
  align-items: center;
}
.picker-time-row .picker-wheel-wrap { flex: 1; }
.picker-colon {
  font-size: 32px;
  font-weight: 300;
  color: var(--text);
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

/* Scrollable wheel */
.picker-wheel-wrap {
  position: relative;
  height: 220px; /* 5 visible rows × 44px */
  overflow: hidden;
}

/* Gradient fade top + bottom */
.picker-fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.96) 0%,
    rgba(255,255,255,0.5) 30%,
    transparent 42%,
    transparent 58%,
    rgba(255,255,255,0.5) 70%,
    rgba(255,255,255,0.96) 100%
  );
}

/* Selection highlight (two horizontal rules around center row) */
.picker-sel-bar {
  position: absolute;
  left: 20px; right: 20px;
  top: calc(50% - 22px);
  height: 44px;
  border-top: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10;
}

.picker-scroll {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.picker-scroll::-webkit-scrollbar { display: none; }

/* Spacers: 2 × ITEM_H to allow first/last item to center */
.picker-spacer {
  height: 88px;
  min-height: 88px;
  flex-shrink: 0;
}

.picker-item {
  height: 44px;
  min-height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 500;
  scroll-snap-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.picker-item--dim { color: #c0c5cc; }

/* ===== Bookings list ===== */

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 0 2px 8px;
}

.bookings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.booking-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.booking-card:active { transform: scale(0.98); }

.booking-time {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.booking-user {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}

.no-bookings {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 10px 0;
}
