/* Icona per aprire i filtri accanto all'intestazione */
.filter-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  cursor: pointer;
  vertical-align: middle;
}

/* Icona accanto all'intestazione */
.filter-icon {
  cursor: pointer;
  margin-left: 5px;
}

/* Posizionamento corretto dei menu filtro */
.filter-menu {
  display: none;
  position: fixed;
  background: white;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
  min-width: 200px;
  font-size: 0.875rem;
}

/* Checkbox dei filtri */
.filter-menu input[type="checkbox"] {
  margin-right: 0.5rem;
}

/* Riga per ciascun valore del filtro */
.filter-menu label {
  display: block;
  padding: 2px 4px;
  cursor: pointer;
}

/* Hover nei menu filtro */
.filter-menu label:hover {
  background-color: #f0f0f0;
}

/* Tabella */
table {
  width: 100%;
  border-collapse: collapse;
}

td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  text-align: left;
}

th {
  background-color: #f3f4f6;
  font-weight: 600;
  position: relative;
}

/* Responsività */
@media (max-width: 768px) {
  .filter-menu {
    min-width: 150px;
  }
}

.active-tab {
  background-color: #2563eb; /* blu */
  color: white;
}

/* Larghezza fissa per ogni colonna */
.fixed-width-table th,
.fixed-width-table td {
  max-width: 100px;     
  min-width: 100px;
  word-wrap: break-word;
  white-space: normal;
}

/* Riga di totali in fondo alla tabella */
.totali-footer {
  background-color: #e5e7eb; /* più evidente del bg-gray-100 */
  font-weight: bold;
  border-top: 2px solid #9ca3af; /* grigio più scuro */
  color: #1f2937; /* testo più scuro */
}

thead tr {
  position: sticky;
  top: 0;
  background-color: #f3f4f6; /* stesso colore di sfondo del th */
  z-index: 10;
}

.filter-menu {
  z-index: 9999;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.fixed-width-table tfoot tr,
.fixed-width-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #f3f4f6; /* stesso colore del footer */
  z-index: 2;
}

.analisi-table-container {
  width: 100%;
  overflow-x: auto; /* consente lo scroll orizzontale quando necessario */
}

/* Easter Egg Monopoly Man */
.monopoly-man {
  position: fixed;
  width: 100px;
  height: 100px;
  z-index: 9999;
  pointer-events: none;
  transition: all 0.3s ease;
}

.monopoly-man img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.money-rain {
  position: fixed;
  width: 30px;
  height: 30px;
  z-index: 9998;
  pointer-events: none;
  animation: fall 3s linear forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

.bounce {
  animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.chart-container {
  height: 480px;
}

.chart-wrapper {
  height: 360px;
  position: relative;
}

.chart-wrapper.distribuzione-wrapper {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  padding: 0.75rem 0.75rem 0.75rem 0;
}

.chart-wrapper.distribuzione-wrapper canvas {
  flex: 0 0 55%;
  max-width: 55%;
  height: 100% !important;
}

.chart-wrapper--fill {
  height: auto;
  flex: 1;
  display: flex;
  align-items: stretch;
  padding: 0.75rem;
}

.placeholder-coming-soon {
  width: 100%;
  height: 100%;
}

.distribuzione-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.distribuzione-legend-header {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.95rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #e5e7eb;
}

.distribuzione-legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  background-color: #ffffff;
  border-radius: 0.6rem;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
}

.distribuzione-legend-content {
  flex: 1;
  min-width: 0;
}

.distribuzione-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  flex-shrink: 0;
}

.distribuzione-legend-label {
  font-weight: 600;
  color: #111827;
  font-size: 0.85rem;
}

.distribuzione-legend-meta {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.15rem;
}

.distribuzione-legend-total {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid #e5e7eb;
  font-weight: 600;
  color: #1f2937;
  font-size: 0.8rem;
}

.distribuzione-legend-note {
  font-size: 0.72rem;
  color: #92400e;
  background-color: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 0.35rem 0.45rem;
  border-radius: 0.4rem;
}

@media (max-width: 1024px) {
  .chart-wrapper.distribuzione-wrapper {
    flex-direction: column;
    padding: 0.5rem;
  }

  .chart-wrapper.distribuzione-wrapper canvas {
    flex: 0 0 auto;
    max-width: 100%;
    height: 240px !important;
  }

  .distribuzione-legend {
    width: 100%;
    max-height: 180px;
  }
}

.menu-item {
  transition: all 0.2s ease;
  position: relative;
}

.menu-item:hover {
  background-color: #f3f4f6;
}

.menu-item.active {
  background-color: #3b82f6;
  color: white;
  font-weight: 600;
}

.menu-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #1d4ed8;
}

button.disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.impostazioni-tab-btn {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.impostazioni-tab-btn:hover {
  background-color: #e5e7eb;
}

.impostazioni-tab-btn.active {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.impostazioni-tab-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Dashboard KPI cards */
.dashboard-kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}

@media (max-width: 640px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
  }
}
