/* ============================
   RESET & STRUTTURA FULLSCREEN
   ============================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: -webkit-fill-available; /* Fix per Safari su iOS */
  overflow: hidden;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  background-color: #050505;
  color: #fff;
}

main {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Viewport dinamica per mobile */
}

#tour-viewer {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* ============================
   HEADER FLUTTUANTE
   ============================ */
header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

header * {
  pointer-events: auto;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo {
  height: 80px;
  width: auto;
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
}

.brand-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.2;
  color: #ffffff;
  text-transform: uppercase;
}

/* ============================
   BOX TITOLO CENTRALE
   ============================ */
.title-box-container {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #d4af37;
  padding: 4px;
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 10px rgba(212, 175, 55, 0.3);
}

.title-box-inner {
  background: #111111;
  border: 1px solid #d4af37;
  padding: 8px 25px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.title-text-main {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  background-image: linear-gradient(90deg, #d4af37, #f7e9b5, #d4af37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  z-index: 3;
  white-space: nowrap;
}

.title-text-sub {
  font-size: 18px;
}

.title-text-glow {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: transparent;
  position: absolute;
  width: 100%;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes glowLuxuryAligned {
  0%, 100% { text-shadow: 0 0 0px rgba(212,175,55,0); }
  50% { text-shadow: 0 0 15px rgba(212,175,55,0.8); }
}

.oro-glow {
  animation: glowLuxuryAligned 3s ease-in-out infinite;
}

.header-spacer {
  width: 180px;
}

/* ============================
   PULSANTIERA LATERALE FLUTTUANTE (<aside>)
   ============================ */
aside {
  position: absolute;
  right: 25px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 12px;
  background: rgba(10, 10, 10, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 65px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
  z-index: 100;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.icon-btn {
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #d4af37;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  outline: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.3s ease;
}

.icon-btn:hover {
  transform: scale(1.1);
  background: rgba(15, 15, 15, 0.9);
  border-color: #ffffff;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.9);
}

.star-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.8));
  transition: transform 0.3s ease;
  user-select: none;
}

#reviewBtn:hover .star-icon {
  transform: scale(1.2) rotate(15deg);
}

/* ============================
   PULSANTE PRENOTA ORA
   ============================ */
.booking-corner {
  position: absolute;
  bottom: 25px;
  left: 25px;
  z-index: 100;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.booking-btn-text {
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid #d4af37;
  border-radius: 30px;
  padding: 12px 28px;
  color: #d4af37;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.6), 0 0 10px rgba(212, 175, 55, 0.3);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.booking-btn-text:hover {
  transform: scale(1.08);
  background: rgba(20, 20, 20, 0.9);
  border-color: #ffffff;
  color: #ffffff;
  box-shadow: 0 0 25px rgba(212, 175, 55, 0.9);
}

/* ============================
   FOOTER FLUTTUANTE
   ============================ */
footer {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  padding: 6px 20px;
  border-radius: 20px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  z-index: 100;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

#mini-screen {
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.footer-link {
  color: #d4af37;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.footer-link:hover {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
  text-decoration: underline;
}

/* ============================
   FINESTRA POP-UP & LIGHTBOX
   ============================ */
#htmlWindow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  z-index: 999999;
}

#htmlContent {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80vw;
  max-width: 1000px;
  height: 75vh;
  transform: translate(-50%, -50%);
  background: #121212;
  border: 2px solid #d4af37;
  border-radius: 12px;
  padding: 30px;
  box-sizing: border-box;
  overflow-y: auto;
  color: #fff;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.25);
}

#modalBody {
  width: 100%;
  height: 100%;
}

#htmlClose {
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 35px;
  color: #d4af37;
  cursor: pointer;
  z-index: 1000000;
  transition: transform 0.2s;
}

#htmlClose:hover {
  transform: scale(1.2);
}

#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000000;
}

#lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: 2px solid #d4af37;
  border-radius: 8px;
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 45px;
  color: #d4af37;
  cursor: pointer;
}

/* ============================
   RESPONSIVE MOBILE ADATTATIVO
   ============================ */
@media screen and (max-width: 768px) {
  /* 1. Header Flessibile */
  header {
    padding: 8px 12px;
    height: auto;
    min-height: 56px;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    gap: 8px;
  }

  .logo-container {
    gap: 8px;
    flex-shrink: 1;
    min-width: 0;
  }

  .logo {
    height: 36px;
  }

  .brand-text {
    font-size: 10px;
    letter-spacing: 1px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .header-spacer {
    display: none;
  }

  /* 2. Titolo Ridimensionabile senza sovrapposizioni */
  .title-box-container {
    padding: 2px;
    max-width: 55vw;
    flex-shrink: 1;
  }

  .title-box-inner {
    padding: 4px 8px;
  }

  .title-text-main, 
  .title-text-glow {
    font-size: clamp(10px, 3.2vw, 13px);
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .title-text-sub {
    font-size: clamp(9px, 2.8vw, 11px);
  }

  /* 3. Pulsante Prenota Ora con gestione Safe Area */
  .booking-corner {
    bottom: calc(75px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    text-align: center;
    white-space: nowrap;
  }

  .booking-btn-text {
    padding: 8px 18px;
    font-size: 10px;
    letter-spacing: 1px;
    border-radius: 20px;
  }

  /* 4. Pulsantiera comandi in basso ottimizzata */
  aside {
    right: 50%;
    top: auto;
    bottom: calc(15px + env(safe-area-inset-bottom));
    transform: translateX(50%);
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 40px;
    width: auto;
    max-width: 92vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  aside::-webkit-scrollbar {
    display: none;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
  }

  .icon-btn img {
    width: 24px;
    height: 24px;
  }

  .star-icon {
    font-size: 18px;
  }

  /* 5. Footer ultra-compatto */
  footer {
    bottom: calc(2px + env(safe-area-inset-bottom));
    padding: 0;
    background: transparent;
    border: none;
    pointer-events: none;
  }

  #mini-screen {
    font-size: 8px;
    opacity: 0.6;
    pointer-events: auto;
  }

  #htmlContent {
    width: 92vw;
    height: 80dvh;
    padding: 15px;
    border-radius: 8px;
  }
}

/* ============================
   SCROLLBAR LUXURY GLOBALE
   ============================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #111111;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #d4af37 0%, #8a6d1c 100%);
  border-radius: 4px;
  border: 1px solid #111111;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #f7e9b5 0%, #d4af37 100%);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #d4af37 #111111;
}

/* ============================
   SUPPORTO FULLSCREEN INTERFACCIA
   ============================ */
:fullscreen main,
:-webkit-full-screen main {
  width: 100vw;
  height: 100vh;
}

:fullscreen aside,
:fullscreen header,
:fullscreen footer,
:fullscreen .booking-corner {
  z-index: 999999;
}