/**
 * AgroGIS Pro - FarmSync WebGIS 2.0 (AgriNewBras)
 * Design System: Dark Forest & Emerald Glassmorphism
 */

:root {
  --bg-base: #040d0c;
  --bg-surface: #061412;
  --bg-card: rgba(10, 31, 28, 0.88);
  --bg-card-hover: rgba(16, 50, 45, 0.95);
  --bg-overlay: rgba(4, 13, 12, 0.75);

  --primary: #10b981;
  --primary-light: #34d399;
  --primary-dark: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);

  --accent-amber: #f59e0b;
  --accent-blue: #38bdf8;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-subtle: rgba(16, 185, 129, 0.15);
  --border-active: rgba(16, 185, 129, 0.45);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);

  --header-height: 56px;
  --bottom-nav-height: 62px;
  --sidebar-width: 380px;

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

/* Layout Container */
#app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
}

.brand-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-title span {
  color: var(--primary);
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary-light);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

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

.farm-select-pill {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.farm-select-pill:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--border-active);
}

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

.btn-header {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.25);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.status-dot.offline {
  background: var(--text-dim);
  box-shadow: none;
}

.status-dot.syncing {
  background: var(--accent-blue);
  box-shadow: 0 0 8px var(--accent-blue);
  animation: pulse-sync 1.2s infinite ease-in-out;
}

.status-dot.pending {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

@keyframes pulse-sync {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Main Workspace */
.workspace-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* WebGIS Map */
#map-container {
  flex: 1;
  height: 100%;
  width: 100%;
  position: relative;
  background: #111e1c;
  z-index: 1;
}

/* Desktop Sidebar */
.desktop-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  flex: 1;
  padding: 10px 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
  background: rgba(16, 185, 129, 0.08);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Floating Controls over Map */
.map-floating-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.glass-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
}

/* Mobile Bottom Navigation (Hidden on Desktop) */
.mobile-bottom-nav {
  display: none;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  z-index: 1000;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 700;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-nav-item span.icon {
  font-size: 20px;
}

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

/* Responsive Rules */
@media (max-width: 900px) {
  .desktop-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
    width: 85%;
    max-width: 360px;
  }

  .desktop-sidebar.open {
    transform: translateX(0);
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .brand-tag, .header-center .farm-location {
    display: none;
  }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-active);
}

/* Modais do Sistema (Glassmorphism Modal System) */
.agrogis-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 13, 12, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.agrogis-modal.active {
  display: flex;
}

.agrogis-modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  animation: modal-appear 0.25s ease-out;
}

@keyframes modal-appear {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Formulários & Controles */
.form-group {
  display: flex;
  flex-direction: column;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-control {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Botões do Sistema */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #040d0c;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: #fff;
}

.btn-secondary.active {
  background: var(--primary);
  color: #040d0c;
  border-color: var(--primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger:hover {
  background: var(--accent-red);
  color: #fff;
}

/* Mascaramento Financeiro RBAC */
.financial-masked {
  filter: blur(3px);
  user-select: none;
  cursor: not-allowed;
  color: var(--text-dim);
  transition: filter 0.2s;
}

/* Badges e Rótulos Flutuantes de Talhão no Mapa */
.agrogis-div-icon {
  background: transparent !important;
  border: none !important;
}

.talhao-map-badge {
  background: rgba(6, 20, 18, 0.9);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 0 8px var(--primary-glow);
  padding: 3px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  transform: translate(-50%, -50%);
}

.talhao-badge-name {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.talhao-badge-area {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary-light);
  line-height: 1.1;
}

/* Rótulos das Curvas de Nível Mestras */
.contour-label-icon {
  background: transparent !important;
  border: none !important;
}

/* Barra de Ações Rápidas de Mapeamento */
.gis-quick-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.gis-toolbar-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.gis-toolbar-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: #fff;
}

/* ==========================================================================
   FASE 8: ESTILOS DE IMPRESSÃO A4 (LAUDOS & CADERNO DE CAMPO) & SENSOREAMENTO
   ========================================================================== */

.print-preview-modal-content {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-active);
}

.print-page-a4 {
  width: 100%;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto 20px auto;
  padding: 16mm 18mm;
  background: #ffffff !important;
  color: #0f172a !important;
  font-family: var(--font-family);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  box-sizing: border-box;
}

.print-page-a4 strong {
  color: #0f172a !important;
}

.print-page-a4 table {
  color: #0f172a !important;
}

/* Máscara de impressão nativa do navegador (Salvar como PDF ou Imprimir) */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    height: auto !important;
    width: auto !important;
  }

  /* Oculta toda a interface WebGIS durante a impressão */
  .app-header,
  .desktop-sidebar,
  #map-container,
  .mobile-bottom-nav,
  .map-floating-panel,
  .gis-quick-toolbar,
  .no-print,
  #painelSensoriamentoRemoto,
  #rasterSwipeDivider {
    display: none !important;
  }

  /* Modais se transformam em fluxo direto de documento */
  .agrogis-modal {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .agrogis-modal-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #corpoDocumentoPDF {
    background: #ffffff !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .print-page-a4 {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
    page-break-after: always;
  }
}

/* ==========================================================================
   PORTAL GATEKEEPER: ACESSO RESTRITO AOS ASSINANTES DO PORTAL AGRINEWBRAS
   ========================================================================== */
.gatekeeper-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: radial-gradient(circle at 50% 30%, rgba(6, 40, 32, 0.96) 0%, rgba(2, 10, 8, 0.99) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gatekeeper-modal {
  width: 100%;
  max-width: 480px;
  background: rgba(10, 25, 22, 0.95);
  border: 1.5px solid rgba(16, 185, 129, 0.4);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(16, 185, 129, 0.15);
  padding: 32px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.gatekeeper-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.gatekeeper-logo {
  font-size: 42px;
  margin-bottom: 8px;
}

.gatekeeper-header h2 {
  font-size: 26px;
  font-weight: 900;
  color: #ffffff;
  margin: 0 0 4px 0;
}

.gatekeeper-header h2 span {
  color: var(--primary-light);
}

.gatekeeper-tag {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.gatekeeper-body p {
  font-size: 13.5px;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 18px;
}

.gatekeeper-features {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gatekeeper-features .gf-item {
  font-size: 12.5px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-gatekeeper-primary {
  width: 100%;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-gatekeeper-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
}

.gatekeeper-link {
  font-size: 12.5px;
  color: #34d399;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.gatekeeper-link:hover {
  color: #6ee7b7;
  text-decoration: underline;
}



