.redditi-medi-container {
    margin: 20px 0;
    font-family: Arial, sans-serif;
}

.redditi-medi-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.redditi-medi-table thead {
    background-color: #2c5aa0;
    color: white;
}

.redditi-medi-table th,
.redditi-medi-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.redditi-medi-table th {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.redditi-medi-table tbody tr:hover {
    background-color: #f5f5f5;
    transition: background-color 0.3s ease;
}

.redditi-medi-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.redditi-medi-table td:last-child {
    font-weight: bold;
    color: #2c5aa0;
    text-align: right;
}

.redditi-medi-chart-container {
    margin: 20px 0;
    text-align: center;
}

.redditi-medi-chart-container canvas {
    max-width: 100%;
    height: auto !important;
    margin: 15px 0;
}

.data-source {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 10px;
    text-align: center;
}

.redditi-medi-container h3 {
    color: #2c5aa0;
    border-bottom: 2px solid #2c5aa0;
    padding-bottom: 8px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .redditi-medi-table {
        font-size: 14px;
    }
    
    .redditi-medi-table th,
    .redditi-medi-table td {
        padding: 8px 10px;
    }
    
    .redditi-medi-chart-container canvas {
        width: 100% !important;
        max-width: none;
    }
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2c5aa0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 2s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stili per il viewer completo */
.redditi-medi-complete-viewer {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.redditi-header {
    background: linear-gradient(135deg, #2c5aa0 0%, #1a4480 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.redditi-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.8em;
    font-weight: 600;
}

.redditi-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 1em;
}

.redditi-mode-toggle {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.redditi-mode-btn {
    padding: 12px 24px;
    border: 2px solid #2c5aa0;
    background: white;
    color: #2c5aa0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.redditi-mode-btn:first-child {
    border-radius: 8px 0 0 8px;
}

.redditi-mode-btn:last-child {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

.redditi-mode-btn.active {
    background: #2c5aa0;
    color: white;
}

.redditi-mode-btn:hover:not(.active) {
    background: #f8f9fa;
}

.redditi-view-section {
    display: none;
}

.redditi-view-section.active {
    display: block;
}

.redditi-controls {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.redditi-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.redditi-control-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.redditi-control-group select {
    padding: 6px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.redditi-refresh-btn {
    padding: 6px 12px;
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: background 0.3s ease;
}

.redditi-refresh-btn:hover {
    background: #1a4480;
}

.redditi-view-toggle {
    display: flex;
    justify-content: center;
    padding: 20px;
    gap: 10px;
    background: white;
}

.redditi-toggle-btn {
    padding: 10px 20px;
    border: 2px solid #2c5aa0;
    background: white;
    color: #2c5aa0;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.redditi-toggle-btn.active {
    background: #2c5aa0;
    color: white;
}

.redditi-toggle-btn:hover:not(.active) {
    background: #f8f9fa;
}

.redditi-content {
    padding: 20px;
}

.redditi-data-view {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.redditi-data-view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.redditi-chart-container {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.redditi-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    font-size: 1.1em;
    color: #6c757d;
}

.redditi-loading i {
    animation: spin 1s linear infinite;
    margin-right: 10px;
    font-size: 1.3em;
}

.redditi-stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.redditi-stats-cards .stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    border-top: 4px solid #2c5aa0;
}

.redditi-stats-cards .stat-card h3 {
    color: #2c5aa0;
    margin: 0 0 10px 0;
    font-size: 1em;
}

.redditi-stats-cards .stat-card .value {
    font-size: 1.4em;
    font-weight: bold;
    color: #495057;
    margin: 5px 0;
}

.redditi-stats-cards .stat-card small {
    color: #6c757d;
    font-size: 0.9em;
}

.redditi-territory-filter {
    margin-bottom: 20px;
}

.redditi-territory-filter label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #495057;
}

.territory-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.territory-chip {
    padding: 6px 12px;
    background: white;
    border: 2px solid #2c5aa0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #2c5aa0;
    transition: all 0.3s ease;
}

.territory-chip.active {
    background: #2c5aa0;
    color: white;
}

.territory-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(44, 90, 160, 0.3);
}

.redditi-info-box {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    border-left: 4px solid #17a2b8;
    font-size: 14px;
}

.redditi-comparison-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.redditi-comparison-cards .stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    border-top: 4px solid #2c5aa0;
}

.redditi-comparison-cards .stat-card h3 {
    color: #2c5aa0;
    margin: 0 0 10px 0;
    font-size: 1em;
}

.redditi-comparison-cards .stat-card .value {
    font-size: 1.4em;
    font-weight: bold;
    margin: 5px 0;
}

.redditi-comparison-cards .stat-card .value.positive {
    color: #28a745;
}

.redditi-comparison-cards .stat-card .value.negative {
    color: #dc3545;
}

.redditi-comparison-cards .stat-card small {
    color: #6c757d;
    font-size: 0.8em;
    line-height: 1.3;
}

.redditi-footer {
    background: #f8f9fa;
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #dee2e6;
    color: #6c757d;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .redditi-header {
        padding: 20px;
    }
    
    .redditi-header h2 {
        font-size: 1.5em;
    }
    
    .redditi-mode-toggle {
        flex-direction: column;
        gap: 0;
    }
    
    .redditi-mode-btn {
        border-radius: 0 !important;
        border-left: 2px solid #2c5aa0 !important;
    }
    
    .redditi-mode-btn:first-child {
        border-radius: 8px 8px 0 0 !important;
    }
    
    .redditi-mode-btn:last-child {
        border-radius: 0 0 8px 8px !important;
        border-top: none !important;
    }
    
    .redditi-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .redditi-control-group {
        justify-content: space-between;
    }
    
    .redditi-view-toggle {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .redditi-toggle-btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    
    .territory-chips {
        justify-content: flex-start;
    }
    
    .redditi-stats-cards,
    .redditi-comparison-cards {
        grid-template-columns: 1fr;
    }
}