/**
 * STYLE.CSS — Ponto Digital PWA
 * Visual escuro, mobile-first, botoes grandes
 */

/* ══════ RESET & BASE ══════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #253349;
  --primary: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text: #f1f5f9;
  --text-sub: #94a3b8;
  --text-muted: #64748b;
  --radius: 16px;
  --radius-sm: 12px;
  --btn-min-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ══════ TELAS ══════ */
.tela {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateX(30px);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tela.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.tela.exit-left {
  transform: translateX(-30px);
}

/* ══════ TELA 1 — EMPRESA ══════ */
.center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 32px;
}

.app-logo {
  text-align: center;
}

.logo-icon {
  font-size: 56px;
  margin-bottom: 8px;
}

.app-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary);
}

.app-clock {
  font-size: 18px;
  color: var(--text-sub);
  margin-top: 4px;
  font-weight: 500;
}

.user-greeting {
  font-size: 16px;
  color: var(--success);
  margin-top: 8px;
  font-weight: 600;
}

.empresa-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

.btn-empresa {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 20px 24px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  min-height: var(--btn-min-h);
}

.btn-empresa:active {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(0.97);
}

.empresa-icon { font-size: 28px; }
.empresa-nome { flex: 1; text-align: left; }

.admin-link {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
}

.btn-admin {
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.offline-banner {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 20px;
  background: var(--warning);
  color: #000;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
}

.hidden { display: none !important; }

/* ══════ TELA 2 — FUNCIONARIOS ══════ */
.tela-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
}

.btn-back:active { background: rgba(255,255,255,0.1); }

.tela-header h2 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.tela-subtitle {
  padding: 16px 20px 8px;
  color: var(--text-sub);
  font-size: 15px;
}

.func-list {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.func-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.func-card:active {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(0.98);
}

.func-card.completo { opacity: 0.6; }

.func-nome {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.func-status {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.func-status.pendente { color: var(--text-muted); }
.func-status.entrada { color: var(--success); }
.func-status.almoco { color: var(--warning); }
.func-status.retorno { color: var(--info); }
.func-status.completo { color: var(--success); }
.func-status.falta { color: var(--danger); }

/* ══════ TELA 3 — BATER PONTO ══════ */
.ponto-content {
  flex: 1;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ponto-info {
  text-align: center;
}

.ponto-data {
  font-size: 15px;
  color: var(--text-sub);
}

.ponto-hora {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 1px;
}

.ponto-status-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.6;
}

.status-previsto {
  color: var(--text-sub);
}

.status-label {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 6px;
}

.status-label.ok { background: rgba(34,197,94,0.15); color: var(--success); }
.status-label.atraso { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-label.adiantado { background: rgba(59,130,246,0.15); color: var(--info); }
.status-label.extra { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Camera */
.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  max-height: 220px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  color: var(--text-sub);
  font-size: 14px;
  transition: opacity 0.3s;
}

.camera-overlay.hidden { opacity: 0; pointer-events: none; }

.camera-error {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  text-align: center;
  font-size: 14px;
}

/* GPS */
.gps-status {
  font-size: 14px;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

.gps-status.ok { color: var(--success); }
.gps-status.error { color: var(--text-muted); }

/* Botao de ponto */
.btn-ponto {
  width: 100%;
  min-height: 70px;
  border: none;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary);
  margin-top: auto;
}

.btn-ponto:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ponto:not(:disabled):active {
  transform: scale(0.97);
  filter: brightness(0.9);
}

.btn-ponto.entrada { background: var(--success); }
.btn-ponto.saida-almoco { background: var(--warning); color: #000; }
.btn-ponto.retorno-almoco { background: var(--info); }
.btn-ponto.saida { background: var(--danger); }

.ponto-completo {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-sub);
}

.completo-icon { font-size: 48px; }

/* ══════ TELA 4 — CONFIRMACAO ══════ */
#tela-4 {
  background: var(--success);
}

.confirmacao-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 8px;
  text-align: center;
}

.confirmacao-check {
  font-size: 64px;
  margin-bottom: 8px;
}

.confirmacao-content h2 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.conf-nome {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

.conf-tipo {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.2);
  padding: 6px 16px;
  border-radius: 8px;
  margin: 4px 0;
}

.conf-horario {
  font-size: 15px;
  color: rgba(255,255,255,0.8);
}

.conf-foto-container {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.5);
  margin: 8px 0;
}

.conf-foto {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conf-gps {
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
}

.conf-countdown {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  font-weight: 600;
  margin-top: 12px;
}

/* ══════ MODAL ══════ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 16px;
}

.modal-content input {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--text-muted);
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  text-align: center;
  letter-spacing: 8px;
  outline: none;
}

.modal-content input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-cancel {
  background: rgba(255,255,255,0.1);
  color: var(--text-sub);
}

.btn-confirm {
  background: var(--primary);
  color: #fff;
}

/* ══════ SCROLLBAR ══════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* ══════ LOADING SPINNER ══════ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

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

/* ══════ TOAST ══════ */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  text-align: center;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.offline {
  background: var(--warning);
  color: #000;
}

/* ══════ LOGIN SCREEN ══════ */
.screen { min-height: 100vh; }
.login-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 24px;
  background: #0f172a;
}
.login-icon { font-size: 64px; margin-bottom: 16px; }
.login-title { color: #f1f5f9; font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { color: #94a3b8; font-size: 14px; margin-bottom: 32px; }
.login-form { width: 100%; max-width: 320px; }
.login-form input {
  width: 100%; padding: 14px 16px; margin-bottom: 12px;
  background: #1e293b; border: 1px solid #334155; border-radius: 12px;
  color: #f1f5f9; font-size: 16px; font-family: inherit;
  outline: none; box-sizing: border-box;
}
.login-form input:focus { border-color: #6366f1; }
.login-form input::placeholder { color: #64748b; }
.btn-login {
  width: 100%; padding: 16px; background: #22c55e; color: #fff;
  border: none; border-radius: 12px; font-size: 16px; font-weight: 700;
  cursor: pointer; font-family: inherit; margin-top: 8px;
}
.btn-login:disabled { opacity: 0.6; }
.login-error { color: #ef4444; font-size: 13px; text-align: center; margin-top: 12px; min-height: 20px; }

/* ══════ LOGOUT BUTTON ══════ */
.btn-logout {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 50;
  font-family: inherit;
}
.btn-logout:active { background: rgba(255,255,255,0.15); }
