/* ============================================ */
/* CHART BUILDER - CSS COMPLETO E AVANZATO */
/* Versione: 2.0 - Tutti i controlli inclusi */
/* ============================================ */

/* ==================== TRIGGER BUTTON ==================== */
.chart-builder-trigger {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1499 !important;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Titillium Web', sans-serif;
}

.chart-builder-trigger:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.chart-builder-trigger i {
    font-size: 16px;
}

.pulse-ring1 {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 25px;
    border: 3px solid #8b5cf6;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) 4;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.3);
    }
}

/* ==================== MODAL CONTAINER ==================== */
.chart-builder-modal {
    position: fixed;
    top: -100%;
    right: 0;
    width: calc(100vw - var(--sidebar-width));
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 30px rgba(0,0,0,0.6);
    z-index: 2500;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-builder-modal.show {
    top: 0;
}

.chart-builder-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* ==================== HEADER ==================== */
.chart-builder-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 50%, #6d28d9 100%);
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-builder-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-builder-title i {
    font-size: 28px;
}

.chart-builder-title h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
	    color: #ffffff!important;
}

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

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

/* ==================== BODY ==================== */
.chart-builder-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ==================== SIDEBAR CONTROLLI ==================== */
.chart-builder-config {
    width: 400px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    padding: 24px;
}

.chart-builder-config::-webkit-scrollbar {
    width: 8px;
}

.chart-builder-config::-webkit-scrollbar-track {
    background: #e5e7eb;
}

.chart-builder-config::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

/* ==================== SEZIONI CONTROLLI ==================== */
.config-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.config-section:hover {
    border-color: #8b5cf6;
}

.config-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-section h3 i {
    color: #8b5cf6;
    font-size: 18px;
}

/* ==================== FORM CONTROLS ==================== */
.config-group {
    margin-bottom: 20px;
}

.config-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-label i {
    color: #8b5cf6;
    font-size: 14px;
}

.config-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Titillium Web', sans-serif;
    background: white;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.3s ease;
}

.config-select:hover {
    border-color: #8b5cf6;
}

.config-select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ==================== CHART TYPE GRID ==================== */
.chart-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.chart-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Titillium Web', sans-serif;
}

.chart-type-btn i {
    font-size: 24px;
    color: #6b7280;
    transition: all 0.3s ease;
}

.chart-type-btn span {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.3s ease;
}

.chart-type-btn:hover {
    border-color: #8b5cf6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.chart-type-btn:hover i,
.chart-type-btn:hover span {
    color: #8b5cf6;
}

.chart-type-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.chart-type-btn.active i,
.chart-type-btn.active span {
    color: white;
}

/* ==================== TIPOLOGIE CHECKBOX ==================== */
.tipologie-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}
/*
.tipologie-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}*/

/* L'ultimo elemento (Totale) occuperà tutta la riga */
.tipologie-checkboxes .tipologia-checkbox:last-child {
    grid-column: span 2;
}

.tipologia-checkbox {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tipologia-checkbox:hover {
    border-color: #8b5cf6;
    background: #f3f4f6;
}

.tipologia-checkbox.checked {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(124, 58, 237, 0.1));
}

.tipologia-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #8b5cf6;
}

.tipologia-checkbox label {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tipologia-checkbox .tipologia-icon {
    font-size: 14px;
}

/* ==================== COLOR CONTROLS ==================== */
.color-mode-group {
    margin-bottom: 16px;
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.color-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-input-wrapper label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    padding: 4px;
    transition: all 0.3s ease;
}

input[type="color"]:hover {
    border-color: #8b5cf6;
}

/* ==================== RANGE SLIDERS ==================== */
.range-group {
    margin-bottom: 18px;
}

.range-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.range-label-text {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.range-value {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    cursor: pointer;
    border: none;
}

/* ==================== PRESET BUTTONS ==================== */
.preset-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.preset-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.preset-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-color: #8b5cf6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* ==================== CHECKBOXES ==================== */
.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.checkbox-group:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #8b5cf6;
}

.checkbox-group label {
    cursor: pointer;
    font-size: 13px;
    color: #1f2937;
    font-weight: 500;
}

/* ==================== ACTION BUTTONS ==================== */
.config-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

.btn-generate {
    grid-column: span 2;
    padding: 14px 24px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Titillium Web', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-reset-builder {
    padding: 12px 20px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Titillium Web', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-reset-builder:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

/* ==================== INFO BOX ==================== */
.info-box {
    margin-top: 16px;
    padding: 14px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    font-size: 11px;
    line-height: 1.5;
}

.info-box i {
    color: #2563eb;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.info-box strong {
    color: #1e40af;
}

/* ==================== DIVIDER ==================== */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
    margin: 16px 0;
}

/* ==================== PREVIEW AREA ==================== */
.chart-builder-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.preview-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.preview-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-header h3 i {
    color: #8b5cf6;
}

.btn-download-chart {
    padding: 10px 18px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-download-chart:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ==================== FILTERS INFO ==================== */
.active-filters-box {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    min-height: 60px;
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.active-filters-box::-webkit-scrollbar {
    width: 6px;
}

.active-filters-box::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.active-filters-box::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.no-filters {
    display: block;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
    padding: 10px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid #f59e0b;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #92400e;
    margin: 4px;
}

.filter-badge i {
    font-size: 10px;
}

/* ==================== PREVIEW CONTAINER ==================== */
.preview-container {
    flex: 1;
    padding: 24px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.preview-placeholder {
    text-align: center;
    color: #9ca3af;
}

.preview-placeholder i {
    font-size: 80px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.preview-placeholder p {
    font-size: 18px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
}

.preview-placeholder small {
    font-size: 14px;
    color: #9ca3af;
}

.chart-wrapper-custom {
    width: 100%;
    height: 100%;
    min-height: 400px;
    position: relative;
    display: none;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-wrapper-custom.active {
    display: block;
}

/* ==================== FOOTER ==================== */
.chart-builder-footer {
    padding: 16px 32px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 32px;
    align-items: center;
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.footer-stat i {
    color: #8b5cf6;
    font-size: 16px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .chart-builder-config {
        width: 350px;
    }
}

@media (max-width: 992px) {
    .chart-builder-body {
        flex-direction: column;
    }
    
    .chart-builder-config {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .chart-type-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .chart-builder-trigger {
        padding: 10px 20px;
        font-size: 13px;
        height: 20px;
        left: 122px !important;
    }
    
    .chart-builder-trigger span {
        display: none;
    }
    
    .chart-builder-modal {
        width: 100vw;
    }
    
    .chart-builder-header {
        padding: 16px 20px;
    }
    
    .chart-builder-title h2 {
        font-size: 18px;
    }
    
    .chart-builder-config {
        padding: 16px;
    }
    
    .chart-type-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .config-actions {
        flex-direction: column;
    }
    
    .btn-generate {
        grid-column: span 1;
    }
    
    .tipologie-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .color-picker-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chart-builder-title i {
        display: none;
    }
    
    .chart-builder-footer {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}


.chart-type-btn[data-type="mixed"] {
    background: linear-gradient(135deg, #ff9900 0%, #ff6600 100%);
}
.chart-type-btn[data-type="mixed"] span { color: #ffffff; }
.chart-type-btn[data-type="mixed"] i { color: #ffffff; }

.chart-type-btn[data-type="mixed"]:hover {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    transform: translateY(-2px);
}

.chart-type-btn[data-type="mixed"].active {
    background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

#mixed-config-group {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}



.config-row {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.config-col-half {
    flex: 1;
}

.sub-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
}

.info-box {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    padding: 10px;
    border-radius: 4px;
    font-size: 11px;
    color: #1e293b;
}

.info-box i {
    color: #3b82f6;
    margin-right: 5px;
}
