/* =============================================================
   PontoSnap Colaborador App - Design System
   Colors: #2baee0 (primary), #0122b1 (dark), #fff
   Fonts: Signika (headings), Inter (body)
   ============================================================= */

:root {
  --primary:      #2baee0;
  --primary-dark: #0122b1;
  --bg-dark:      #010d3e;
  --grad:         linear-gradient(135deg, #2baee0 0%, #0122b1 100%);
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --text:         #1a1a2e;
  --text-muted:   #6c757d;
  --border:       #e9ecef;
  --bg:           #f5f7fa;
  --white:        #fff;
  --radius:       16px;
  --radius-sm:    10px;
  --nav-height:   64px;
  --header-height:60px;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --font-head:    'Signika', sans-serif;
  --font-body:    'Inter', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }

/* ── Update Banner ── */
.update-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #2bace0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: .85rem;
  padding-top: calc(10px + var(--safe-top));
}
.update-banner button {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Login Page ── */
.login-page {
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
}

.login-container {
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  backdrop-filter: blur(10px);
}

.login-logo h1 {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

.login-logo p {
  font-size: .875rem;
  color: rgba(255,255,255,.75);
  margin-top: 4px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(1,13,62,.3);
}

.field-group {
  margin-bottom: 20px;
}

.field-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrap input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 42px 12px 42px;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  background: #f9fafb;
}

.input-icon-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(43,174,224,.15);
}

.field-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.btn-toggle-pin {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
}

.btn-primary-full {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: #2bace0;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .2s, transform .1s;
}

.btn-primary-full:active { transform: scale(.98); opacity: .9; }
.btn-primary-full:disabled { opacity: .6; cursor: not-allowed; }

.btn-outline-full {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .2s;
}

.btn-outline-full:active { background: rgba(43,174,224,.06); }

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: .8rem;
  color: rgba(255,255,255,.6);
}

.login-footer a { color: rgba(255,255,255,.85); }

/* ── Flash messages ── */
.flash-msg {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 16px;
}
.flash-error   { background: rgba(239,68,68,.1); color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.flash-success { background: rgba(16,185,129,.1); color: #059669; border: 1px solid rgba(16,185,129,.2); }
.flash-info    { background: rgba(43,174,224,.1); color: var(--primary-dark); border: 1px solid rgba(43,174,224,.2); }

/* ── App pages ── */
.app-page {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  min-height: 100svh;
}

/* ── App Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header-left { display: flex; align-items: center; gap: 12px; }

.avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad);
  color: #fff; font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.header-name   { font-weight: 600; font-size: .9rem; }
.header-company { font-size: .75rem; color: var(--text-muted); }
.header-title  { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }

.btn-icon {
  width: 38px; height: 38px;
  border: none; border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s;
}
.btn-icon:active { background: var(--border); }

/* ── Clock section ── */
.clock-section {
  background: var(--grad);
  padding: 24px 20px;
  text-align: center;
  color: #fff;
}

.clock-time {
  font-family: var(--font-head);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
}

.clock-date {
  font-size: .9rem;
  opacity: .85;
  margin-top: 6px;
  text-transform: capitalize;
}

.clock-status {
  margin-top: 8px;
  font-size: .8rem;
  opacity: .7;
}

/* ── Home action section ── */
.action-section { padding: 20px 16px; }

.registro-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
  padding: 24px;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.tipo-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(16,185,129,.12);
  color: var(--success);
}

.tipo-label {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.btn-registro {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(43,174,224,.4);
  transition: transform .15s, box-shadow .15s;
}
.btn-registro:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(43,174,224,.3); }

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-height) + var(--safe-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 500;
  padding: 8px 0;
  transition: color .2s;
}

.nav-item.active { color: var(--primary); }
.nav-item svg { transition: stroke .2s; }
.nav-item.active svg { stroke: var(--primary); }

/* ── Ponto page ── */
.ponto-container {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  gap: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.step-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--border);
  transition: background .3s;
}
.step.active .step-dot { background: var(--primary); }
.step span { font-size: .7rem; color: var(--text-muted); }
.step.active span { color: var(--primary); font-weight: 600; }
.step-line { width: 40px; height: 1px; background: var(--border); margin: 0 4px 18px; }

.ponto-step { padding: 8px 0; }

.step-icon {
  width: 72px; height: 72px;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.step-icon-blue { background: rgba(43,174,224,.12); color: var(--primary); }
.step-icon-green { background: rgba(16,185,129,.1); color: var(--success); }

.step-title {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.step-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.location-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.location-status { font-weight: 600; margin-bottom: 4px; }
.location-detail { font-size: .82rem; color: var(--text-muted); }

.badge-success { background: rgba(16,185,129,.12); color: var(--success); padding: 4px 12px; border-radius: 20px; }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); padding: 4px 12px; border-radius: 20px; }
.badge-info    { background: rgba(43,174,224,.12); color: var(--primary); padding: 4px 12px; border-radius: 20px; }

/* ── Camera / Face ── */
.cam-wrapper {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  aspect-ratio: 3/4;
}

.face-video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror front camera */
}

.face-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform: scaleX(-1);
  pointer-events: none;
}

.face-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.face-ring {
  width: 200px; height: 200px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4);
  position: relative;
  transition: border-color .3s;
}

.face-ring.detecting { border-color: var(--warning); animation: pulse-ring .8s infinite; }
.face-ring.success   { border-color: var(--success); }
.face-ring.error     { border-color: var(--danger); }

.face-ring-inner {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,.2);
}

.face-hint {
  margin-top: 16px;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.face-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.face-status-text { font-size: .875rem; font-weight: 500; }

.face-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.face-progress-bar {
  height: 100%;
  background: var(--grad);
  border-radius: 2px;
  transition: width .3s;
}

@keyframes pulse-ring {
  0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,.4); }
  50%      { box-shadow: 0 0 0 12px rgba(245,158,11,0); }
}

/* ── Confirm / Result ── */
.result-success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(16,185,129,.12);
  color: var(--success);
  font-size: 2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  animation: popIn .3s ease;
}

.result-error-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(239,68,68,.1);
  color: var(--danger);
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

@keyframes popIn {
  0%   { transform: scale(0); opacity: 0; }
  80%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.comprovante-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 16px;
  margin: 16px 0;
}

.comp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.comp-row:last-child { border: none; }
.comp-label { color: var(--text-muted); }
.comp-value { font-weight: 600; text-align: right; }

.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.just-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: .9rem;
  font-family: var(--font-body);
  resize: vertical;
  min-height: 80px;
}
.just-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,174,224,.15); }

/* ── Historico ── */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.month-label { font-family: var(--font-head); font-weight: 600; font-size: 1rem; text-transform: capitalize; }

.btn-month {
  width: 36px; height: 36px;
  border: none; border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-month:disabled { opacity: .4; }

.hist-summary {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.summary-item {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  border-right: 1px solid var(--border);
}
.summary-item:last-child { border: none; }
.summary-value { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); }
.summary-label { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px 20px; }
.empty-center   { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; gap: 12px; color: var(--text-muted); font-size: .9rem; }

.hist-list { padding: 0 16px 16px; }

.hist-date-header {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
  padding: 16px 0 8px;
  letter-spacing: .04em;
}

.hist-row {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.hist-row.hist-external { border-left: 3px solid var(--warning); }

.hist-row-left { display: flex; align-items: center; gap: 14px; }

.hist-tipo {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.hist-tipo.entrada { background: rgba(16,185,129,.1); color: var(--success); }
.hist-tipo.saida   { background: rgba(239,68,68,.1); color: var(--danger); }

.hist-hora { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }
.hist-sub  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.badge-ext {
  background: rgba(245,158,11,.12);
  color: var(--warning);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
}

.btn-hist-action {
  width: 36px; height: 36px;
  border: none; border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ── Justificativa page ── */
.page-content { padding: 16px; max-width: 480px; margin: 0 auto; }

.section-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.section-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.opt-label, .req-label { font-weight: 400; font-size: .78rem; }
.req-label { color: var(--danger); }

.tipo-options { display: flex; flex-direction: column; gap: 10px; }

.tipo-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
}

.tipo-option input[type="radio"] { display: none; }

.tipo-option.selected {
  border-color: var(--primary);
  background: rgba(43,174,224,.04);
}

.tipo-option-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.tipo-option-text { flex: 1; }
.tipo-option-title { display: block; font-weight: 600; font-size: .9rem; }
.tipo-option-desc  { display: block; font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.tipo-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: transparent;
  flex-shrink: 0;
  transition: all .2s;
}
.tipo-option.selected .tipo-check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.select-field {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: .9rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}
.select-field:focus { outline: none; border-color: var(--primary); }

.char-count { font-size: .75rem; color: var(--text-muted); text-align: right; margin-top: 4px; }

.just-list { display: flex; flex-direction: column; gap: 10px; }
.just-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.just-item-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.just-tipo { font-weight: 600; font-size: .82rem; }
.just-desc { font-size: .8rem; color: var(--text-muted); }
.just-date { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Install page ── */
.install-page {
  background: var(--grad);
  min-height: 100svh;
  padding: 40px 20px;
  padding-top: calc(40px + var(--safe-top));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.install-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  margin-top: 24px;
}

.install-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.install-step:last-child { border: none; }
.install-step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grad);
  color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.install-step-title { font-weight: 600; font-size: .9rem; margin-bottom: 2px; }
.install-step-desc  { font-size: .82rem; color: var(--text-muted); }

/* ── Spinners ── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.spinner-lg {
  display: inline-block;
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.spinner-wrap { display: flex; justify-content: center; margin: 24px 0; }

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

/* ── Offline page ── */
.offline-page {
  background: var(--grad);
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  padding: 20px;
}

.offline-card {
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 380px;
}

/* ── Utilities ── */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
