/* ---------- COMPONENTS: MODALS, BANNERS, POPUPS, TOASTS ---------- */

/* Banner de Desenho Ativo */
#draw-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1300;
  background: rgba(20, 26, 31, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 12px;
  display: none;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-lg);
}

#draw-banner.show {
  display: flex;
}

#draw-banner .pts {
  color: var(--accent);
  font-weight: 700;
}

/* Painel de Configuração e Confirmação de Quadrante */
#confirm-panel {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1350;
  background: var(--panel);
  border: 1px solid var(--line-highlight);
  border-radius: var(--radius-md);
  padding: 18px;
  width: 360px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
}

#confirm-panel.show {
  display: block;
}

#confirm-panel h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

#poly-info-box {
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 11px;
  line-height: 1.5;
}

/* Popup de Marcação de Endereço em Célula */
.mark-popup {
  font-family: var(--mono);
  color: #1a1a1a;
  width: 220px;
  padding: 4px;
}

.mark-popup h4 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
}

.mark-popup input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-family: var(--mono);
  background: #ffffff;
  color: #000000;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.swatch:hover {
  transform: scale(1.15);
}

.swatch.sel {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.mp-actions {
  display: flex;
  gap: 6px;
}

.mp-actions button {
  flex: 1;
  padding: 7px 6px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid #ccc;
  background: #f2f2f2;
  cursor: pointer;
  font-family: var(--mono);
  font-weight: 600;
}

.mp-actions .apply {
  background: #141a1f;
  color: #ffffff;
  border-color: #141a1f;
}

.mp-actions .remove {
  color: var(--danger);
  border-color: var(--danger);
  background: #fff;
}

/* Toast Notifications */
.tactical-toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 26, 31, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-fade 0.3s ease-out;
}

@keyframes toast-fade {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Modal Tático de Coordenadas, GPS & QR Code */
.tactical-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.2s ease-out;
  padding: 16px;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tactical-modal-card {
  background: var(--panel);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg), 0 0 25px var(--accent-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-eyebrow {
  font-size: 9.5px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-title {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.step-tag {
  font-size: 11px;
  background: var(--accent);
  color: #000;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
}

.modal-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.coord-display-box {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.coord-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.coord-label {
  color: var(--text-dim);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.coord-val {
  color: var(--teal);
  font-weight: 700;
  font-size: 12.5px;
}

.coord-val-dms {
  color: var(--text);
  font-size: 11.5px;
}

.nav-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.nav-btn {
  padding: 9px 10px;
  font-size: 11.5px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.qrcode-section {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.qrcode-box {
  background: #ffffff;
  padding: 6px;
  border-radius: var(--radius-sm);
  flex: 0 0 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qrcode-info {
  flex: 1;
}

.qrcode-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.qrcode-desc {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.45;
}

.modal-footer {
  padding: 10px 18px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line-soft);
}

/* ================= MARCADORES TÁTICOS DE VIATURAS / EQUIPES ================= */
.tactical-unit-container {
  background: transparent !important;
  border: none !important;
}

.tactical-unit-marker {
  position: relative;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(30, 215, 96, 0.4);
  animation: unit-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes unit-ping {
  0% { transform: scale(0.9); opacity: 0.8; }
  75%, 100% { transform: scale(1.8); opacity: 0; }
}

.unit-body {
  position: relative;
  z-index: 2;
  width: 28px;
  height: 28px;
  background: #141a1f;
  border: 2px solid #1ed760;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(30, 215, 96, 0.6), 0 2px 6px rgba(0, 0, 0, 0.8);
  transition: transform var(--transition-fast);
}

.tactical-unit-marker:hover .unit-body {
  transform: scale(1.18);
  border-color: #ffffff;
}

.tactical-unit-selected .unit-body {
  transform: scale(1.25);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent), 0 0 8px rgba(255, 255, 255, 0.9);
}

.tactical-unit-selected .unit-tag {
  background: var(--accent);
  color: #000000;
  border-color: #ffffff;
  font-weight: 800;
}

.unit-icon {
  font-size: 14px;
  line-height: 1;
}

.unit-tag {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 18, 22, 0.92);
  border: 1px solid #1ed760;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
}

/* Badge de Distância na Linha de Vetor de Apoio */
.unit-distance-badge {
  background: rgba(20, 26, 31, 0.92) !important;
  border: 1px solid #1ed760 !important;
  color: #1ed760 !important;
  font-family: var(--mono) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  padding: 2px 6px !important;
  border-radius: 3px !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7) !important;
}

/* ================= MINI-PLAYER PIP DE VÍDEO NO OPERADOR ================= */
.operator-video-pip {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 220px;
  z-index: 1200;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85);
  border: 2px solid var(--accent);
  background: #000000;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  display: block;
}

.operator-video-pip.hidden {
  display: none !important;
}

.operator-video-pip iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #050709;
}

.op-pip-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1250;
  display: flex;
  gap: 4px;
}

.op-pip-btn {
  background: rgba(14, 18, 22, 0.85);
  border: 1px solid var(--line);
  color: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.op-pip-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* MODO TELA DIVIDIDA NO OPERADOR (MAPA 50% / VÍDEO 50%) */
#app.split-view #map-wrap {
  display: flex !important;
  flex-direction: row !important;
  position: relative !important;
  width: calc(100vw - var(--sidebar-w, 320px)) !important;
}

#app.split-view #map {
  flex: 1 1 50% !important;
  width: 50% !important;
  height: 100% !important;
  border-right: 2px solid var(--accent) !important;
}

#app.split-view .operator-video-pip {
  flex: 1 1 50% !important;
  width: 50% !important;
  height: 100% !important;
  position: relative !important;
  top: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  left: auto !important;
  border-radius: 0 !important;
  border: none !important;
  border-left: 2px solid var(--accent) !important;
  box-shadow: none !important;
  z-index: 500 !important;
  display: block !important;
}

#app.split-view .operator-video-pip .op-pip-actions {
  top: 14px;
  right: 14px;
}

@media (max-width: 900px) {
  #app.split-view #map-wrap {
    flex-direction: column !important;
    width: 100vw !important;
  }
  #app.split-view #map {
    flex: 1 1 50% !important;
    width: 100% !important;
    height: 50vh !important;
    border-right: none !important;
    border-bottom: 2px solid var(--accent) !important;
  }
  #app.split-view .operator-video-pip {
    flex: 1 1 50% !important;
    width: 100% !important;
    height: 50vh !important;
    border-left: none !important;
  }

  .operator-video-pip {
    width: 180px !important;
    height: 115px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 26px) !important;
    right: calc(env(safe-area-inset-right, 0px) + 14px) !important;
    z-index: 2500 !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.95), 0 0 16px rgba(255, 140, 70, 0.35) !important;
  }
}

@media (max-width: 540px) {
  .operator-video-pip {
    width: 160px !important;
    height: 100px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 32px) !important;
    right: calc(env(safe-area-inset-right, 0px) + 12px) !important;
    z-index: 2500 !important;
    border-width: 1.5px !important;
  }
}


