/* Fix per navbar mobile - SOLO IL PULSANTE CENTRATO */
@media (max-width: 991px) {
  .navbar .container {
    flex-wrap: wrap;
  }
  
  .navbar-brand {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 1rem;
  }
  
  /* LOGO PIÙ PICCOLO SU MOBILE E TABLET */
  .navbar-brand img {
    height: 36px !important;
    width: auto !important;
  }
  
  .navbar-nav {
    flex: 1;
    justify-content: center;
  }
  
  .navbar .btn-outline-light {
    margin: 0 auto;
    display: block;
    width: fit-content;
  }
}

/* RISOLVE IL LOGO SCOMPARSO SU DESKTOP */
@media (min-width: 992px) {
  .navbar-brand {
    flex: 0 0 auto;
    max-width: none;
  }
}

/* NAVBAR DESKTOP - MENU CENTRATO CON DISTANZE ORIGINALI */
@media (min-width: 992px) {
  .navbar .container {
    max-width: 1140px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0;
  }
  
  /* Logo a sinistra */
  .navbar-brand {
    justify-self: start;
    grid-column: 1;
  }
  
  .navbar-brand img {
    height: 28px !important;
    width: auto !important;
    max-width: none !important;
  }
  
  /* Menu al centro */
  .navbar-nav {
    justify-self: center;
    grid-column: 2;
    margin: 0 !important;
  }
  
  /* Pulsante a destra */
  .navbar .btn-outline-light {
    justify-self: end;
    grid-column: 3;
  }
}

/* Prevent horizontal overflow - RISOLVE IL "SPACCARSI" */
body {
  overflow-x: hidden;
}

.container-fluid,
.container {
  overflow-x: hidden;
}

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

/* Fix testi troppo grandi su mobile */
@media (max-width: 767px) {
  .display-huge {
    font-size: 3rem !important;
  }
  
  .display-4 {
    font-size: 2rem !important;
  }
}

/* LOGHI AZIENDALI - DIMENSIONE FISSA */
img[src*="logo-forte48"],
img[src*="logo-orso"],
img[src*="STS-Hotel-logo"],
img[src*="logo-GHELFI_digital"] {
  max-width: 96px !important;
  width: 96px !important;
  height: auto !important;
}

/* LOGHI CLIENTI CIRCOLARI */
.rounded-circle {
  border-radius: 50% !important;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  width: 96px !important;
  height: 96px !important;
}

/* FIX IMMAGINI CARD VANTAGGI - SEMPRE FULL WIDTH */
.card .img-fluid.no-bottom-radius {
  width: 100% !important;
  height: auto !important;
  object-fit: cover;
  display: block;
}

/* SEZIONE "I NUMERI" - LAYOUT MOBILE */
@media (max-width: 991px) {
  /* Forza il wrapping delle colonne */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .col-6,
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .col-5 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Rimuovi offset su mobile */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .offset-1 {
    margin-left: 0 !important;
  }
  
  /* Spaziatura tra le sezioni */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > div:first-child {
    margin-bottom: 2rem;
  }
}

/* 5. SEZIONE "I NUMERI" - LAYOUT MOBILE */
@media (max-width: 991px) {
  /* Forza il wrapping delle colonne */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .col-6,
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .col-5 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Rimuovi offset su mobile */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > .offset-1 {
    margin-left: 0 !important;
  }
  
  /* Spaziatura tra le sezioni */
  .container.bg-black.px-vw-5.py-vh-3.rounded-5.shadow > .row > div:first-child {
    margin-bottom: 2rem;
  }
}

/* 2. FIX IMMAGINE DI SFONDO "I NUMERI" - CORNICE SU TUTTI I LATI ANCHE MOBILE */
.position-relative.py-vh-5.bg-cover.bg-center.rounded-5 {
  background-size: cover !important;
  background-position: center !important;
}

@media (max-width: 991px) {
  /* Assicura che su mobile l'immagine copra anche i lati */
  .position-relative.py-vh-5.bg-cover.bg-center.rounded-5 {
    background-size: cover !important;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Mantiene la cornice anche sui lati */
  .container-fluid.px-vw-5.py-vh-5.position-relative {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}


/* FIX IMMAGINI PARTNERSHIP E APPLE WATCH - COME NELLO SCREENSHOT */
@media (max-width: 991px) {
  /* Container delle immagini */
  .bg-dark.position-relative .row.d-flex.align-items-center > div[class*="col-12 col-lg-7"],
  .bg-dark.position-relative .row.d-flex.align-items-center > div[class*="col-12 col-lg-6"] {
    padding-left: 1rem;
    padding-right: 1rem;
    overflow: visible;
    margin-bottom: 2rem;
  }
  
  /* Prima immagine (sinistra) - 65% larghezza */
  .bg-dark.position-relative .row.d-flex.align-items-center img.rounded-5:first-child {
    max-width: 65% !important;
    width: 65% !important;
    height: auto;
    margin-left: 0 !important;
    margin-bottom: -3rem !important;
    position: relative;
    z-index: 1;
  }
  
  /* Seconda immagine (destra sfalsata) - 65% larghezza */
  .bg-dark.position-relative img.ms-5 {
    max-width: 65% !important;
    width: 65% !important;
    margin-left: 35% !important;
    margin-bottom: 0 !important;
    position: relative;
    z-index: 2;
  }
  
  /* Rimuove il margin-bottom negativo sulla seconda */
  .bg-dark.position-relative img.mb-n5.ms-5 {
    margin-bottom: 0 !important;
  }
}

/* FIX SBALZO IMMAGINI SEZIONE IMAGES */
.w-100.position-relative.bg-black.text-white.bg-cover.d-flex.align-items-center {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.w-100.position-relative.bg-black.text-white.bg-cover.d-flex.align-items-center .position-relative {
  will-change: transform;
}

/* Stabilizza le immagini durante lo scroll */
.w-100.position-relative.bg-black.text-white.bg-cover.d-flex.align-items-center img {
  will-change: auto;
  transform: translateZ(0);
}

/* Chatbot sempre sopra l'header anche su mobile */
.chat-container {
  z-index: 9999 !important;
}

/* Header fisso sotto la chat quando è aperta */
.navbar.fixed-top {
  z-index: 999 !important; /* più basso della chat */
}

/* Safari iOS: base anti-scroll orizzontale */
@supports (-webkit-touch-callout: none) {
  html, body {
    overflow-x: hidden;
    width: 100vw;
  }
}

/* Disabilita SOLO il rilevamento automatico dei numeri su Safari iOS */
@supports (-webkit-touch-callout: none) {
  /* Previene la selezione automatica di numeri come telefoni */
  body {
    -webkit-text-size-adjust: 100%;
  }
  
  /* Target specifico solo per testi con numeri grandi */
  .display-huge,
  .display-4,
  .display-1,
  .display-2,
  .display-3 {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* MANTIENI INTERATTIVI tutti gli elementi cliccabili */
  button,
  a,
  input,
  textarea,
  select,
  [onclick],
  [role="button"],
  .btn,
  /* Chatbot - tutti gli elementi */
  .chatbot-button,
  .chat-container,
  .chat-container *,
  .close-button,
  .send-button,
  .chat-input,
  /* CookieScript */
  #cookiescript_injected,
  #cookiescript_injected *,
  [id*="cookiescript"],
  [class*="cookiescript"],
  /* Eventuali altri banner cookie */
  [id*="cookie"],
  [class*="cookie"],
  [id*="consent"],
  [class*="consent"] {
    -webkit-touch-callout: default !important;
    -webkit-user-select: auto !important;
    user-select: auto !important;
    pointer-events: auto !important;
  }
}

/* Safari mobile: limita altezza chat, NON tocco top/left */
@media (max-width: 991px) and (-webkit-touch-callout: none) {
  .chat-container {
    max-height: 75vh !important;
    height: auto !important;
  }
  
  /* Assicura che il pulsante chatbot sia sempre cliccabile */
  .chatbot-button {
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
  }
}

/* FIX DIMENSIONI CHAT SU MOBILE - specialmente Safari */
@media (max-width: 991px) {
  .chat-container {
    width: calc(100vw - 40px) !important;
    max-width: 380px !important;
    height: calc(100vh - 100px) !important;
    max-height: 600px !important;
    bottom: 20px !important;
    right: 20px !important;
    left: 20px !important;
    margin: 0 auto !important;
  }
  
  /* Assicura che l'header sia visibile */
  .chat-header {
    min-height: 60px;
    flex-shrink: 0;
  }
  
  /* Area messaggi più piccola */
  .chat-messages {
    max-height: calc(100vh - 250px) !important;
    overflow-y: auto !important;
  }
}

/* Safari iOS: dimensioni ancora più conservative */
@media (max-width: 991px) and (-webkit-touch-callout: none) {
  .chat-container {
    max-height: 70vh !important;
    height: auto !important;
    min-height: 400px !important;
  }
  
  .chat-messages {
    max-height: calc(70vh - 180px) !important;
  }
}

/* Schermi molto piccoli */
@media (max-width: 480px) {
  .chat-container {
    width: calc(100vw - 30px) !important;
    height: calc(100vh - 80px) !important;
    max-height: 550px !important;
    bottom: 15px !important;
    right: 15px !important;
    left: 15px !important;
  }
  
  .chat-messages {
    max-height: calc(100vh - 220px) !important;
  }
}
