/* ===== PORTEIRA - FECHAMENTO DE TURNO ===== */
:root {
  --primary: #EA232F;
  --primary-light: #EA232F18;
  --cream: #F8F4EF;
  --dark: #1a1a1a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  margin: 0;
  min-height: 100vh;
  color: #1a1a1a;
}

/* ===== LAYOUT ===== */
.page-container {
  padding: 1.25rem;
  max-width: 640px;
  margin: 0 auto;
  /* padding-bottom garante que o último item não fique atrás do bottom-nav (64px) + folga */
  padding-bottom: 7rem;
}
.page-title { font-size: 1.25rem; font-weight: 800; color: #1a1a1a; margin-bottom: 1rem; }
.section-title { font-size: 0.875rem; font-weight: 700; color: #374151; margin-bottom: 0.75rem; display: flex; align-items: center; }

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 9999;
  white-space: nowrap;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== SPINNER ===== */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== INPUT FIELDS ===== */
.input-field {
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  width: 100%;
  color: #1a1a1a;
}
.input-field:focus { border-color: var(--primary); }
.input-field:disabled { background: #f9fafb; color: #9ca3af; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-correction { background: #fef3c7; color: #92400e; }
.badge-reviewed { background: #d1fae5; color: #065f46; }
.badge-approved { background: #dcfce7; color: #14532d; }

/* ===== TAGS ===== */
.tag { background: #f3f4f6; color: #374151; border-radius: 0.5rem; padding: 0.125rem 0.5rem; font-size: 0.7rem; font-weight: 500; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
body { padding-top: 56px; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0; z-index: 50;
  width: 260px; background: #fff;
  border-right: 1px solid #f3f4f6;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(0,0,0,0.4);
  display: none;
}
.sidebar-overlay.show { display: block; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: #374151; font-size: 0.9rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background 0.15s;
}
.sidebar-link:hover { background: #f9fafb; }
.sidebar-link.active { color: var(--primary); background: var(--primary-light); font-weight: 700; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff;
  border-top: 1px solid #f3f4f6;
  display: flex;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  color: #9ca3af; font-size: 0.6rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  transition: color 0.15s;
  padding: 0;
}
.bottom-nav-item i { font-size: 1.125rem; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item .bottom-fab {
  width: 3rem; height: 3rem;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: -1.25rem;
  box-shadow: 0 4px 12px rgba(234,35,47,0.4);
}
.bottom-nav-item .bottom-fab i { color: #fff; font-size: 1.25rem; }

/* ===== FORM STEPS ===== */
.step-indicator {
  display: flex; gap: 0.25rem; margin-bottom: 1.25rem;
}
.step-dot {
  flex: 1; height: 4px; border-radius: 2px; background: #e5e7eb;
  transition: background 0.3s;
}
.step-dot.active { background: var(--primary); }
.step-dot.completed { background: #10b981; }

.form-step { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== OCCURRENCE CARDS ===== */
.occurrence-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 1rem;
  padding: 0.875rem;
  margin-bottom: 0.75rem;
}
.occurrence-card.pending { border-color: #fbbf24; background: #fffbeb; }
.occurrence-card.problem { border-color: #fca5a5; background: #fff5f5; }

/* ===== COUNTER BADGES ===== */
.counter-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 9999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ===== REVIEW CARDS ===== */
.review-card {
  background: #fff;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.review-card-header {
  background: #f9fafb;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f3f4f6;
}
.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.75rem 1rem;
  gap: 0.75rem;
}
.review-item { display: flex; flex-direction: column; gap: 2px; }
.review-item.col-span-2 { grid-column: span 2; }
.review-label { font-size: 0.7rem; color: #9ca3af; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.review-value { font-size: 0.875rem; font-weight: 600; color: #1a1a1a; }

/* ===== METRIC CARDS (DASHBOARD) ===== */
.metric-card {
  background: #fff;
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.metric-icon {
  width: 2.5rem; height: 2.5rem;
  border-radius: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}
.metric-value { font-size: 1.75rem; font-weight: 900; color: #1a1a1a; line-height: 1; }
.metric-label { font-size: 0.75rem; color: #9ca3af; font-weight: 500; }

/* ===== STEP ERRORS ===== */
.step-errors {
  background: #fff5f5;
  border: 1.5px solid #fca5a5;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.step-errors p { font-size: 0.75rem; font-weight: 700; color: #dc2626; margin-bottom: 0.5rem; }
.step-errors ul { margin: 0; padding-left: 1.25rem; }
.step-errors ul li { font-size: 0.8rem; color: #b91c1c; }

/* ===== BARRA DE NAVEGAÇÃO FIXA DO FORMULÁRIO ===== */
.form-nav-bar {
  position: fixed;
  bottom: 64px; /* acima do bottom-nav */
  left: 0;
  right: 0;
  z-index: 39;
  background: #fff;
  border-top: 1px solid #f3f4f6;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.75rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

/* Botões padrão do formulário */
.btn-primary {
  background: #EA232F;
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #e5e7eb; }

.btn-ghost {
  background: transparent;
  color: #9ca3af;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-ghost:hover { border-color: #d1d5db; color: #6b7280; }

/* ===== STEP BAR ===== */
.step-bar {
  display: flex;
  gap: 4px;
}
.step-item {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  transition: background 0.3s;
}
.step-item.active  { background: #EA232F; }
.step-item.done    { background: #10b981; }

/* ===== PRINT ===== */
@media print {
  .navbar, .bottom-nav, .sidebar, .no-print,
  #mainNav, #mainSidebar, #bottomNav, #formNavBar,
  .flex.gap-2.mb-5, /* barra de ações rápidas */
  button, a.btn-primary, a.btn-secondary { display: none !important; }
  body { padding-top: 0; padding-left: 0; background: #fff; }
  .card { box-shadow: none; border: 1px solid #e5e7eb; page-break-inside: avoid; }
  .page-container { padding: 1rem; max-width: none; padding-bottom: 0; }
}

/* ===== LIGHTBOX ===== */
#photoLightbox {
  animation: fadeInLB 0.2s ease;
}
@keyframes fadeInLB {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== SKELETON LOADING ===== */
.animate-pulse > * {
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ===== DASHBOARD CHART ===== */
.dash-bar-chart rect { transition: opacity 0.2s; }

/* ===== PERIOD FILTER PILLS ===== */
/* scrollbar oculta no filtro de período */
.period-pills::-webkit-scrollbar { display: none; }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  /* No desktop não há bottom-nav, então padding-bottom menor */
  .page-container { padding: 2rem; padding-bottom: 3rem; max-width: none; }
  .sidebar { transform: translateX(0); }
  body { padding-left: 260px; }
  .bottom-nav { display: none; }
  /* No desktop, form-nav fica direto no bottom sem deslocar pelo bottom-nav */
  .form-nav-bar {
    bottom: 0;
    padding-bottom: 0.75rem;
    left: 260px; /* alinha com o conteúdo após sidebar */
  }
}
