/* Widget Principale */
.co2-widget {
    text-align: center;
    padding: 1.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    color: #333;
    max-width: 320px;
    margin: 1rem auto;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    position: relative;
    backdrop-filter: blur(6px);
    overflow: hidden;
     border: 2px solid #667eea; /* bordo azzurro coerente col logo */

}

/* Rimuovo il ::before per evitare sovrapposizioni */
.co2-widget::before {
    display: none;
}

.co2-logo {
    margin-bottom: .5rem;
    opacity: 1;
    z-index: 2;
}

.co2-logo img {
    height: 32px;
    filter: none;
}

.co2-widget h4 {
    margin: 0 0 .5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.co2-widget .current-value {
    font-size: 2.8rem;
    font-weight: 700;
    color: #222;
   /* margin: 0 0 0.3rem 0; 
     line-height: 1.03; */
}

.co2-widget .current-value small {
    font-size: 1.5rem;
    font-weight: 400;
    color: #666;
    margin-top: -.1rem; 
}

.co2-widget .comparison {
    font-size: 1.1rem;
    font-weight: 600;
    margin: .5rem 0;
    padding: 0.8rem;
    background: rgba(240, 240, 240, 0.8);
    border-radius: 10px;
    border: 1px solid #ddd;
}

.co2-widget .comparison.trend-up {
    color: #c92a2a;
    background: rgba(255, 230, 230, 0.8);
}

.co2-widget .comparison.trend-down {
    color: #2f9e44;
    background: rgba(220, 255, 220, 0.8);
}

.co2-widget .trend-icon {
    font-size: 1.3em;
    margin-right: 0.4rem;
}

.co2-widget .comparison small {
    display: block;
    font-size: 0.85rem;
    margin-top: 0.4rem;
    color: #555;
    font-weight: 400;
}

.co2-widget .co2-actions {
    margin: 1rem 0 1rem 0;
}

.co2-widget .export-co2-image {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.co2-widget .export-co2-image:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.co2-widget .co2-footer {
    font-size: 0.75rem;
    color: #666;
    margin-top: .1rem;
}

.co2-widget .co2-footer small {
    opacity: 0.7;
}
/* Grafico Storico */
.co2-historical-chart {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin: 3rem 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.co2-historical-chart .chart-container {
    width: 100%;
}

/* Tabelle dati */
.co2-historical-chart .data-table {
    margin-top: 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.co2-historical-chart .data-table table {
    width: 100%;
    border-collapse: collapse;
}

.co2-historical-chart .data-table th {
    background: #f8fafc;
    padding: 12px;
    font-weight: 600;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.co2-historical-chart .data-table td {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
}

.co2-historical-chart .data-table tr:nth-child(even) {
    background: #f8fafc;
}

/* Controlli Grafico */
.chart-controls {
    margin-top: 20px;
    text-align: center;
}

.chart-controls h4 {
    margin: 15px 0 10px 0;
    color: #2d3748;
    font-size: 16px;
}

/* Controlli SOPRA il grafico */
.chart-controls-top {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    margin-bottom: 0;
}

.periods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.periods-grid .period-btn {
    width: 100%;
    text-align: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.periods-grid .period-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.zoom-controls-top {
    text-align: center;
    padding: 10px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.zoom-controls-top .zoom-btn {
    margin: 0 5px;
    padding: 8px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.zoom-controls-top .zoom-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.zoom-controls-top .zoom-reset {
    background: #ff6b6b;
}

.zoom-controls-top .zoom-reset:hover {
    background: #e53e3e;
}

/* Migliora il container del grafico */
.chart-container {
    background: white;
    padding: 20px;
    border-radius: 0 0 12px 12px;
    border: 1px solid #e5e7eb;
    border-top: none;
}

/* Responsive */
@media (max-width: 768px) {
    .chart-controls-top {
        padding: 15px;
    }
    
    .periods-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .periods-grid .period-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .zoom-controls-top {
        padding: 8px;
    }
    
    .zoom-controls-top .zoom-btn {
        padding: 6px 10px;
        font-size: 12px;
        margin: 0 3px;
    }
}

@media (max-width: 480px) {
    .chart-controls-top {
        padding: 12px;
    }
    
    .periods-grid .period-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .zoom-controls-top {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .zoom-controls-top .zoom-btn {
        flex: 1;
        min-width: 60px;
    }
}
/* Pulsanti Periodi Storici */
.period-btn {
    margin: 5px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.period-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Pulsanti Zoom */
.zoom-btn {
    margin: 5px;
    padding: 8px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.zoom-reset {
    background: #ff6b6b;
}

.zoom-reset:hover {
    background: #e53e3e;
}

/* Responsive */
@media (max-width: 768px) {
    .period-btn {
        padding: 8px 12px;
        font-size: 12px;
        margin: 3px;
    }
    
    .zoom-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}
/* Errori */
.co2-widget.error,
.co2-chart.error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    border-radius: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .co2-widget {
        padding: 1.5rem;
        margin: 1rem;
        max-width: none;
    }
    
    .co2-widget .current-value {
        font-size: 2.8rem;
    }
    
    .co2-widget .comparison {
        font-size: 1.1rem;
        padding: 0.8rem;
    }
    
    .co2-historical-chart {
        padding: 1.5rem;
        margin: 2rem 0;
    }
    
    .co2-historical-chart .chart-container {
        height: 300px !important;
    }
}

@media (max-width: 480px) {
    .co2-widget .current-value {
        font-size: 2.2rem;
    }
    
    .co2-widget .comparison {
        font-size: 1rem;
    }
    
    .co2-historical-chart {
        padding: 1rem;
    }
}