/* Factory Timesheet Kiosk - iOS 12 Compatible CSS */
/* No CSS gap, clamp(), or subgrid used */

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #1a1a2e;
  color: #eee;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  position: relative;
}

/* ─── Screens ─────────────────────────────────────── */
.screen {
  display: none;
  height: 100%;
  flex-direction: column;
  padding: 20px;
}

.screen.active {
  display: flex;
}

/* ─── Header ──────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  min-height: 60px;
}

.business-name {
  font-size: 22px;
  font-weight: 700;
  color: #e94560;
}

.offline-badge {
  background: #ff6b35;
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.btn-back {
  background: none;
  border: none;
  color: #e94560;
  font-size: 20px;
  cursor: pointer;
  padding: 10px 15px;
}

.punch-type-label {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
}

/* ─── Clock Display ───────────────────────────────── */
.clock {
  font-size: 80px;
  font-weight: 300;
  text-align: center;
  margin: 30px 0 10px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  letter-spacing: 2px;
}

.date {
  font-size: 20px;
  text-align: center;
  color: #aaa;
  margin-bottom: 40px;
}

/* ─── Action Buttons ──────────────────────────────── */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
  align-content: center;
}

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44%;
  margin: 8px;
  padding: 30px 20px;
  border: none;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  min-height: 120px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}

.btn-clock-in {
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

.btn-clock-out {
  background: linear-gradient(135deg, #e17055, #d63031);
  color: #fff;
  box-shadow: 0 4px 15px rgba(225, 112, 85, 0.4);
}

.btn-break-start {
  background: linear-gradient(135deg, #fdcb6e, #e17055);
  color: #fff;
  box-shadow: 0 4px 15px rgba(253, 203, 110, 0.4);
}

.btn-break-end {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

/* ─── Staff Selection ─────────────────────────────── */
.staff-search-wrap {
  padding: 0 0 14px 0;
}

.staff-search-input {
  width: 100%;
  padding: 16px 18px;
  border: 2px solid #333;
  border-radius: 12px;
  background: #16213e;
  color: #fff;
  font-size: 20px;
  outline: none;
  -webkit-appearance: none;
}

.staff-search-input:focus {
  border-color: #e94560;
}

.staff-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.staff-list-item {
  display: flex;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid #1e2a4a;
  cursor: pointer;
  border-radius: 10px;
  margin-bottom: 4px;
  background: #16213e;
  transition: background 0.1s;
}

.staff-list-item:active {
  background: #0f3460;
}

.staff-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e94560;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-right: 16px;
}

.staff-list-info {
  flex: 1;
}

.staff-list-name {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
}

.staff-list-emp {
  font-size: 14px;
  color: #888;
  margin-top: 2px;
}

.staff-list-arrow {
  font-size: 20px;
  color: #555;
}

.staff-list-empty {
  text-align: center;
  color: #666;
  padding: 40px 20px;
  font-size: 18px;
}

/* ─── Selected Staff on PIN Screen ────────────────── */
.selected-staff-name {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: #00cec9;
  margin: 10px 0 4px;
}

/* ─── PIN Screen Body ────────────────────────────── */
.pin-screen-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── PIN Entry ───────────────────────────────────── */
.pin-display {
  text-align: center;
  margin: 10px 0;
}

.pin-dots {
  display: flex;
  justify-content: center;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #555;
  margin: 0 8px;
  transition: background 0.15s, border-color 0.15s;
}

.dot.filled {
  background: #e94560;
  border-color: #e94560;
}

.pin-error {
  color: #e94560;
  font-size: 15px;
  margin-top: 10px;
  font-weight: 500;
}

.numpad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.numpad-btn {
  height: 56px;
  border: none;
  border-radius: 10px;
  background: #16213e;
  color: #fff;
  font-size: 28px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.numpad-btn:active {
  background: #3a4a7a;
  transform: scale(0.93);
}

.numpad-submit {
  font-size: 24px;
  color: #fff;
  background: linear-gradient(135deg, #00b894, #00cec9);
}

.numpad-submit:active {
  background: linear-gradient(135deg, #00a383, #00b8b5);
  transform: scale(0.93);
}

.numpad-delete {
  font-size: 22px;
  color: #aaa;
}

/* ─── Camera / Photo ──────────────────────────────── */
.staff-greeting {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  margin: 10px 0 20px;
  color: #00cec9;
}

.camera-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #000;
  max-height: 400px;
}

#camera-video, #photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

.photo-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding-bottom: 20px;
}

.btn-open-camera {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  padding: 30px 50px;
  border-radius: 50px;
  font-size: 24px;
  font-weight: 700;
  min-height: auto;
  width: auto;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.5);
  position: relative;
  z-index: 2;
}

.btn-capture {
  background: linear-gradient(135deg, #e94560, #c0392b);
  color: #fff;
  padding: 20px 40px;
  border-radius: 50px;
  font-size: 20px;
  min-height: auto;
  width: auto;
  flex-direction: row;
}

.capture-circle {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  margin-right: 12px;
}

.btn-retake {
  background: #333;
  color: #fff;
  padding: 18px 30px;
  border-radius: 50px;
  font-size: 18px;
  min-height: auto;
  width: auto;
  margin-right: 12px;
}

.btn-confirm-photo {
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: #fff;
  padding: 18px 30px;
  border-radius: 50px;
  font-size: 18px;
  min-height: auto;
  width: auto;
}

/* ─── Confirmation Screen ─────────────────────────── */
.confirmation {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.confirm-icon {
  font-size: 80px;
  color: #00b894;
  margin-bottom: 20px;
}

.confirm-name {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
}

.confirm-action {
  font-size: 24px;
  color: #aaa;
  margin-bottom: 10px;
}

.confirm-time {
  font-size: 28px;
  font-weight: 600;
  color: #00cec9;
  margin-bottom: 20px;
}

.confirm-photo-img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #00b894;
}

/* ─── Error Screen ────────────────────────────────── */
.error-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-icon {
  font-size: 80px;
  color: #e94560;
  margin-bottom: 20px;
}

.error-message {
  font-size: 22px;
  color: #e94560;
  margin-bottom: 30px;
  max-width: 300px;
}

.btn-try-again {
  background: #333;
  color: #fff;
  padding: 18px 40px;
  border-radius: 50px;
  font-size: 18px;
  min-height: auto;
  width: auto;
}

/* ─── Register Link ──────────────────────────────────────── */
.btn-register-link {
  background: none;
  border: none;
  color: #a29bfe;
  font-size: 16px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 16px;
}

/* ─── Registration Form ─────────────────────────────────── */
.register-form {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 20px;
}

.register-row {
  display: flex;
  margin: 0 -6px;
}

.register-row .register-field {
  flex: 1;
  margin: 0 6px;
}

.register-field {
  margin-bottom: 14px;
}

.register-field label {
  display: block;
  font-size: 14px;
  color: #aaa;
  margin-bottom: 6px;
  font-weight: 600;
}

.register-field input,
.register-field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #333;
  border-radius: 10px;
  background: #16213e;
  color: #fff;
  font-size: 18px;
  outline: none;
  -webkit-appearance: none;
  font-family: inherit;
}

.register-field input:focus,
.register-field textarea:focus {
  border-color: #e94560;
}

.register-field textarea {
  resize: none;
  font-size: 16px;
}

.register-section-label {
  font-size: 16px;
  color: #6c5ce7;
  font-weight: 700;
  margin: 18px 0 10px;
  padding-top: 10px;
  border-top: 1px solid #1e2a4a;
}

.register-error {
  color: #e94560;
  font-size: 15px;
  text-align: center;
  margin: 10px 0;
  font-weight: 500;
}

.register-actions {
  margin-top: 16px;
}

/* ─── Loading Spinner ─────────────────────────────── */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 400px) {
  .clock {
    font-size: 56px;
  }
  .btn {
    padding: 20px 15px;
    font-size: 16px;
    min-height: 90px;
  }
  .btn-icon {
    font-size: 28px;
  }
  .numpad-btn {
    height: 50px;
    font-size: 24px;
  }
  .selected-staff-name { font-size: 20px; margin: 4px 0; }
  .pin-display { margin: 6px 0; }
}

@media (min-width: 768px) {
  .clock {
    font-size: 100px;
  }
  .btn {
    width: 200px;
    padding: 40px 30px;
    font-size: 22px;
  }
  .numpad {
    max-width: 360px;
    gap: 8px;
  }
  .numpad-btn {
    height: 70px;
    font-size: 34px;
  }
}

/* Landscape: compact PIN screen to fit above the fold */
@media (max-height: 500px) {
  .screen { padding: 8px 16px; }
  .header { min-height: 40px; padding: 4px 0; }
  .selected-staff-name { font-size: 18px; margin: 2px 0; }
  .pin-display { margin: 4px 0; }
  .dot { width: 14px; height: 14px; margin: 0 6px; border-width: 2px; }
  .numpad { gap: 4px; max-width: 280px; }
  .numpad-btn { height: 40px; font-size: 22px; border-radius: 8px; }
  .punch-type-label { font-size: 18px; }
}
