.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(42,31,23,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-mid) var(--ease-out),
              visibility var(--dur-mid);
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  max-width: 960px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(24px) scale(0.97);
  transition: transform var(--dur-mid) var(--ease-out);
  box-shadow: 0 30px 80px rgba(42,31,23,0.25);
}
.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1.2rem;
  font-size: 1.8rem;
  color: var(--color-text-muted);
  line-height: 1;
  z-index: 10;
  transition: color var(--dur-fast), transform var(--dur-fast);
}
.modal-close:hover { color: var(--color-brown); transform: rotate(90deg); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* ── WALL SCENE ── */
.modal-img-wrap {
  position: relative;
  min-height: 400px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  overflow: hidden;
  /* Parede realista com textura */
  background:
    /* textura sutil de parede */
    repeating-linear-gradient(
      90deg,
      transparent,
      rgba(0,0,0,0.008) 1px,
      transparent 2px,
      transparent 30px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      rgba(0,0,0,0.008) 1px,
      transparent 2px,
      transparent 30px
    ),
    /* cor da parede - bege claro tipo gesso */
    linear-gradient(
      180deg,
      #f2ebe0 0%,
      #ece4d6 30%,
      #e8dfd0 60%,
      #e5dccb 100%
    );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 70px; /* Space for the sideboard */
  transition: background var(--dur-mid) var(--ease-out);
}

/* Sombra ambiente na parede */
.modal-img-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 30%,
    transparent 35%,
    rgba(61,43,31,0.06) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Iluminação de cima (spot light) */
.modal-img-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 70%;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(255,248,235,0.45) 0%,
    rgba(255,248,235,0.18) 35%,
    transparent 75%
  );
  pointer-events: none;
  z-index: 1;
}

/* Móvel de escala (Aparador de Madeira Escura) */
.furniture-mockup {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: linear-gradient(180deg, #3d2b1f 0%, #221710 100%);
  border-top: 3px solid #523b2b;
  z-index: 3;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.15);
  transition: opacity 0.3s;
}
.furniture-mockup::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 6px;
  height: 100%;
  background: #180f0a;
  box-shadow: 78vw 0 0 #180f0a;
}
.furniture-decor {
  position: absolute;
  bottom: 60px;
  left: 12%;
  font-size: 1.6rem;
  z-index: 3;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
  transition: opacity 0.3s;
}
.furniture-decor::before {
  content: '🌿'; /* Vase/Plant scale reference */
}

/* Quadro na parede sem moldura CSS (a moldura real já vem na foto) */
.modal-img-wrap img {
  position: relative;
  z-index: 2;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  box-shadow:
    /* sombra realista projetada na parede */
    4px 12px 28px rgba(0,0,0,0.3),
    1px 2px 6px rgba(0,0,0,0.2);
  transition: all 0.3s var(--ease-out);
}

/* Enforce sizes based on orientation */
.modal-img-wrap.orientation-vertical img {
  max-width: 180px;
  max-height: 250px;
  width: auto;
  height: auto;
}
.modal-img-wrap.orientation-horizontal img {
  max-width: 250px;
  max-height: 180px;
  width: auto;
  height: auto;
}
.modal-img-wrap.orientation-quadrada img {
  max-width: 210px;
  max-height: 210px;
  width: auto;
  height: auto;
}

/* Toggle View Button */
.toggle-view-btn {
  position: absolute;
  bottom: 4.5rem;
  right: 1rem;
  z-index: 10;
  background: rgba(250, 246, 240, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  padding: 0.45rem 0.9rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-brown);
  box-shadow: 0 4px 12px rgba(61,43,31,0.12);
  transition: all 0.25s var(--ease-out);
}
.toggle-view-btn:hover {
  background: var(--color-white);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(61,43,31,0.18);
}
.toggle-view-btn svg {
  color: var(--color-orange);
}

/* ZOOM / CLEAN VIEW MODE */
.modal-img-wrap.zoom-mode {
  background: #fdfcf9;
  padding-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-img-wrap.zoom-mode::before,
.modal-img-wrap.zoom-mode::after,
.modal-img-wrap.zoom-mode .furniture-mockup,
.modal-img-wrap.zoom-mode .furniture-decor {
  opacity: 0;
  pointer-events: none;
}
.modal-img-wrap.zoom-mode .modal-img-container {
  width: 85% !important;
  height: 85% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  cursor: zoom-out;
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
}
.modal-img-wrap.zoom-mode img {
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  border: none !important;
  box-shadow: 0 10px 40px rgba(61,43,31,0.12) !important;
  width: auto !important;
}
.modal-img-wrap.zoom-mode .toggle-view-btn {
  bottom: 1rem;
}

.modal-badge {
  position: absolute;
  top: 1rem; left: 1rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  font-weight: 500;
  z-index: 5;
}
.modal-badge.disponivel {
  background: rgba(37,211,102,0.18);
  color: #0a7a35;
}
.modal-badge.vendido {
  background: rgba(61,43,31,0.15);
  color: var(--color-brown);
}

.modal-info {
  padding: 2.5rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal-category {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-orange);
  margin-bottom: 0.4rem;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--color-brown);
  margin-bottom: 0.4rem;
}

.modal-price {
  font-family: var(--font-body);
  font-size: 1.8rem;
  color: var(--color-orange-dark);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.modal-details li {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
  color: var(--color-text-muted);
}
.modal-details li strong { color: var(--color-text); font-weight: 500; }

#modalWhatsapp {
  width: 100%;
  justify-content: center;
  margin-bottom: 1.8rem;
}

.modal-desc-wrap {
  margin-bottom: 1rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.2rem;
}
.modal-desc-title {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}
.modal-desc {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--color-text);
}

@media (max-width: 680px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-img-wrap {
    min-height: 300px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-img-wrap img {
    width: auto;
    height: auto;
    max-width: 70%;
    max-height: 70%;
    /* Removido aspect-ratio para respeitar as proporções reais da obra */
  }
  .modal-info { padding: 1.5rem; }
}
