@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap");

:root {
  --bs-white: #fff;
  --bs-gray-100: #f8f9fa;
  --bs-gray-200: #e9ecef;
  --bs-gray-500: #7a7a7a;
  --bs-gray-800: #3f3f3f;
  --bs-dark: hsl(0, 0%, 15%);
  --bs-black: rgb(12, 12, 12);
}

/* RESET */
* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
}

/* ======================================================
   LAYOUT GERAL
====================================================== */

section {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#stage {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

#pano-config-api,
.marzipano-canvas {
  background: rgb(61, 61, 61);
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  position: relative;
  /* Smooth transition for the loading desaturation effect. */
  transition: filter 350ms ease;
}

/* Applied while new textures are being fetched from the backend.
   Light desaturation (~50%) signals to the user that the view is updating.
   Removed automatically when LOD0 tiles begin loading. */
#pano-config-api.pano-loading {
  filter: saturate(50%);
}

/* Loading spinner centered on the viewer — shown during desaturation. */
.pano-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  transition: opacity 350ms ease;
  pointer-events: none;
}

.pano-spinner.visible {
  opacity: 1;
}

.pano-spinner-ring {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: spin 0.8s linear infinite;
}

.pano-spinner-text {
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.pano-spinner-text::after {
  content: '';
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dots 2.7s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ' '; }
  25%  { content: ' .'; }
  50%  { content: ' ..'; }
  75%  { content: ' ...'; }
  100% { content: ' '; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.client-logo {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  z-index: 50;
  pointer-events: none;
}

.client-logo img {
  max-width: 140px;
  height: auto;
  display: block;
}

/* ======================================================
   UI CONTAINER
====================================================== */

.ui-container {
  position: relative;
  width: clamp(220px, 20vw, 300px);
  height: 100%;
  padding: 1rem;
  background-color: var(--bs-white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ui-container * {
  pointer-events: auto;
}

/* ======================================================
   UPLOAD MONITOR
====================================================== */

.upload-monitor {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--bs-gray-200);
  border-radius: 0.375rem;
  background: var(--bs-gray-100);
}

.upload-monitor.active {
  display: block;
}

.upload-monitor-message {
  font-size: 0.75rem;
  color: var(--bs-gray-800);
}

.upload-monitor-progress {
  display: none;
  width: 100%;
  height: 0.4rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bs-gray-200);
}

.upload-monitor-bar {
  width: 0;
  height: 100%;
  background: var(--bs-dark);
  transition: width 0.2s ease;
}

/* ======================================================
   MENU PRINCIPAL
====================================================== */

#menu-elements {
  padding: 5px;
  overflow-y: auto;
}

.menu-item {
  --thumb-size: clamp(48px, 6vw, 80px);

  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 1vw, 0.75rem);
  padding: clamp(0.4rem, 1vw, 0.75rem);
  margin-bottom: 0.75rem;
  border: 1px solid var(--bs-gray-200);
  border-radius: 0.375rem;
  background-color: var(--bs-white);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.menu-item:hover {
  background-color: var(--bs-gray-100);
  border-color: var(--bs-gray-800);
}

.menu-item-thumbnail {
  width: var(--thumb-size);
  height: var(--thumb-size);
  object-fit: cover;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.menu-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.menu-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bs-dark);
}

.menu-item-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bs-gray-500);
}

.menu-item-arrow {
  font-size: 1.25rem;
  color: var(--bs-gray-500);
}

/* ======================================================
   SUBMENU
====================================================== */

.submenu-panel {
  position: absolute;
  inset: 0;
  background-color: var(--bs-white);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 10;
}

.submenu-panel.active {
  transform: translateX(0);
}

.submenu-main-preview {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.submenu-main-preview img {
  max-width: 80%;
  height: auto;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-gray-200);
}

.submenu-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
}

.submenu-back {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.submenu-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.submenu-body {
  padding: 1rem;
  height: calc(100% - 64px);
  overflow-y: auto;
}

/* ======================================================
   TILES
====================================================== */

.tile-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 0;
}

.tile {
  width: 35%;
  padding: 0.375rem;
  cursor: pointer;
  text-align: center;
}

.tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.tile img:hover {
  border-color: var(--bs-gray-800);
}

.tile.active img {
  border-color: var(--bs-dark);
}

.tile-label {
  font-size: 0.875rem;
  color: var(--bs-gray-800);
}

/* ======================================================
   BOTÕES
====================================================== */

.scene-selector {
  position: absolute;
  margin: 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bs-white);
  border-radius: 0.375rem;
  padding: 0;
  z-index: 1000;
  width: min(600px, 90vw);
  height: min(400px, 60vh);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.scene-selector-header {
  display: flex;
  justify-content: space-between;
  padding: 15px 20px;
  background: var(--bs-black);
}

.scene-selector-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
}

.scene-selector-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.scene-selector-close:hover {
  opacity: 1;
}

.scene-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 0fr));
  gap: 16px;
  justify-content: center;
  align-content: center;
  height: 100%;
  margin: 0 60px;
}

.scene-button {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80px;
  width: 80px;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 14px;
  font-family: Poppins, sans-serif;
  text-align: center;
}

.scene-button:last-child {
  margin-bottom: 0;
}

.scene-button:hover {
  background: var(--bs-gray-200);
}

.scene-button.active {
  color: var(--bs-white);
  background: var(--bs-black);
}

#save-2render {
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 0.375rem;
  background-color: var(--bs-black);
  color: var(--bs-white);
  display: block;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#save-2render:hover {
  background-color: var(--bs-dark);
}

.scene-toggle-btn {
  padding: 0.5rem;
  margin: 0.75rem 0.25rem;
  border: none;
  border-radius: 0.375rem;
  background-color: var(--bs-black);
  color: var(--bs-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  font-family: Poppins, sans-serif;
}

.scene-toggle-btn:hover {
  background-color: var(--bs-dark);
}

/* ======================================================
 * RENDER 2D MODAL
 * ====================================================== */

.render-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.render-modal-content {
  background: var(--bs-white);
  border-radius: 0.375rem;
  width: min(95vw, 1050px);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.render-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--bs-black);
  flex-shrink: 0;
}

.render-modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
}

.render-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.render-modal-close:hover {
  opacity: 1;
}

.render-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  overflow-y: auto;
}

/* Layout em grid para detalhes do render */
.render-modal-body-grid {
  display: grid;
  grid-template-columns: 2fr auto 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow-y: auto;
  width: 100%;
  align-items: start;
}

.render-image-col {
  min-width: 0;
}

.render-contact-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.render-contact-col h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bs-gray-800);
}

.render-preview-image {
  display: block;
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.375rem;
}

.render-preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  gap: 14px;
}

.render-preview-loading .pano-spinner-ring {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: rgba(0, 0, 0, 0.75);
}

.render-preview-loading .pano-spinner-text {
  color: rgba(0, 0, 0, 0.65);
}

.render-download-btn {
  padding: 12px 30px;
  background: var(--bs-black);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  transition: background 0.2s;
}

.render-download-btn:hover {
  background: var(--bs-dark);
}

.render-error {
  padding: 60px 40px;
  color: #dc3545;
  font-size: 1rem;
  text-align: center;
}

/* Especificações técnicas do render */

.specifications-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  justify-content: center;
  height: 100%;
}

.spec-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  text-align: center;
  flex: 0 0 auto;
  max-width: 90px;
}

.spec-icon {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-gray-200);
  flex-shrink: 0;
}

/* Formulário de contato */

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contact-form input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bs-gray-200);
  border-radius: 0.375rem;
  font-family: Poppins, sans-serif;
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
}

.contact-form input:focus {
  outline: none;
  border-color: var(--bs-black);
}

.contact-form button {
  padding: 0.6rem;
  border: none;
  border-radius: 0.375rem;
  background-color: var(--bs-black);
  color: var(--bs-white);
  font-family: Poppins, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.contact-form button:hover {
  background-color: var(--bs-dark);
}

/* Botões de compartilhamento */

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.share-buttons button {
  padding: 0.6rem;
  border: 1px solid var(--bs-gray-200);
  border-radius: 0.375rem;
  background: var(--bs-white);
  color: var(--bs-dark);
  font-family: Poppins, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.share-buttons button:hover {
  background: var(--bs-gray-100);
  border-color: var(--bs-black);
}

/* QR Code */

.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--bs-gray-200);
  border-radius: 0.375rem;
  background: var(--bs-white);
}

.qr-container img {
  max-width: 100%;
  height: auto;
}

.qr-container.hidden {
  display: none;
}

/* Fullscreen button */

.fullscreen-button {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.2);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.fullscreen-button:hover {
  background: rgba(0, 0, 0, 0.5);
}

/* ======================================================
   MOBILE 70 / 30 LAYOUT
====================================================== */

@media (max-width: 768px) {
  #stage {
    flex-direction: column;
  }

  #pano-config-api {
    flex: 0 0 70dvh;
    height: 70dvh;
  }

  .ui-container {
    flex: 0 0 30dvh;
    height: 30dvh;
    width: 100%;
    overflow-y: auto;
    border-top: 1px solid var(--bs-gray-200);
  }

  #menu-elements {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem;
    overflow-x: auto;
  }

  .menu-item {
    width: 90px;
    flex-direction: column;
    border: none;
    margin: 0;
    padding: 0.5rem;
  }

  .menu-item-subtitle,
  .menu-item-arrow {
    display: none;
  }

  .menu-item-title {
    font-size: 0.875rem;
    font-weight: 400;
  }

  .scene-selector {
    top: 40%;
  }

  .scene-button {
    font-size: 11px;
    width: 70px;
    height: 70px;
    gap: 12px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .scene-buttons {
    align-items: center;
    justify-items: center;
  }

  /* Modal: coluna única no mobile */
  .render-modal-content {
    width: 95vw;
  }

  .render-modal-body-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  .specifications-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .render-preview-loading {
    aspect-ratio: 4 / 3;
    min-height: 200px;
  }
}

/* Tablet: imagem topo full, specs row, contact abaixo */
@media (min-width: 769px) and (max-width: 991px) {
  .render-modal-content {
    width: 95vw;
  }

  .render-modal-body-grid {
    grid-template-columns: 1fr 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  .render-image-col {
    grid-column: 1 / -1;
  }

  .specifications-container {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ======================================================
   VR MODE
====================================================== */

/* VR button — stacked below the fullscreen button */
.vr-button {
  position: absolute;
  top: 56px;   /* fullscreen: top 12px + ~36px height + 8px gap */
  left: 12px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.2);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vr-button:hover {
  background: rgba(0, 0, 0, 0.5);
}

/* Full-screen WebGL canvas — overlaid on #pano-config-api, hidden until active */
.vr-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 19;
  pointer-events: none;
}

.vr-canvas.active {
  display: block;
  pointer-events: auto;
}

/* Hide sidebar UI while in VR */
.vr-hidden {
  display: none !important;
}
