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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Cairo', Roboto, sans-serif;
  direction: rtl;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* === App shell: header on top, camera fills the rest === */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;            /* dvh handles the mobile address bar correctly */
  width: 100%;
}

/* === Slim header === */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(90deg, #0f3a7d 0%, #1e5a96 100%);
}

.topbar-title {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock {
  text-align: left;
  line-height: 1.2;
}

#time-display {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

#date-display {
  display: block;
  font-size: 11px;
  opacity: 0.8;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
.dot.ready      { background: #10b981; }
.dot.processing { background: #f59e0b; }
.dot.error      { background: #ef4444; }

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

/* === Camera stage: fills all remaining space === */
.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Floating action buttons === */
.actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 14px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  /* dark fade so the buttons stay readable over a bright camera image */
  background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0));
  z-index: 5;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 92px;
  border: none;
  border-radius: 18px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: transform 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}

.btn:disabled { opacity: 0.5; }
.btn:not(:disabled):active { transform: scale(0.96); }

.btn-in  { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.btn-out { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.btn-icon {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.btn-label {
  font-size: 22px;
  line-height: 1.15;
}

.btn-label small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
}

/* === Result overlay === */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  z-index: 10;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadein 0.18s ease;
}

.overlay.hidden { display: none; }

.overlay.ok   { background: rgba(16, 185, 129, 0.82); }
.overlay.bad  { background: rgba(239, 68, 68, 0.82); }
.overlay.warn { background: rgba(245, 158, 11, 0.85); }

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 700;
}

.overlay-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
}

.overlay-sub {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.95;
  line-height: 1.4;
}

/* === Wider screens (tablet / desktop): scale things up === */
@media (min-width: 700px) {
  .topbar-title { font-size: 24px; }
  #time-display { font-size: 22px; }
  .btn { min-height: 120px; border-radius: 22px; }
  .btn-icon { font-size: 44px; }
  .btn-label { font-size: 28px; }
  .btn-label small { font-size: 14px; }
  .actions { gap: 20px; padding: 22px; max-width: 900px; margin: 0 auto; }
  .overlay-icon { width: 130px; height: 130px; font-size: 74px; }
  .overlay-title { font-size: 40px; }
  .overlay-sub { font-size: 24px; }
}
