/**
 * MASTER GEO FOTO — Design System & Estilos Principais (Tema Claro Oficial)
 * Cores da Identidade Visual MASTER: Verde #00a335 e Branco
 * Foco: Alta clareza sob a luz do sol em atividades de campo, ergonomia tátil e visual premium.
 */

:root {
  --mgf-bg: #f8fafc;
  --mgf-surface: #ffffff;
  --mgf-surface-2: #f1f5f9;
  --mgf-surface-3: #e2e8f0;
  --mgf-border: #e2e8f0;
  --mgf-border-strong: #cbd5e1;
  --mgf-text: #0f172a;
  --mgf-text-muted: #64748b;
  --mgf-primary: #00a335;
  --mgf-primary-hover: #008f2e;
  --mgf-primary-light: #e8f7ec;
  --mgf-accent: #00b83c;
  --mgf-success: #00a335;
  --mgf-warning: #d97706;
  --mgf-danger: #ef4444;
  --mgf-radius: 12px;
  --mgf-radius-sm: 8px;
  --mgf-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

/* Reset e Base */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--mgf-bg);
  color: var(--mgf-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: 74px;
}

/* Tipografia e Títulos */
h1, h2, h3, h4, h5, h6 {
  color: #0f172a;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Header Superior Fixo */
.mgf-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--mgf-border);
  position: sticky;
  top: 0;
  z-index: 1020;
  padding: 10px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.mgf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #0f172a;
}

.mgf-brand-logo {
  height: 38px;
  width: auto;
}

.mgf-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges e Status */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.status-pill.online {
  background: #e8f7ec;
  color: #008f2e;
  border-color: rgba(0, 163, 53, 0.25);
}

.status-pill.offline {
  background: #fef3c7;
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.25);
}

.status-pill.gps-ok {
  background: #e8f7ec;
  color: #008f2e;
  border-color: rgba(0, 163, 53, 0.25);
}

.status-pill.gps-waiting {
  background: #fef3c7;
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.25);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.pulse {
  animation: mgf-pulse 2s infinite;
}

@keyframes mgf-pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Containers e Vistas */
.app-view {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards e Superfícies */
.mgf-card {
  background: var(--mgf-surface);
  border: 1px solid var(--mgf-border);
  border-radius: var(--mgf-radius);
  box-shadow: var(--mgf-shadow);
  padding: 18px;
  margin-bottom: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.mgf-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* Contadores e Métricas */
.counter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .counter-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: #ffffff;
  border: 1px solid var(--mgf-border);
  border-radius: var(--mgf-radius-sm);
  padding: 14px 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.stat-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--mgf-primary);
}

.stat-box.success::before { background: var(--mgf-success); }
.stat-box.warning::before { background: var(--mgf-warning); }
.stat-box.info::before { background: var(--mgf-primary); }

.stat-box .stat-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-box .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--mgf-text-muted);
  letter-spacing: 0.04em;
}

/* Botões de Ação Rápida (Tema MASTER Verde) */
.btn-action-primary {
  background: linear-gradient(135deg, #00b83c 0%, #008f2e 100%);
  color: #ffffff !important;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 16px 20px;
  border-radius: var(--mgf-radius);
  border: none;
  box-shadow: 0 4px 14px rgba(0, 163, 53, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 58px;
}

.btn-action-primary:active {
  transform: scale(0.98);
}

.btn-action-primary:hover {
  background: linear-gradient(135deg, #00cb42 0%, #009e33 100%);
  color: #ffffff !important;
  box-shadow: 0 6px 18px rgba(0, 163, 53, 0.4);
}

.btn-action-secondary {
  background: #ffffff;
  color: #0f172a !important;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: var(--mgf-radius);
  border: 1px solid var(--mgf-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 50px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.btn-action-secondary:hover {
  background: var(--mgf-surface-2);
  border-color: var(--mgf-primary);
  color: var(--mgf-primary) !important;
}

/* VISTA DA CÂMERA (DESIGN EXPANSIVO E ERGONÔMICO) */
#view-camera.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}

.camera-container {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  background: #000000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  height: calc(100dvh - 160px);
  min-height: 480px;
}

.camera-viewport {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000000;
}

.camera-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Retículo e Viewfinder da Câmera */
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0.5) 100%);
}

.viewfinder-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 160px;
  height: 160px;
  pointer-events: none;
  opacity: 0.85;
}

/* Cantoneiras de enquadramento profissional */
.viewfinder-crosshair::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(to right, #00b83c 22px, transparent 22px) 0 0,
    linear-gradient(to bottom, #00b83c 22px, transparent 22px) 0 0,
    linear-gradient(to left, #00b83c 22px, transparent 22px) 100% 0,
    linear-gradient(to bottom, #00b83c 22px, transparent 22px) 100% 0,
    linear-gradient(to right, #00b83c 22px, transparent 22px) 0 100%,
    linear-gradient(to top, #00b83c 22px, transparent 22px) 0 100%,
    linear-gradient(to left, #00b83c 22px, transparent 22px) 100% 100%,
    linear-gradient(to top, #00b83c 22px, transparent 22px) 100% 100%;
  background-repeat: no-repeat;
  background-size: 22px 22px;
}

/* Ponto de mira central */
.viewfinder-crosshair::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  background:
    linear-gradient(#00b83c, #00b83c) center/2px 100% no-repeat,
    linear-gradient(#00b83c, #00b83c) center/100% 2px no-repeat;
}

/* Indicador HUD na Câmera */
.camera-hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.hud-badge {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0, 163, 53, 0.45);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Barra de Controles da Câmera */
.camera-controls-bar {
  background: #0f172a;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  z-index: 10;
}

.btn-camera-control {
  background: #1e293b;
  border: 1px solid #334155;
  color: #ffffff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-camera-control:active {
  transform: scale(0.92);
}

/* Botão de Disparo Shutter Principal (Verde MASTER) */
.btn-shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--mgf-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 163, 53, 0.5);
  position: relative;
  transition: transform 0.15s ease;
}

.btn-shutter-inner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00b83c 0%, #008f2e 100%);
  border: 2px solid #ffffff;
}

.btn-shutter:active {
  transform: scale(0.92);
}

/* Preview após captura */
.preview-container {
  display: none;
  background: var(--mgf-surface);
  border: 1px solid var(--mgf-border);
  border-radius: var(--mgf-radius);
  padding: 16px;
  margin-top: 16px;
}

.preview-container.active {
  display: block;
}

.preview-image-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--mgf-radius-sm);
  overflow: hidden;
  background: #000000;
  margin-bottom: 14px;
  box-shadow: var(--mgf-shadow);
}

.preview-image-wrapper img {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  display: block;
}

/* GALERIA & CARDS */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 14px;
}

@media (min-width: 576px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.photo-card {
  background: var(--mgf-surface);
  border: 1px solid var(--mgf-border);
  border-radius: var(--mgf-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  box-shadow: var(--mgf-shadow);
}

.photo-card:hover {
  transform: translateY(-2px);
  border-color: var(--mgf-primary);
  box-shadow: 0 6px 18px rgba(0, 163, 53, 0.12);
}

.photo-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000000;
  overflow: hidden;
}

.photo-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.photo-card:hover .photo-card-img-wrap img {
  transform: scale(1.03);
}

.photo-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 8px;
}

.photo-card-timestamp {
  font-size: 0.8rem;
  color: var(--mgf-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-card-coords {
  font-family: monospace;
  font-size: 0.78rem;
  color: #008f2e;
  font-weight: 600;
  word-break: break-all;
}

.photo-card-notes {
  font-size: 0.85rem;
  color: var(--mgf-text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* BARRA DE NAVEGAÇÃO INFERIOR FIXA (TEMA CLARO) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--mgf-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item-btn {
  background: transparent;
  border: none;
  color: var(--mgf-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
  min-width: 64px;
}

.nav-item-btn svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  fill: currentColor;
}

.nav-item-btn.active {
  color: var(--mgf-primary);
}

.nav-item-btn:active {
  transform: scale(0.92);
}

/* Botão Flutuante de Captura na Navegação */
.nav-item-btn.capture-highlight {
  position: relative;
  top: -12px;
  background: linear-gradient(135deg, #00b83c 0%, #008f2e 100%);
  color: #ffffff;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 163, 53, 0.45);
  border: 3px solid var(--mgf-bg);
  padding: 0;
}

.nav-item-btn.capture-highlight svg {
  width: 26px;
  height: 26px;
  margin-bottom: 0;
  fill: #ffffff;
}

/* Modais Customizados (Tema Claro) */
.modal-content {
  background: #ffffff;
  border: 1px solid var(--mgf-border);
  border-radius: var(--mgf-radius);
  color: var(--mgf-text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal-header {
  border-bottom: 1px solid var(--mgf-border);
  padding: 16px 20px;
}

.modal-footer {
  border-top: 1px solid var(--mgf-border);
  padding: 14px 20px;
}

/* Formulários e Inputs */
.form-control, .form-select {
  background-color: #ffffff !important;
  border: 1px solid var(--mgf-border-strong) !important;
  color: #0f172a !important;
  border-radius: var(--mgf-radius-sm) !important;
  padding: 10px 14px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--mgf-primary) !important;
  box-shadow: 0 0 0 3px rgba(0, 163, 53, 0.2) !important;
}

.form-label {
  color: var(--mgf-text);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Barra de Progresso */
.progress {
  background-color: var(--mgf-surface-2);
  border-radius: 10px;
  height: 12px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #00a335, #00cb42);
}

/* Notificações Toasts */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 16px;
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  z-index: 1090;
  pointer-events: none;
}

.mgf-toast {
  background: #ffffff;
  border: 1px solid var(--mgf-border);
  border-left: 4px solid var(--mgf-primary);
  border-radius: var(--mgf-radius-sm);
  padding: 12px 16px;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
}

.mgf-toast.success { border-left-color: var(--mgf-success); }
.mgf-toast.warning { border-left-color: var(--mgf-warning); }
.mgf-toast.danger { border-left-color: var(--mgf-danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Banner de Contingência Offline */
.offline-banner {
  background: #fef3c7;
  border-bottom: 1px solid rgba(217, 119, 6, 0.25);
  color: #92400e;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  display: none;
}

.offline-banner.active {
  display: block;
}

/* Utilitários de Imagem e Visor */
.detail-photo-view {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  background: #0f172a;
  border-radius: var(--mgf-radius-sm);
}

.table-light-custom {
  color: #0f172a;
  font-size: 0.88rem;
}

.table-light-custom td {
  padding: 8px 12px;
  border-color: var(--mgf-border);
}

.table-light-custom td:first-child {
  color: var(--mgf-text-muted);
  font-weight: 600;
  width: 35%;
}

/* Proteção contra FOUC (Flash de tela antes do Login) */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #f8fafc;
  z-index: 2050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

html.is-authenticated #appLoginOverlay {
  display: none !important;
}

/* Ajustes Responsivos de Campo para Smartphones */
@media (max-width: 576px) {
  #view-camera.active {
    margin: -1rem -0.75rem 0 -0.75rem;
  }

  #view-camera .camera-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    height: calc(100vh - 138px);
    height: calc(100dvh - 138px);
    min-height: 480px;
  }

  #view-camera .preview-container {
    margin: 16px 12px;
  }
}

