/* Data Visualizer Styles */
.data-viz .container {
    max-width: 900px;
    width: 100%;
    margin: 30px auto;
    padding: 40px;
    box-sizing: border-box;
    box-shadow: 0 20px 40px rgba(0, 123, 255, 0.25);
    border-radius: 12px;
    background: white;
}

.data-viz h1 {
    font-size: 2em;
    color: #003f7f;
    margin-bottom: 25px;
    text-align: center;
}

.viz-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.data-input-section label,
.chart-options label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

#data-input {
    width: 100%;
    min-height: 120px;
    padding: 12px 15px;
    font-size: 14px;
    font-family: monospace;
    border: 2px solid #ddd;
    border-radius: 12px;
    resize: vertical;
    box-sizing: border-box;
}

#data-input:focus {
    outline: none;
    border-color: #007BFF;
}

.chart-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

/* Custom select per Chart type (menu con stessa curvatura del bottone) */
.chart-select-wrap {
    position: relative;
}

.chart-select-wrap select {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.chart-select-trigger {
    position: relative;
    min-width: 180px;
    padding: 10px 36px 10px 24px;
    font-size: 15px;
    font-weight: 600;
    box-sizing: border-box;
    border-radius: 12px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.chart-select-trigger::after {
    content: "▼";
    position: absolute;
    right: 12px;
    font-size: 0.7em;
    color: #666;
}

.chart-select-wrap.open .chart-select-trigger {
    border-color: #007BFF;
}

.chart-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    margin-top: 4px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
}

.chart-select-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}

.chart-select-option:first-child {
    border-radius: 10px 10px 0 0;
}

.chart-select-option:last-child {
    border-radius: 0 0 10px 10px;
}

.chart-select-option:hover {
    background: #f0f7ff;
}

.chart-select-option.selected {
    background: var(--btn-primary, #003f7f);
    color: white;
}

.chart-select-wrap.open .chart-select-dropdown {
    display: block;
}

#btn-generate {
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 600;
    min-width: 180px;
    box-sizing: border-box;
    background: var(--btn-primary, #003f7f);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

#btn-generate:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.chart-container.hidden {
    display: none;
}

.chart-container {
    width: 100%;
    max-width: 100%;
    max-height: 500px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#chart-canvas {
    max-width: 100%;
    max-height: 450px;
}

@media (max-width: 768px) {
    .data-viz .container {
        margin: 20px 16px;
        padding: 28px 24px;
    }
    .chart-options {
        flex-direction: column;
        align-items: stretch;
    }
    #btn-generate {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .data-viz .container {
        margin: 12px 10px;
        padding: 24px 18px;
    }
    .data-viz h1 {
        font-size: 1.4em;
    }
    #data-input {
        min-height: 100px;
        font-size: 16px; /* prevent zoom on iOS */
    }
    .chart-select-trigger {
        min-width: 100%;
    }
    #btn-generate {
        min-width: 100%;
        min-height: 48px;
    }
    .chart-container {
        padding: 16px;
        max-height: 400px;
    }
    #chart-canvas {
        max-height: 350px;
    }
}

@media (max-width: 480px) {
    .data-viz .container {
        margin: 8px 8px;
        padding: 20px 14px;
    }
}
