/**
 * CSS per il widget di confronto benchmark industriali in tempo reale
 */

.benchmark-widget {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin: 24px 0;
    font-family: 'Lato', 'Roboto', sans-serif;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.widget-header h3 {
    color: #333;
    margin: 0;
    font-weight: 500;
    font-size: 20px;
}

.widget-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 13px;
    color: #777;
}

.widget-meta span {
    margin-bottom: 4px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.metric-box {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.metric-box.positive {
    border-left: 4px solid #28a745;
}

.metric-box.negative {
    border-left: 4px solid #dc3545;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.metric-header h4 {
    font-size: 16px;
    margin: 0;
    color: #333;
    font-weight: 500;
}

.percentile {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    background-color: #e9ecef;
    padding: 3px 8px;
    border-radius: 12px;
}

.metric-values {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.client-value, .industry-value {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.client-value .value {
    font-size: 18px;
    font-weight: 600;
    color: #007AFF;
}

.industry-value .value {
    font-size: 18px;
    font-weight: 600;
    color: #6c757d;
}

.client-value .label, .industry-value .label {
    font-size: 12px;
    color: #777;
    margin-top: 4px;
}

.comparison-bar-container {
    position: relative;
    height: 24px;
    background-color: #e9ecef;
    border-radius: 4px;
    margin-top: 8px;
}

.baseline-marker {
    position: absolute;
    top: 0;
    left: 50%;
    height: 100%;
    width: 2px;
    background-color: #adb5bd;
    z-index: 1;
}

.comparison-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #007AFF;
    border-radius: 4px;
    z-index: 0;
    transition: width 0.5s ease;
}

.comparison-bar.positive {
    background-color: #28a745;
}

.comparison-bar.negative {
    background-color: #dc3545;
}

.baseline-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #777;
    white-space: nowrap;
}

.widget-footer {
    display: flex;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.widget-explanation {
    font-size: 13px;
    color: #777;
    display: flex;
    align-items: center;
}

.color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 4px 0 12px;
}

.color-indicator.positive {
    background-color: #28a745;
}

.color-indicator.negative {
    background-color: #dc3545;
}

/* Stato di caricamento */
.benchmark-widget.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 32px 0;
}

.loading-indicator p {
    color: #666;
    margin-top: 16px;
    font-size: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 122, 255, 0.1);
    border-radius: 50%;
    border-top-color: #007AFF;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Stato di errore */
.benchmark-widget.error {
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.benchmark-widget.error .alert {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px;
    margin: 24px 0;
}

.benchmark-widget.error .alert i {
    color: #dc3545;
    width: 32px;
    height: 32px;
    margin-bottom: 16px;
}

.benchmark-widget.error .alert p {
    margin-bottom: 8px;
    font-size: 16px;
}

.benchmark-widget.error .alert p.small {
    font-size: 14px;
    color: #666;
}

/* Animazione pulsante refresh */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotating {
    animation: rotate 1s linear;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .widget-header {
        flex-direction: column;
    }
    
    .widget-meta {
        align-items: flex-start;
        margin-top: 8px;
    }
}