/* Analytics Content - MODIFICATO per adattamento automatico */


/* Analytics Panel */
.analytics-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: calc(100vw - var(--sidebar-width));  /*Corretto da "white" a "width" */
	max-width: none; /* Rimosso il limite per occupare tutto lo spazio disponibile */
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 30px rgba(0,0,0,0.6);
    z-index: 2501;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.analytics-panel.active {
    right: 0; /* Per far apparire il panel */
}

.analytics-panel.open {
    right: 0;
}

.analytics-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    padding: 8px 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.analytics-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.analytics-header-top h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
	    color: #fff;
}

.analytics-filters-info {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
}

.analytics-filters-info strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.filter-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 4px;
    margin-right: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
}

.analytics-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.analytics-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.analytics-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 32px;
    background: #ffffff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    overflow-x: auto;
}

.analytics-tab {
    padding: 12px 24px;
    background: #f9fafb;
    border: none;
    border-radius: 4px;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.analytics-tab:hover {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    color: #1f2937;
}

.analytics-tab.active {
    background: #ff9900;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.analytics-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.analytics-content::-webkit-scrollbar {
    width: 10px;
}

.analytics-content::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

.analytics-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 5px;
}

.analytics-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.analytics-tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}


.analytics-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 5px 5px 5px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

.analytics-content::-webkit-scrollbar {
    width: 10px;
}

.analytics-content::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

.analytics-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 5px;
}

.analytics-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.analytics-tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Grid charts con scroll */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 450px), 1fr));
    gap: 20px;
    align-content: start;
    padding-bottom: 20px;
}

/* Chart Container - ALTEZZA DINAMICA */
.chart-container {
    background: rgba(30, 41, 59, 0) !important;
    backdrop-filter: none !important;
    border-radius: 0px;
    padding: 0px;
    border: 0px solid rgba(148, 163, 184, 0.2);
    box-shadow: none !important;
    min-height: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Scrollbar personalizzata */
.analytics-content::-webkit-scrollbar,
.analytics-tab-content::-webkit-scrollbar {
    width: 10px;
}

.analytics-content::-webkit-scrollbar-track,
.analytics-tab-content::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

.analytics-content::-webkit-scrollbar-thumb,
.analytics-tab-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 5px;
}

.analytics-content::-webkit-scrollbar-thumb:hover,
.analytics-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* Responsive: colonna singola su schermi piccoli */
@media (max-width: 1200px) {
    #tab-temporale .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Calendario a tutta larghezza */
.chart-container.chart-full {
    grid-column: 1 / -1;
    min-height: 300px;
}

.chart-container h3 {
    color: #1f2937;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
    flex-shrink: 0;
}

.chart-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
    width: 100%;
}

.chart-container canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}


/* Insights */
.insights-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.stats-realtime,
.insights-auto {
     background: #f9fafb;
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e5e7eb;
}

.stats-realtime h3,
.insights-auto h3 {
    color: #1f2937;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.stats-realtime h3 i,
.insights-auto h3 i { color: #ff9900; }


.stats-realtime-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-realtime-item {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    padding: 20px;
    border-radius: 4px;
    text-align: center;
    border: 2px solid #ff9900;
}

.stat-realtime-label {
    font-size: 12px;
    color: #1f2937;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-realtime-value {
    font-size: 32px;
    font-weight: 800;
    color: #1f2937;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
   background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-radius: 4px;
    margin-bottom: 16px;
   border: 1px solid #ff9900;
}

.insight-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff9900 0%, #ff6600 100%);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.insight-icon i {color: #ffffff; }

.insight-content {
    flex: 1;
}

.insight-label {
    font-size: 12px;
    color: #1f2937;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.insight-value {
    font-size: 18px;
    color:#1f2937;
    font-weight: 700;
}

/* Chart Download Button */
.chart-download-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.chart-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Analytics Side Panel - si espande quando sidebar chiusa */
#analytics-side-panel {
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Opzionale: espandi leggermente quando c'è più spazio */
#sidebar.collapsed ~ #map #analytics-side-panel {
    width: 360px; /* +20px quando sidebar chiusa */
}

@media (max-width: 768px) {
    #sidebar.collapsed ~ #map #analytics-side-panel {
        width: 340px; /* Mantieni dimensione originale su mobile */
    }
}

/* Layout a due colonne per Panoramica */
.charts-grid-two-col {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.charts-grid-two-col .chart-container {
    max-height: calc(100vh - 250px);
    min-height: 500px;
}

/* Responsive: colonna singola su schermi piccoli */
@media (max-width: 1200px) {
    .charts-grid-two-col {
        grid-template-columns: 1fr;
    }
}

.btn-reset-analytics {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid fff;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.3s ease;
}

.btn-reset-analytics:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #fff
    transform: rotate(180deg);
}

.btn-reset-analytics:active {
    transform: rotate(180deg) scale(0.95);
}

/* Chart Container - altezza flessibile */
.chart-container {
    background: rgba(30, 41, 59, 0) !important;
    backdrop-filter: none !important;
    border-radius: 0px;
    padding: 0px;
    border: 0px solid rgba(148, 163, 184, 0.2);
    box-shadow: none !important;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Per il tab temporale con 2 colonne */
#tab-temporale .charts-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}




/* Layout responsive per tab temporale */
@media (max-width: 1200px) {
    #tab-temporale .charts-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Calendario Heatmap Custom - COMPATTO */
.calendar-heatmap {
    width: 100%;
    overflow-x: auto;
    padding: 10px;
}

.calendar-heatmap-grid {
    display: inline-grid;
    grid-template-columns: 70px repeat(31, minmax(18px, 1fr));
    gap: 1px;
    width: 100%;
    font-size: 9px;
}

.calendar-heatmap-header {
    display: contents;
}

.calendar-heatmap-day-label,
.calendar-heatmap-month-label {
    background: rgba(30, 41, 59, 0.6);
    color: #f1f5f9;
    padding: 4px 2px;
    text-align: center;
    font-weight: 600;
    border-radius: 2px;
    font-size: 8px;
}

.calendar-heatmap-month-label {
    text-align: right;
    padding-right: 6px;
    font-size: 9px;
}

.calendar-heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(15, 23, 42, 0.3);
    font-size: 8px;
}

.calendar-heatmap-cell:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    font-size: 10px;
}

.calendar-heatmap-cell.empty {
    background: rgba(148, 163, 184, 0.1);
    color: transparent;
    cursor: default;
}

.calendar-heatmap-cell.empty:hover {
    transform: none;
    box-shadow: none;
}

.calendar-heatmap-cell.active {
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #3b82f6;
    z-index: 100;
}

/* Gradiente di colori basato sull'intensità */
.calendar-heatmap-cell.intensity-1 {
    background: #fed7aa;
    color: #1e293b;
}

.calendar-heatmap-cell.intensity-2 {
    background: #fdba74;
    color: #1e293b;
}

.calendar-heatmap-cell.intensity-3 {
    background: #fb923c;
    color: #1e293b;
}

.calendar-heatmap-cell.intensity-4 {
    background: #f97316;
    color: #fff;
}

.calendar-heatmap-cell.intensity-5 {
    background: #ea580c;
    color: #fff;
}

.calendar-heatmap-cell.intensity-6 {
    background: #c2410c;
    color: #fff;
}

.calendar-heatmap-cell.intensity-7 {
    background: #991b1b;
    color: #fff;
}

@media (max-width: 1400px) {
    .calendar-heatmap-grid {
        font-size: 8px;
        grid-template-columns: 65px repeat(31, minmax(16px, 1fr));
    }
    
    .calendar-heatmap-cell {
        font-size: 7px;
    }
}

@media (max-width: 1200px) {
    .calendar-heatmap-grid {
        font-size: 7px;
        grid-template-columns: 60px repeat(31, minmax(14px, 1fr));
    }
    
    .calendar-heatmap-cell {
        font-size: 6px;
    }
}

/* Responsive per tab Panoramica */
.charts-grid-two-col {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.charts-grid-two-col .chart-container {
    max-height: calc(100vh - 250px);
    min-height: 400px;
}

/* Responsive: adattamento automatico */
@media (max-width: 1600px) {
    .charts-grid-two-col .chart-container {
        min-height: 350px;
    }
}

@media (max-width: 1400px) {
    .charts-grid-two-col .chart-container {
        min-height: 300px;
    }
}

@media (max-width: 1200px) {
    .charts-grid-two-col {
        grid-template-columns: 1fr;
    }
    
    .charts-grid-two-col .chart-container {
        min-height: 400px;
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    .charts-grid-two-col .chart-container {
        min-height: 300px;
    }
.insights-container {display: flex;  flex-direction: column; flex: 1; overflow-y: auto;     }
.analytics-content {padding: 5px 2px 8px 2px; }
.analytics-tabs {     padding: 12px 12px; flex-direction: row;  flex-wrap: wrap;    justify-content: space-evenly;}

}

/* Miglioramento per Analytics Panel su schermi grandi */
@media (min-width: 1920px) {
    .analytics-panel {
        width: calc(100vw - 340px);
    }
    
    .charts-grid-two-col .chart-container {
        min-height: 450px;
    }
}


/* Tab Oraria - 4 grafici in griglia 2x2 */
#tab-oraria .charts-grid-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - 300px);
    min-height: 600px;
}

#tab-oraria .chart-container {
    min-height: 250px;
    height: 100%;
}

/* Panoramica - adattamento automatico */
#tab-panoramica .charts-grid-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - 280px);
    min-height: 500px;
    align-content: stretch;
}

#tab-panoramica .chart-container {
    min-height: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#tab-panoramica .chart-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
    width: 100%;
}

/* Responsive tablet */
@media (max-width: 1400px) {
    #tab-oraria .charts-grid-two-col,
    #tab-panoramica .charts-grid-two-col {
        height: auto;
        grid-template-rows: auto;
    }
    
    #tab-oraria .chart-container {
        min-height: 300px;
        height: auto;
    }
}

/* Responsive mobile */
@media (max-width: 1200px) {
    #tab-oraria .charts-grid-two-col {
        grid-template-columns: 1fr;
    }
    
    #tab-oraria .chart-container {
        min-height: 350px;
        max-height: 500px;
    }
}

/* Responsive per Panoramica */
@media (max-width: 1400px) {
    #tab-panoramica .charts-grid-two-col {
        height: calc(100vh - 250px);
        min-height: 450px;
    }
}

@media (max-width: 1200px) {
    #tab-panoramica .charts-grid-two-col {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 400px;
    }
    
    #tab-panoramica .chart-container {
        min-height: 350px;
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    #tab-panoramica .chart-container {
        min-height: 300px;
    }
}