/* ==========================================================================
   ARQUIVO: modal.css
   OBJETIVO: Estilo da Janela Modal com Ficha Completa do Imóvel
   CARACTERÍSTICAS:
   - Fundo escurecido suave (backdrop)
   - Galeria de fotos deslizante interna com indicador de contagem
   - Ficha técnica completa (preço, condomínio, IPTU, características)
   - Botão de WhatsApp em destaque fixado para alta conversão
   ========================================================================== */

/* Fundo Escurecido que cobre toda a tela */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Garante altura exata desconsiderando barras dinâmicas do navegador no celular */
  background-color: rgba(11, 28, 48, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-end; /* No celular sobe como bottom sheet */
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center; /* No tablet/desktop fica centralizado */
    padding: 20px;
  }
}

/* Quando o modal está ativo/aberto */
.modal-overlay.ativo {
  opacity: 1;
  visibility: visible;
}

/* Caixa de Conteúdo do Modal */
.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  max-height: 86dvh; /* Altura segura para garantir que o rodapé e botão fiquem 100% visíveis acima da barra do navegador */
  background: var(--cor-card, #ffffff);
  border-radius: 28px 28px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(40px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 600px) {
  .modal-card {
    border-radius: var(--arredondamento, 24px);
    transform: scale(0.95);
  }
}

.modal-overlay.ativo .modal-card {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .modal-overlay.ativo .modal-card {
    transform: scale(1);
  }
}

/* Cabeçalho do Modal com Botão Fechar */
.modal-header-bar {
  position: relative;
  width: 100%;
}

.btn-modal-compartilhar,
.btn-modal-fechar {
  position: absolute;
  top: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(11, 28, 48, 0.7);
  backdrop-filter: blur(4px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
}

.btn-modal-fechar {
  right: 12px;
}

.btn-modal-compartilhar {
  right: 54px; /* Fica logo ao lado do botão fechar */
}

.btn-modal-compartilhar:hover,
.btn-modal-fechar:hover {
  background-color: rgba(11, 28, 48, 0.95);
  transform: scale(1.08);
}

.btn-modal-compartilhar .icone-svg,
.btn-modal-fechar .icone-svg,
.btn-modal-fechar img {
  width: 17px;
  height: 17px;
  color: #ffffff;
  fill: currentColor;
}

/* Toast de Aviso ("Link copiado com sucesso!") */
.modal-toast-notificacao {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background-color: #0b1c30;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 100000;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-toast-notificacao.ativo {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Galeria de Fotos dentro do Modal */
.modal-gallery-wrap {
  position: relative;
  width: calc(100% + 40px); /* Ocupa a largura inteira estendendo sobre o padding do modal */
  margin: -20px -20px 0 -20px; /* Alinha com o topo do modal */
  aspect-ratio: 16 / 10;
  background-color: #050b14; /* Fundo preto elegante para enquadrar fotos verticais ou horizontais */
  overflow: hidden;
  flex-shrink: 0;
  cursor: zoom-in; /* Indica que ao clicar abre a foto ampliada */
}

.modal-gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.modal-gallery-track::-webkit-scrollbar {
  display: none;
}
.modal-gallery-track {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.modal-photo-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #050b14;
}

/* Imagem com object-fit contain: NUNCA CORTA A FOTO, mantendo faixas pretas nas laterais se for vertical */
.modal-photo-slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Setas de navegação da galeria */
.modal-gallery-prev,
.modal-gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: background-color 0.2s ease, transform 0.15s ease;
  color: #0b1c30;
}

.modal-gallery-prev { left: 12px; }
.modal-gallery-next { right: 12px; }

.modal-gallery-prev:hover,
.modal-gallery-next:hover {
  background-color: #ffffff;
  transform: translateY(-50%) scale(1.05);
}

.modal-gallery-prev .icone-svg,
.modal-gallery-next .icone-svg,
.modal-gallery-prev img,
.modal-gallery-next img {
  width: 18px;
  height: 18px;
  color: #0b1c30;
}

/* Contador de Fotos (Ex: "1 / 9") */
.modal-photo-counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  z-index: 5;
}

/* Botão de Dica de Tela Cheia no Canto da Galeria */
.btn-modal-fullscreen-hint {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-modal-fullscreen-hint:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.08);
}

.btn-modal-fullscreen-hint .icone-svg {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

/* Corpo Rolável do Modal (Tudo rola junto agora!) */
.modal-body-scroll {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* Todos os ícones SVG dentro do Modal têm tamanho estrito */
.modal-overlay svg.icone-svg {
  display: inline-block;
  flex-shrink: 0;
}

.modal-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cor-primaria, #006c4a);
}

.modal-location .icone-svg,
.modal-location img {
  width: 16px;
  height: 16px;
  min-width: 16px;
  color: var(--cor-icone-localizacao-card, var(--cor-primaria, #006c4a));
}

.modal-code-badge {
  font-size: 11px;
  font-weight: 700;
  color: #45464d;
  background-color: #f1f5fd;
  border: 1px solid #e2e8f5;
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--cor-texto-principal, #0b1c30);
  line-height: 1.3;
}

/* Bloco de Preços e Taxas */
.modal-pricing-box {
  display: flex;
  flex-direction: column;
  background-color: #f1f5fd;
  border-radius: 16px;
  padding: 14px 16px;
  gap: 4px;
}

.modal-main-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--cor-texto-principal, #0b1c30);
}

.modal-extra-rates {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--cor-texto-secundario, #45464d);
  font-weight: 500;
}

/* Grade de Especificações no Modal */
.modal-specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.modal-spec-card {
  background: #f8f9ff;
  border: 1px solid #e2e8f5;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.modal-spec-card .icone-svg,
.modal-spec-card img {
  width: 20px;
  height: 20px;
  color: var(--cor-icone-specs-card, #0b1c30);
}

.modal-spec-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--cor-texto-principal, #0b1c30);
}

.modal-spec-lbl {
  font-size: 11px;
  color: var(--cor-texto-secundario, #45464d);
}

/* Descrição Completa */
.modal-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--cor-texto-principal, #0b1c30);
  margin-bottom: 6px;
}

.modal-description-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--cor-texto-secundario, #45464d);
}

/* Tags de Características / Diferenciais */
.modal-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  background-color: #eaf8f1;
  color: var(--cor-primaria, #006c4a);
  font-size: 12px;
  font-weight: 600;
}

.modal-tag .icone-svg,
.modal-tag img {
  width: 14px;
  height: 14px;
  color: var(--cor-primaria, #006c4a);
}

/* Rodapé Fixo do Modal com Botão do WhatsApp */
.modal-footer-bar {
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); /* Proteção contra barra inferior do iPhone / Android */
  background: #ffffff;
  border-top: 1px solid #edf2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0; /* Garante que o rodapé nunca encolha ou suma */
}

.btn-modal-whatsapp {
  width: 100%;
  padding: 14px;
  background-color: var(--cor-primaria, #006c4a);
  color: #ffffff;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0, 108, 74, 0.35);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-modal-whatsapp:hover {
  background-color: var(--cor-primaria-hover, #005137);
  transform: translateY(-2px);
}

.btn-modal-whatsapp img {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   VISUALIZADOR EM TELA CHEIA (FULLSCREEN VIEWER)
   ========================================================================== */
.modal-fullscreen-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Respeita a altura real descontando a barra do navegador do celular */
  background-color: #000000;
  z-index: 99999; /* Fica acima de tudo */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-fullscreen-viewer.ativo {
  opacity: 1;
  visibility: visible;
}

.btn-fullscreen-close {
  position: absolute;
  top: 20px;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.btn-fullscreen-close .icone-svg {
  width: 24px;
  height: 24px;
  color: #ffffff;
}

.fullscreen-gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.fullscreen-gallery-track::-webkit-scrollbar {
  display: none;
}
.fullscreen-gallery-track {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.fullscreen-photo-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  padding: 20px 16px 125px 16px; /* Espaço generoso na base para a foto não colidir com as setas e contador */
}

.fullscreen-photo-slide img {
  max-width: 100%;
  max-height: 75vh;
  max-height: 75dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
}

/* Setas de navegação na parte inferior com folga confortável da barra do celular */
.fullscreen-nav-prev,
.fullscreen-nav-next {
  position: absolute;
  bottom: 60px;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.fullscreen-nav-prev { 
  left: 20px; 
}

.fullscreen-nav-next { 
  right: 20px; 
}

.fullscreen-nav-prev:hover,
.fullscreen-nav-next:hover {
  background: rgba(255, 255, 255, 0.45);
  transform: scale(1.08);
}

.fullscreen-nav-prev .icone-svg,
.fullscreen-nav-next .icone-svg {
  width: 22px;
  height: 22px;
  color: #ffffff;
}

/* Contador central de fotos */
.fullscreen-photo-counter {
  position: absolute;
  bottom: 65px;
  bottom: calc(65px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 9999px;
  z-index: 10;
}
