/* ==========================================================================
   CALCULADORA DE TERRENOS & ÁREA — ESTILOS MODERNOS & RESPONSIVOS
   ========================================================================== */

.tela-terreno-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 48px 20px;
  animation: fadeInTerreno 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: #1e293b;
}

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

/* ==========================================================================
   Cabeçalho
   ========================================================================== */
.terreno-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.terreno-heading-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.terreno-icon {
  font-size: 26px;
  line-height: 1;
}

.terreno-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.terreno-subtitle {
  font-size: 12.5px;
  color: #64748b;
  margin: 2px 0 0 0;
}

.terreno-actions-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-terreno-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
  }
}

.btn-terreno-voltar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid #1e3a8a;
  background: #1e3a8a;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    background: #1e40af;
  }
}

/* ==========================================================================
   Barra de Modelos Prontos (Presets)
   ========================================================================== */
.terreno-toolbar-presets {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 16px;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.preset-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-preset {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;

  &:hover {
    border-color: #94a3b8;
    color: #0f172a;
  }

  &.active {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    font-weight: 700;
  }
}

.terreno-select-sm {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  outline: none;
}

/* ==========================================================================
   Grid Principal do Workspace (Canvas vs Dados)
   ========================================================================== */
.terreno-workspace-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.35fr) minmax(340px, 1fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 960px) {
  .terreno-workspace-grid {
    grid-template-columns: 1fr;
  }
}

.terreno-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.terreno-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;

  &.between {
    justify-content: space-between;
  }
}

.box-icon {
  font-size: 16px;
}

.box-title {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}

.box-badge-count {
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 7px;
  border-radius: 12px;
}

.box-sub-info {
  font-size: 11px;
  color: #64748b;
}

/* ==========================================================================
   Canvas Interativo de Desenho
   ========================================================================== */
.canvas-box {
  padding: 12px 14px;
}

.canvas-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 10px;
}

.tool-buttons-group {
  display: flex;
  gap: 4px;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;

  &:hover {
    color: #0f172a;
    border-color: #94a3b8;
  }

  &.active {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    font-weight: 700;
  }
}

.canvas-toggles-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;

  input {
    cursor: pointer;
  }
}

.canvas-zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon-canvas {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    background: #f1f5f9;
  }

  &.btn-danger-clean {
    color: #b91c1c;

    &:hover {
      background: #fee2e2;
      border-color: #fca5a5;
    }
  }
}

.canvas-viewport-wrapper {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);

  canvas {
    display: block;
    width: 100%;
    cursor: default;
  }
}

.canvas-hint-overlay {
  position: absolute;
  top: 8px;
  left: 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
  color: #334155;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.canvas-scale-badge {
  position: absolute;
  bottom: 8px;
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.9);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: #475569;
  pointer-events: none;

  .scale-bar {
    display: block;
    height: 3px;
    background: #0284c7;
    border-radius: 2px;
    width: 60px;
  }
}

.canvas-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
  padding-top: 8px;
}

/* ==========================================================================
   Tabela de Lados & Medidas
   ========================================================================== */
.tabela-lados-wrapper {
  overflow-x: auto;
}

.tabela-terreno-lados {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;

  th {
    text-align: left;
    padding: 7px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
  }

  td {
    padding: 6px 10px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
  }

  tr:hover td {
    background: #f8fafc;
  }
}

.lado-nome-badge {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 11.5px;
  color: #0284c7;
}

.input-lado-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  .input-comprimento-lado {
    width: 82px;
    padding: 4px 6px;
    font-size: 12.5px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    text-align: right;
  }

  .unit-text {
    font-size: 11px;
    color: #64748b;
  }
}

.azimute-txt {
  font-size: 11px;
  color: #475569;
}

.angulo-lado-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  .input-angulo-lado {
    width: 72px;
    padding: 4px 6px;
    font-size: 12px;
    text-align: right;
    border: 1px solid #cbd5e1;
    border-radius: 5px;

    &:disabled {
      opacity: 0.72;
      cursor: not-allowed;
    }
  }
}

.btn-travar-angulo {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;

  &.locked {
    border-color: #0284c7;
    background: #e0f2fe;
  }
}

.aresta-livre-row {
  background: rgba(245, 158, 11, 0.08);
  box-shadow: inset 4px 0 0 #f59e0b;
}

.aresta-livre-badge {
  display: inline-flex;
  margin-top: 0.35rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.angulo-interno-txt {
  display: inline-flex;
  min-width: 4.5rem;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
}

.terreno-validation-status {
  margin-top: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.terreno-validation-status.is-valid {
  color: #047857;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.terreno-validation-status.is-invalid {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.lado-actions-wrap {
  display: flex;
  gap: 4px;
}

.btn-lado-acao {
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;

  &:hover:not(:disabled) {
    background: #f1f5f9;
    color: #0f172a;
  }

  &:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
}

/* ==========================================================================
   Coluna Direita: Resultados & Conversões
   ========================================================================== */
.hero-result-box {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: #cbd5e1;
}

.btn-copiar-resumo {
  background: transparent;
  border: 1px solid #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  color: #64748b;
  cursor: pointer;

  &:hover {
    background: #f1f5f9;
    color: #0f172a;
  }
}

.hero-metric-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .hero-metric-cards-grid {
    grid-template-columns: 1fr;
  }
}

.hero-metric-card {
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;

  &.primary {
    border-color: #0284c7;
    background: #f0f9ff;

    .metric-value {
      color: #0369a1;
    }

    .metric-tag {
      background: #e0f2fe;
      color: #0369a1;
    }
  }

  &.secondary {
    border-color: #059669;
    background: #f0fdf4;

    .metric-value {
      color: #047857;
    }

    .metric-tag {
      background: #dcfce7;
      color: #047857;
    }
  }
}

.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
}

.metric-tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.metric-unit {
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
}

.metric-sub {
  font-size: 11px;
  color: #64748b;
  margin: 0;
}

/* Painel de Unidades de Terrenos Mais Utilizadas */
.unidades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.unidade-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  transition: all 0.15s ease;

  &:hover {
    border-color: #94a3b8;
    background: #f8fafc;
  }
}

.unidade-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.unidade-nome {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unidade-sigla {
  font-size: 10px;
  color: #0284c7;
  font-weight: 700;
}

.unidade-valor-wrap {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-bottom: 2px;
}

.unidade-valor {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.unidade-simbolo-sm {
  font-size: 10.5px;
  color: #64748b;
}

.unidade-desc {
  font-size: 9.5px;
  color: #64748b;
  line-height: 1.25;
}

/* ==========================================================================
   Estimativas de Fechamento / Cerca e Valor
   ========================================================================== */
.estimativas-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.estimativa-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}

.estimativa-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
  color: #1e293b;
}

.est-icon {
  font-size: 14px;
}

.estimativa-inputs-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-with-prefix {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;

  .prefix {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    padding: 0 8px;
    background: #f1f5f9;
    border-right: 1px solid #cbd5e1;
    line-height: 28px;
  }

  input {
    border: none;
    outline: none;
    padding: 4px 8px;
    font-size: 12.5px;
    width: 90px;
  }
}

.est-result-inline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: #334155;

  strong {
    font-size: 15px;
    color: #15803d;
  }
}

.cerca-grid-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.cerca-field {
  display: flex;
  flex-direction: column;
  gap: 2px;

  label {
    font-size: 10.5px;
    font-weight: 600;
    color: #64748b;
  }
}

.cerca-resultado-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.cerca-res-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 11.5px;

  .cerca-res-lbl {
    color: #64748b;
  }

  .cerca-res-val {
    color: #0284c7;
    font-size: 12.5px;
  }
}

/* ==========================================================================
   Modal de Ajuste Rápido de Comprimento
   ========================================================================== */
.terreno-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.terreno-modal-box {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border: 1px solid #cbd5e1;
  overflow: hidden;
  animation: fadeInTerreno 0.15s ease;
}

.terreno-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.terreno-modal-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;

  &:hover {
    color: #0f172a;
  }
}

.terreno-modal-body {
  padding: 16px;
}

.modal-instruction {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
  margin: 0 0 14px 0;
}

.modal-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;

  label {
    font-size: 11px;
    font-weight: 700;
    color: #334155;
  }
}

.input-unit-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;

  input {
    flex: 1;
    border: none;
    outline: none;
    padding: 7px 10px;
    font-size: 15px;
  }

  .unit-tag {
    background: #f1f5f9;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    line-height: 34px;
    border-left: 1px solid #cbd5e1;
  }
}

.terreno-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.btn-terreno-confirm {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;

  &:hover {
    background: #0369a1;
  }
}

/* ==========================================================================
   Modo Escuro (Dark Mode)
   ========================================================================== */
body.dark-mode, [data-theme="dark"], .dark-theme {
  .tela-terreno-container {
    color: #e2e8f0;
  }

  .terreno-header, .terreno-box, .hero-result-box, .terreno-toolbar-presets {
    background: #0f172a;
    border-color: #1e293b;
    color: #f8fafc;
  }

  .terreno-title, .box-title {
    color: #f8fafc;
  }

  .terreno-subtitle, .box-sub-info, .preset-title {
    color: #94a3b8;
  }

  .btn-terreno-action, .terreno-select-sm, .btn-preset {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;

    &:hover {
      background: #334155;
      color: #f8fafc;
    }

    &.active {
      background: #0284c7;
      color: #ffffff;
      border-color: #0284c7;
    }
  }

  .btn-tool, .btn-icon-canvas {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;

    &:hover {
      background: #334155;
      color: #f8fafc;
    }

    &.active {
      background: #0284c7;
      color: #ffffff;
    }
  }

  .canvas-viewport-wrapper {
    background: #0b1120;
    border-color: #1e293b;
  }

  .canvas-hint-overlay, .canvas-scale-badge {
    background: rgba(15, 23, 42, 0.88);
    border-color: #334155;
    color: #cbd5e1;
  }

  .tabela-terreno-lados {
    th {
      background: #1e293b;
      border-color: #334155;
      color: #cbd5e1;
    }

    td {
      border-color: #1e293b;
      color: #e2e8f0;
    }

    tr:hover td {
      background: #1e293b;
    }
  }

  .input-lado-inline .input-comprimento-lado {
    background: #0b0f19;
    border-color: #334155;
    color: #f8fafc;
  }

  .angulo-lado-inline .input-angulo-lado, .btn-travar-angulo {
    background: #0b0f19;
    border-color: #334155;
    color: #f8fafc;
  }

  .btn-travar-angulo.locked {
    background: rgba(2, 132, 199, 0.2);
    border-color: #0284c7;
  }

  .btn-lado-acao {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
  }

  .hero-metric-card {
    background: #1e293b;
    border-color: #334155;

    &.primary {
      background: rgba(2, 132, 199, 0.15);
      border-color: #0284c7;

      .metric-value {
        color: #38bdf8;
      }
    }

    &.secondary {
      background: rgba(5, 150, 105, 0.15);
      border-color: #059669;

      .metric-value {
        color: #34d399;
      }
    }
  }

  .unidade-card, .estimativa-card {
    background: #1e293b;
    border-color: #334155;
  }

  .unidade-nome {
    color: #f8fafc;
  }

  .unidade-valor {
    color: #38bdf8;
  }

  .input-with-prefix {
    background: #0b0f19;
    border-color: #334155;

    .prefix {
      background: #1e293b;
      border-color: #334155;
      color: #cbd5e1;
    }

    input {
      background: #0b0f19;
      color: #f8fafc;
    }
  }

  .terreno-modal-box {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
  }

  .terreno-modal-header, .terreno-modal-footer {
    background: #1e293b;
    border-color: #334155;
  }

  .terreno-modal-title {
    color: #f8fafc;
  }

  .input-unit-wrap {
    background: #0b0f19;
    border-color: #334155;

    input {
      background: #0b0f19;
      color: #f8fafc;
    }

    .unit-tag {
      background: #1e293b;
      border-color: #334155;
      color: #cbd5e1;
    }
  }
}

