/* Import Bootstrap Icons */
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css");

/*
 * Base structure
 */

html,
body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* Margin bottom by footer height */
  margin-bottom: 60px;
  /* Pad top for fixed navbar */
  padding-top: 70px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#map-container {
  height: 500px;
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Leaflet popup styling for proper text visibility */
.leaflet-popup-content-wrapper {
  background-color: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
}

.leaflet-popup-content-custom {
  min-width: 200px;
}

.leaflet-popup-content-custom h6 {
  color: #212529 !important;
}

.leaflet-popup-content-custom .text-muted {
  color: #495057 !important;
}

.leaflet-popup-content-custom .btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: #0d6efd;
  --bs-btn-border-color: #0d6efd;
  background-color: var(--bs-btn-bg);
  border-color: var(--bs-btn-border-color);
  color: var(--bs-btn-color);
}

.leaflet-popup-tip {
  background-color: var(--bs-body-bg, #fff);
}

.main-flex-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

.filters-flex {
  display: flex;
  flex-direction: column;
}

.map-flex {
  display: flex;
  flex-direction: column;
}

/* Page layout: filtri a destra su desktop */
.page-layout-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.main-content-column {
  flex: 1;
  min-width: 0;
}

.filters-sidebar-column {
  display: none;
}

/* Filtri mobile visibili solo su schermi < 992px */
.filters-mobile-container {
  display: block;
}

/* Su schermi larghi: layout a due colonne */
@media (min-width: 992px) {
  .filters-mobile-container {
    display: none;
  }

  .page-layout-container {
    flex-direction: row;
    gap: 1.5rem;
  }

  .filters-sidebar-column {
    display: block;
    flex: 0 0 260px;
    order: 1;
  }

  .main-content-column {
    order: 0;
  }

  .filters-card {
    position: sticky;
    top: 80px;
  }
}

/* Accordion mappa/calendario sticky su desktop */
@media (min-width: 992px) {
  .sticky-accordion-wrapper {
    position: sticky;
    top: 70px;
    z-index: 1000;
    overflow: visible;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }

  /* Pseudo-elemento per coprire lo spazio tra navbar e accordion */
  .sticky-accordion-wrapper::before {
    content: '';
    position: absolute;
    top: -70px;
    left: -1rem;
    right: -1rem;
    height: 70px;
    background-color: var(--bs-body-bg, #212529);
    z-index: -1;
  }

  /* Assicura che le activity restino sotto l'accordion sticky */
  .activities-flex {
    position: relative;
    z-index: 1;
  }
}

.activities-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: stretch;
}

.activities-flex>div {
  flex: 1 1 0;
  min-width: 300px;
  max-width: 33.3333%;
  display: flex;
}

@media (max-width: 991.98px) {
  .activities-flex>div {
    max-width: 50%;
  }
}

@media (max-width: 767.98px) {
  .activities-flex>div {
    max-width: 100%;
  }
}

/* Card image height consistency */
.card-img-top,
.card-img-placeholder {
  height: 360px;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.card-img-top:hover,
.card-img-placeholder:hover {
  opacity: 0.85;
}

/* Card title emphasis */
.card-title.fw-bold {
  font-size: 1.15rem;
  line-height: 1.3;
}

/* Card text truncation for location */
.card-text a {
  word-break: break-word;
}

/* Modal cover image - larger and responsive */
.modal-cover-img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
  .modal-cover-img {
    max-height: none;
    border-radius: 0;
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
  }
}

.calendar-flex {
  display: flex;
  flex-direction: column;
}

/* Responsive calendar styling */
#calendar {
  height: auto;
  min-height: 400px;
}

/* Mobile calendar adjustments */
@media (max-width: 767.98px) {
  #calendar {
    height: calc(100vh - 200px);
    /* Adjust for navbar, filters, and padding */
    min-height: 300px;
  }

  /* Ensure calendar content fits properly */
  #calendar .fc-view-harness {
    height: 100% !important;
  }

  /* Adjust calendar header for mobile */
  #calendar .fc-header-toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }

  #calendar .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
  }

  /* Make calendar cells more touch-friendly */
  #calendar .fc-daygrid-day {
    min-height: 2.5rem;
  }

  #calendar .fc-daygrid-day-number {
    font-size: 0.9rem;
    padding: 0.25rem;
  }
}

/* Tablet calendar adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
  #calendar {
    height: calc(100vh - 250px);
    min-height: 350px;
  }
}

/* Stile per l'effetto flash (una sola animazione) */
.highlight-event {
  position: relative;
  overflow: hidden;
}

.highlight-event::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  animation: flash-overlay 0.7s ease-out;
  z-index: 2;
}

@keyframes flash-overlay {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

#whatsapp-summary-content {
  white-space: pre-wrap;
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 1rem;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  max-height: 50vh;
  overflow-y: auto;
}

/* Logo theme switching */
[data-bs-theme="light"] .light-logo {
  display: inline-block !important;
}

[data-bs-theme="light"] .dark-logo {
  display: none !important;
}

[data-bs-theme="dark"] .light-logo {
  display: none !important;
}

[data-bs-theme="dark"] .dark-logo {
  display: inline-block !important;
}

/* Auto theme handling */
[data-bs-theme="auto"] .light-logo {
  display: inline-block !important;
}

[data-bs-theme="auto"] .dark-logo {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  [data-bs-theme="auto"] .light-logo {
    display: none !important;
  }

  [data-bs-theme="auto"] .dark-logo {
    display: inline-block !important;
  }
}

/* Allinea a sinistra le voci della navbar anche su mobile */
@media (max-width: 991.98px) {
  .navbar-nav {
    align-items: flex-start !important;
  }

  .navbar-nav .nav-link,
  .navbar-nav .btn-link {
    justify-content: flex-start !important;
    text-align: left !important;
  }
}
