.modale-container {
  position: relative;
}

.btn-open-modale {
  padding: 10px 20px;
  background-color: #215732;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.btn-open-modale:hover {
  background-color: #183f24;
}

/* Modale Sheet Top */
.modale {
  display: none;
  position: fixed;
  z-index: 999999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
}

.modale.active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

/* Overlay scuro */
.modale-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  z-index: 999998;
  transition: background-color 0.3s ease;
}

.modale-overlay.active {
  display: block;
  background-color: rgba(0, 0, 0, 0.5);
}

/* Contenuto modale - animazione dall'alto */
.modale-content {
  background-color: #fefefe;
  padding: 20px;
  border-radius: 0 0 16px 16px;
  width: 100%;
  max-height: 95vh;
  min-height: 50vh;
  height: auto;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  animation: slideDownFromTop 0.4s ease-out;
  display: flex;
  flex-direction: column;
  margin-top: 0;
  z-index: 999999;
}

@keyframes slideDownFromTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modale.active .modale-content {
  animation: slideDownFromTop 0.4s ease-out;
}

/* Barra di trascinamento */
.modale-handle {
  width: 40px;
  height: 4px;
  background-color: #ccc;
  border-radius: 2px;
  margin: 0 auto 15px auto;
  cursor: grab;
  order: 10;
}

.modale-handle:active {
  cursor: grabbing;
}

/* Header della modale */
.modale-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -20px -20px 15px -20px;
  padding: 16px 20px;
  background-color: #215732;
  border-bottom: none;
  flex-shrink: 0;
}

.modale-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  flex: 1;
}

.close-modale {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.3s ease;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  height: 32px;
  flex-shrink: 0;
  position: relative;
  z-index: 100000;
}

.close-modale:hover,
.close-modale:focus {
  color: #fff;
  opacity: 0.85;
}

/* Body della modale */
.modale-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  min-height: 0;
}

/* Layout a 2 colonne tipo Amazon */
.modale-wrapper-2col {
  display: flex;
  gap: 20px;
  height: 100%;
}

/* Sidebar sinistra con filtri */
.modale-sidebar {
  flex: 0 0 280px;
  border-right: 1px solid #eee;
  padding-right: 0;
  overflow-y: auto;
  padding-top: 0;
  padding-bottom: 10px;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  margin-bottom: 15px;
  padding: 15px 20px 10px 20px;
  border-bottom: 2px solid #215732;
  flex-shrink: 0;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #215732;
}

/* Tab navigation */
.facet-tabs {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 20px;
  margin: 0;
  flex: 1;
}

.facet-tab {
  padding: 15px 0;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: #215732;
  transition: all 0.3s ease;
  position: relative;
}

.facet-tab:hover {
  background-color: #f9f9f9;
  font-weight: 600;
}

.facet-tab.active {
  font-weight: 700;
  color: #0073aa;
  border-bottom-color: #0073aa;
  border-left: 3px solid #0073aa;
  padding-left: 10px;
}

.facet-tab.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #0073aa;
}

/* Main content a destra */
.modale-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  border: none;
}

/* Pannelli dei facet */
.facet-panels {
  position: relative;
}

.facet-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.facet-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.facet-panel-title {
  margin: 0 0 20px 0;
  padding: 0 20px 15px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #215732;
  border-bottom: 2px solid #215732;
}

.modale-content-text {
  padding: 10px 0;
  line-height: 1.6;
  color: #215732;
}

/* Stili per i Facet nella modale */
.modale-facets {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modale-facet-item {
  padding: 0;
  border-bottom: none;
}

.modale-facet-item + .modale-facet-item {
  border-top: 1px solid #e5e5e5;
  padding-top: 18px;
}

.facet-title {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: #215732;
  text-transform: capitalize;
}

.facet-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px;
}

.facet-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.facet-content li {
  padding: 6px 0;
  margin: 0;
  display: flex;
  align-items: center;
}

/* Stili per checkbox e radio */
.facet-content input[type="radio"],
.facet-content input[type="checkbox"] {
  margin: 0 5px 0 0;
  line-height: normal;
  flex-shrink: 0;
  transform: scale(1.5);
  transform-origin: left center;
}

.facet-content label {
  color: #215732;
  text-decoration: none;
  font-size: 16px;
  transition: color 0.2s ease;
  text-transform: capitalize;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
}

.facet-content label:hover {
  color: #005a87;
}

.facet-count {
  background-color: #f0f0f0;
  color: #666;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  margin-left: 5px;
}

/* Stili per select */
.facet-content select {
  color: #215732;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.facet-content select:hover {
  border-color: #215732;
}

.facet-content select:focus {
  outline: none;
  border-color: #215732;
  box-shadow: 0 0 0 2px rgba(33, 87, 50, 0.1);
}

/* Footer della modale con pulsanti */
.modale-footer {
  display: flex;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  margin-top: 15px;
  flex-shrink: 0;
  order: 11;
}

.btn-reset-modale {
  flex: 1;
  padding: 12px 20px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.3s ease;
}

.btn-reset-modale:hover {
  background-color: #c82333;
}

.btn-chiudi-modale {
  flex: 1;
  padding: 12px 20px;
  background-color: #f0f0f0;
  color: #215732;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-chiudi-modale:hover {
  background-color: #e8e8e8;
  border-color: #215732;
}

/* Scrollbar personalizzata */
.modale-content::-webkit-scrollbar {
  width: 6px;
}

.modale-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.modale-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.modale-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
  .modale-content {
    max-height: 85vh;
    padding: 20px;
  }

  .modale-header h2 {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .modale-content {
    border-radius: 0 0 12px 12px;
    padding: 16px;
    max-height: 95vh;
    min-height: auto;
  }

  .modale-header {
    margin: -16px -16px 12px -16px;
    padding: 14px 16px;
  }

  .modale-header h2 {
    font-size: 18px;
  }

  .modale-wrapper-2col {
    flex-direction: row;
    gap: 0;
  }

  .modale-sidebar {
    flex: 0 0 100px;
    border-right: 1px solid #eee;
    padding-right: 0;
  }

  .sidebar-header {
    padding: 10px 8px;
    font-size: 12px;
  }

  .sidebar-header h3 {
    font-size: 12px;
  }

  .facet-tabs {
    padding: 0 8px;
  }

  .facet-tab {
    padding: 10px 0;
    font-size: 11px;
    border-bottom: 1px solid #f0f0f0;
    border-left: none;
  }

  .facet-tab.active {
    border-left: 3px solid #0073aa;
    padding-left: 7px;
    font-weight: 700;
  }

  .facet-tab.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #0073aa;
  }

  .modale-main {
    flex: 1;
    padding: 10px 0;
  }

  .facet-panel-title {
    font-size: 13px;
    padding: 0 12px 15px 12px;
  }

  .facet-content {
    padding: 0 12px;
  }

  .facet-content label {
    font-size: 16px;
  }

  .modale-footer {
    flex-direction: row;
    gap: 10px;
  }

  .btn-reset-modale,
  .btn-chiudi-modale {
    flex: 1;
    padding: 12px;
    font-size: 13px;
  }
}