/**
 * Estilos Principais • Amostra Aí WebGIS
 * Brant Solutions | AgriNewBras • Prof. Dr. Santos H. B. Dias
 * 
 * Regra Suprema de Contraste Cromático e Acessibilidade Visual (WCAG AAA):
 * - Textos sobre fundos escuros declarados com #FFFFFF !important ou #F1F5F9 !important
 * - Textos sobre fundos claros declarados com #0F172A !important
 * - Proibição absoluta de texto escuro sobre fundo escuro ou texto claro sobre fundo claro
 */

:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-subtle: #334155;
  --primary-emerald: #10b981;
  --primary-hover: #059669;
  --primary-light: #d1fae5;
  --accent-cyan: #06b6d4;
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --text-white: #ffffff;
  --text-light: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-dark: #0f172a;
  --border-color: rgba(255, 255, 255, 0.12);
  --border-highlight: rgba(16, 185, 129, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-light);
  user-select: none;
}

/* ==============================================================================
   ESTRUTURA GERAL DA APLICAÇÃO (LAYOUT FULLSCREEN)
   ============================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Altura dinâmica para navegadores móveis */
  position: relative;
  overflow: hidden;
}

/* Header Superior Compacto */
.top-header {
  height: 58px;
  background-color: #0b1329;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary-emerald), var(--accent-cyan));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-version {
  font-size: 0.65rem;
  font-weight: 700;
  background-color: rgba(16, 185, 129, 0.2);
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

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

.btn-header {
  background-color: var(--bg-card);
  color: #ffffff !important;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background-color: var(--bg-card-subtle);
  border-color: var(--primary-emerald);
}

.btn-header.btn-pwa-install {
  background: linear-gradient(135deg, var(--primary-emerald), #059669);
  color: #ffffff !important;
  border: none;
}

/* Área do Mapa Leaflet */
.map-wrapper {
  flex: 1;
  width: 100%;
  position: relative;
  z-index: 1;
}

#map {
  width: 100%;
  height: 100%;
  background-color: #1e293b;
}

/* Controles Flutuantes sobre o Mapa */
.map-floating-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.floating-btn {
  width: 44px;
  height: 44px;
  background-color: #0f172a;
  color: #ffffff !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.floating-btn:hover, .floating-btn:active {
  background-color: var(--primary-emerald);
  color: #ffffff !important;
  transform: scale(1.05);
}

.floating-btn.active {
  background-color: var(--primary-emerald);
  border-color: #34d399;
}

/* Alerta HUD de GPS / Ponto Ativo */
.gps-hud-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--primary-emerald);
  border-radius: var(--radius-full);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: 90vw;
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.gps-hud-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff !important;
}

.gps-hud-dist {
  font-size: 0.95rem;
  font-weight: 800;
  color: #34d399 !important;
}

.gps-hud-arrow {
  display: inline-block;
  font-size: 1.1rem;
  transition: transform 0.3s ease;
}

/* ==============================================================================
   PAINEL INFERIOR DESLIZÁVEL (BOTTOM SHEET PARA SMARTPHONES E DESKTOP)
   ============================================================================== */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s ease;
  max-height: 85vh;
}

.bottom-sheet.collapsed {
  height: 64px !important;
  overflow: hidden;
}

.sheet-handle-bar {
  width: 100%;
  padding: 10px 0 4px 0;
  display: flex;
  justify-content: center;
  cursor: pointer;
}

.sheet-pill {
  width: 44px;
  height: 5px;
  background-color: #64748b;
  border-radius: var(--radius-full);
}

/* Barra de Abas do Painel */
.sheet-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 12px;
  gap: 6px;
}

.sheet-tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  color: #cbd5e1 !important;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #ffffff !important;
}

.tab-btn.active {
  color: #34d399 !important;
  border-bottom-color: var(--primary-emerald);
}

/* Conteúdo das Abas */
.sheet-content {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-pane.active {
  display: block;
}

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

/* Grupos de Formulário e Cards */
.form-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.form-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff !important;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1 !important;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background-color: #0b1329;
  border: 1px solid var(--border-color);
  color: #ffffff !important;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary-emerald);
}

/* Seletor de Métodos (Radio Tiles) */
.method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.method-card {
  background-color: #0b1329;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.method-card:hover {
  border-color: #475569;
}

.method-card.active {
  border-color: var(--primary-emerald);
  background-color: rgba(16, 185, 129, 0.1);
}

.method-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff !important;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.method-card-desc {
  font-size: 0.75rem;
  color: #94a3b8 !important;
  line-height: 1.3;
}

/* Badges e Notificações de Alerta */
.alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24 !important;
}

.alert-info {
  background-color: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #38bdf8 !important;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399 !important;
}

/* Estatísticas Rápidas (Grid 2 ou 3 colunas) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat-item {
  background-color: #0b1329;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8 !important;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff !important;
  margin-top: 2px;
}

.stat-value.highlight {
  color: #34d399 !important;
}

/* Botões de Ação Primária */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-emerald), #059669);
  color: #ffffff !important;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  width: 100%;
  background-color: var(--bg-card-subtle);
  color: #ffffff !important;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: #475569;
}

/* Lista de Pontos e Navegação */
.points-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #0b1329;
}

.point-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background-color 0.15s ease;
}

.point-row:hover {
  background-color: var(--bg-card);
}

.point-row.active {
  background-color: rgba(16, 185, 129, 0.15);
  border-left: 3px solid var(--primary-emerald);
}

.point-row.collected {
  opacity: 0.6;
  text-decoration: line-through;
}

.badge-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-complete {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-routine {
  background-color: rgba(59, 130, 246, 0.2);
  color: #60a5fa !important;
  border: 1px solid rgba(59, 130, 246, 0.4);
}
