/* Geo — estilos locais (sobre sublote-visual-system.css) */

.main-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tool-map {
  flex: 1;
  height: 100%;
  min-width: 0;
  background: var(--bg-dark);
  z-index: 1;
}

.map-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.brand-subtitle {
  margin-left: 0;
  font-size: 11px;
}

.registry-toggle {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
}

.registry-toggle__btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-default);
  white-space: nowrap;
}

.registry-toggle__btn:hover {
  color: var(--text-main);
}

.registry-toggle__btn--active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.registry-toggle__btn--active:hover {
  color: #fff;
}

/* Sidebar à esquerda nesta ferramenta */
.tool-sidebar {
  position: relative;
  right: auto;
  left: 0;
  width: 340px;
  min-width: 340px;
  max-width: 340px;
  height: 100%;
  border-left: none;
  border-right: 1px solid var(--border-color);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.tool-map {
  flex: 1;
  height: 100%;
  min-width: 0;
  background: var(--bg-dark);
  z-index: 1;
}

.tool-footer {
  padding: 8px var(--space-xl);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--header-bg);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(var(--blur-md));
}

.tool-footer p {
  margin: 0;
}

.tool-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-default);
}

.tool-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tool-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px 12px;
}

.parcel-title {
  font-size: 15px;
  word-break: break-word;
  line-height: 1.35;
}

.metric-item--full {
  grid-column: 1 / -1;
}

.metric-value--text {
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.35;
  color: var(--text-main) !important;
}

.tool-doc-hint {
  display: block;
  margin-top: var(--space-sm);
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
}

.tool-dl {
  display: grid;
  gap: 8px;
}

.tool-dl > div {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 8px;
  font-size: 12px;
}

.tool-dl dt {
  color: var(--text-muted);
}

.tool-dl dd {
  margin: 0;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

.tool-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 0 4px;
}

.tool-action-hub {
  width: 100%;
  justify-content: center;
  font-size: 15px;
  padding: 12px 16px;
}

.tool-actions-secondary {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.tool-action-sm {
  width: 100%;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
  padding: 9px 14px;
  white-space: normal;
  box-sizing: border-box;
}

.tool-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.tool-status {
  margin-top: auto;
}

.tool-status--error {
  color: var(--danger) !important;
}

.tool-status--success {
  color: var(--accent) !important;
}

#panel-details {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
}

#panel {
  gap: var(--space-md);
}

/* Leaflet */
.leaflet-control-zoom a {
  background: var(--glass-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  backdrop-filter: blur(var(--blur-sm));
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card) !important;
  color: var(--primary) !important;
}

.leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.75) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--cyan) !important;
}

/* Bottom sheet mobile (Geo) */
.geo-panel-drag-handle {
  display: none;
}

.mobile-drawer-overlay {
  display: none;
}

@media (max-width: 900px) {
  .app-container {
    height: 100dvh;
  }

  .app-header--with-search {
    flex-wrap: wrap;
    min-height: 56px;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    align-items: center;
  }

  /* Tema + perfil na 1ª linha com a logo; Desenhar/Azimutes sobem para a faixa abaixo da busca */
  .app-header--with-search > .header-toolbar-end {
    display: contents;
  }

  .app-header--with-search > .header-brand-group {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  .app-header--with-search .btn-theme-toggle {
    order: 2;
    flex-shrink: 0;
  }

  .app-header--with-search .header-account-btn {
    order: 3;
    flex-shrink: 0;
  }

  .app-header--with-search > .header-search-group {
    order: 4;
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    padding: 4px 4px 4px 8px;
  }

  .app-header--with-search .geo-import-actions {
    order: 5;
    display: flex;
    width: 100%;
    flex: 1 1 100%;
    gap: 8px;
  }

  .app-header--with-search .geo-import-actions .geo-import-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .brand-subtitle {
    display: none;
  }

  .registry-toggle {
    width: auto;
    flex-shrink: 0;
  }

  .registry-toggle__btn {
    padding: 7px 10px;
    font-size: 11px;
  }

  .header-search-input {
    font-size: 16px;
    min-width: 0;
  }

  .btn-search-input-inside {
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .main-workspace {
    position: relative;
  }

  .tool-map {
    width: 100%;
    height: 100%;
  }

  .map-viewport {
    width: 100%;
    flex: 1;
  }

  .geo-panel-drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 8px 12px 4px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
  }

  .geo-panel-drag-handle:active {
    cursor: grabbing;
  }

  .geo-panel-drag-handle .drag-pill {
    width: 48px;
    height: 5px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 3px;
    margin-bottom: 6px;
    transition: background 0.2s ease, width 0.2s ease;
  }

  .geo-panel-drag-handle:active .drag-pill,
  .tool-sidebar.mobile-drawer-open .geo-panel-drag-handle .drag-pill {
    background: var(--cyan);
    width: 56px;
  }

  .geo-panel-peek-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tool-sidebar.geo-panel-has-selection .geo-panel-peek-label {
    color: var(--text-main);
  }

  .mobile-drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .mobile-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .tool-sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: min(85dvh, 85vh) !important;
    border-right: none !important;
    border-top: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    border-radius: 18px 18px 0 0 !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55) !important;
    z-index: 40 !important;
    transform: translateY(calc(100% - 56px - env(safe-area-inset-bottom, 0px)));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    padding: 0 var(--space-lg) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .tool-sidebar.mobile-drawer-open {
    transform: translateY(0) !important;
    max-height: 92dvh !important;
    border-radius: 0 !important;
  }

  #panel-intro {
    display: block;
  }

  .tool-sidebar.geo-panel-has-selection #panel-intro {
    display: none;
  }

  .tool-footer {
    display: none;
  }

  .modal-card {
    max-height: min(90dvh, 92vh);
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .brand-logo-img {
    height: 28px;
  }

  .brand-title {
    font-size: 15px;
  }
}

/* ── Modal pós-download & promos do ecossistema ── */

body.modal-open {
  overflow: hidden;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-overlay:not(.hidden) {
  display: flex;
}

.download-ready-card {
  width: min(520px, 94vw);
  animation: modal-fade-in 0.28s var(--ease-spring);
}

.download-ready-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.tool-promos {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.tool-promo {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--duration-normal) var(--ease-default),
    box-shadow var(--duration-normal) var(--ease-default);
}

.tool-promo:not(.tool-promo--soon):hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.tool-promo--soon {
  opacity: 0.72;
}

.tool-promo__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.tool-promo__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  color: var(--cyan);
  flex-shrink: 0;
}

.tool-promo__icon .ui-icon {
  width: 26px;
  height: 26px;
  min-width: 26px;
}

.tool-promo__name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.tool-promo__tagline {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.tool-promo__badge {
  white-space: nowrap;
}

.tool-promo__desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0;
}

.tool-promo__note {
  font-size: 11px;
  color: var(--cyan);
  margin: 0;
}

.tool-promo__actions {
  display: flex;
  gap: var(--space-sm);
}

.tool-promo__cta {
  width: 100%;
  justify-content: center;
}

.tool-promo--primary .tool-promo__name {
  color: var(--text-main);
}

html[data-theme="light"] .tool-promo__note {
  color: #0284c7;
}

/* ── Desenhar / Azimutes ─────────────────────────────────────────────── */

.geo-draw-toolbar-wrap {
  position: absolute;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  top: var(--space-md);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: calc(100% - 24px);
}

.geo-draw-toolbar-wrap.hidden {
  display: none !important;
}

.geo-draw-toolbar {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  transform: none;
  z-index: auto;
  max-width: none;
}

.geo-draw-toolbar-wrap.has-area .geo-draw-toolbar {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  box-shadow: none;
}

.geo-draw-toolbar__count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  padding: 0 4px;
  white-space: nowrap;
}

.geo-draw-toolbar .btn-commit {
  background-color: var(--success, #10b981) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.geo-draw-toolbar .btn-commit:hover {
  filter: brightness(0.92);
}

.geo-draw-toolbar .btn-action-tool.is-active {
  background-color: color-mix(in srgb, var(--cyan) 20%, transparent);
  border-color: var(--cyan);
  color: var(--cyan);
}

.geo-draw-area-preview {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px 8px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--border-color);
  border-top: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  box-shadow: var(--shadow-glass);
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-main);
}

.geo-draw-area-preview[hidden] {
  display: none !important;
}

.geo-draw-area-preview__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.geo-draw-area-preview strong {
  font-weight: 700;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.geo-draw-edge-label {
  background: none !important;
  border: none !important;
}

.geo-draw-edge-label span {
  display: inline-block;
  transform: translate(-50%, -50%);
  padding: 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-card, #0f172a) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent);
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgba(2, 8, 20, 0.35);
}

.geo-draw-vertex {
  cursor: grab;
}

.geo-draw-vertex:active {
  cursor: grabbing;
}

@media (pointer: coarse), (max-width: 900px) {
  .geo-draw-vertex {
    /* SVG stroke/fill handled by Leaflet radius; keep grab feedback */
    cursor: grab;
  }
}

.geo-import-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
}

.geo-import-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 12px;
}

.geo-import-btn--active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

.header-search-group.is-draw-mode .header-search-input,
.header-search-group.is-draw-mode .btn-search-input-inside {
  opacity: 0.45;
  pointer-events: none;
}

.geo-azimuth-modal {
  width: 560px;
  max-width: min(92vw, 560px);
}

.geo-azimuth-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.geo-azimuth-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.geo-azimuth-section__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.geo-azimuth-preset {
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.geo-azimuth-preset:hover {
  color: var(--text-main);
}

.geo-azimuth-origin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.geo-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.geo-field__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.geo-field__input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-md, 8px);
  outline: none;
  transition: border-color 0.2s var(--ease-default), box-shadow 0.2s var(--ease-default);
}

.geo-field__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.geo-azimuth-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 168px;
  resize: vertical;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-md, 8px);
  outline: none;
  transition: border-color 0.2s var(--ease-default), box-shadow 0.2s var(--ease-default);
}

.geo-azimuth-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.geo-azimuth-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.geo-azimuth-error {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger, #ef4444);
}

.geo-azimuth-error.hidden {
  display: none !important;
}

.modal-overlay.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .geo-import-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .geo-azimuth-origin-grid {
    grid-template-columns: 1fr;
  }

  .geo-draw-toolbar-wrap {
    top: 8px;
    max-width: calc(100% - 16px);
  }

  .geo-draw-toolbar {
    padding: 4px 6px;
    gap: 4px;
    justify-content: center;
  }

  .geo-draw-toolbar__count,
  .geo-draw-toolbar__count + .toolbar-divider {
    display: none !important;
  }

  .geo-draw-toolbar .btn-action-tool {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .geo-draw-area-preview {
    padding: 6px 10px 7px;
    font-size: 11px;
  }

  .geo-draw-edge-label span {
    font-size: 9px;
    padding: 1px 4px;
  }
}
