* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50, #4a6491);
    color: white;
    padding: 25px 30px;
    text-align: center;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.content {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
}

.input-section {
    flex: 1;
    min-width: 300px;
    padding: 30px;
    border-right: 1px solid #eaeaea;
}

.output-section {
    flex: 2;
    min-width: 500px;
    padding: 30px;
    display: flex;
    flex-direction: column;
}

.input-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: #4a6491;
}

.unit {
    color: #666;
    font-size: 0.9rem;
    margin-left: 5px;
}

.calc-btn {
    background: linear-gradient(to right, #4a6491, #2c3e50);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-top: 10px;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 30px;
    padding: 0 30px 30px;
}

.action-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.save-btn {
    background-color: #27ae60;
    color: white;
}

.load-btn {
    background-color: #3498db;
    color: white;
}

.dxf-btn {
    background-color: #f39c12;
    color: white;
}

.print-btn {
    background-color: #9b59b6;
    color: white;
}

.reset-btn {
    background-color: #95a5a6;
    color: white;
}

.png-btn {
    background-color: #1abc9c;
    color: white;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.visualizations {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    min-height: 400px;
}

.visualization-container {
    flex: 1;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
    overflow: hidden;
}

.visualization-title {
    background-color: #4a6491;
    color: white;
    padding: 10px 15px;
    font-weight: 600;
    text-align: center;
    font-size: 16px;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    min-height: 350px;
}

canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.results {
    margin-top: 30px;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 5px solid #4a6491;
}

.results h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 600;
    white-space: nowrap;
}

.result-value {
    color: #2c3e50;
    font-weight: 600;
    text-align: right;
    min-width: 100px;
}

.instructions {
    background-color: #fff8e1;
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
    border-left: 5px solid #ffb300;
}

.instructions h3 {
    color: #e65100;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
}

footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
    margin-top: 30px;
}

@media (max-width: 900px) {
    .content {
        flex-direction: column;
    }

    .input-section {
        border-right: none;
        border-bottom: 1px solid #eaeaea;
    }

    .visualizations {
        flex-direction: column;
    }

    .visualization-container {
        min-width: 100%;
    }
}

.hidden {
    display: none;
}

#fileInput {
    display: none;
}

.dxf-format-info {
    background-color: #e8f4f8;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 5px solid #3498db;
    font-size: 0.9rem;
}

.dxf-format-info h4 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.dxf-format-info ul {
    padding-left: 20px;
    margin-top: 5px;
}

.error-message {
    background-color: #ffe6e6;
    color: #c00;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 15px;
    border-left: 5px solid #c00;
    display: none;
}

.success-message {
    background-color: #e6ffe6;
    color: #006600;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 15px;
    border-left: 5px solid #006600;
    display: none;
}

.formula-info {
    background-color: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 5px solid #4a6491;
    font-size: 0.9rem;
}

.formula-info h4 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.formula-info ul {
    padding-left: 20px;
    margin-top: 5px;
}

.formula {
    font-family: 'Courier New', monospace;
    background-color: #f8f9fa;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.material-options {
    margin-bottom: 25px;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-option input {
    width: auto;
}

.warning-note {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 15px;
    border-left: 5px solid #ffc107;
    font-size: 0.9rem;
}

.print-info {
    display: none;
}

@media print {
    body {
        background-color: white;
        padding: 0;
        margin: 0;
        font-size: 10pt;
        line-height: 1.2;
        width: 100%;
        height: 100%;
    }

    .container {
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
        margin: 0;
        padding: 0;
        page-break-inside: avoid;
        height: auto;
        min-height: 100vh;
    }

    header {
        background: white;
        color: black;
        padding: 3px;
        border-bottom: 2px solid #333;
        text-align: center;
        height: auto;
        min-height: auto;
    }

    h1 {
        font-size: 16pt;
        margin-bottom: 2px;
        page-break-after: avoid;
    }

    .subtitle {
        font-size: 10pt;
        color: #666;
        margin-bottom: 5px;
    }

    .buttons,
    .instructions,
    .input-section,
    .formula-info,
    .warning-note,
    footer {
        display: none;
    }

    .visualizations {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        margin-top: 10px;
        min-height: 280px;
        height: 280px;
        max-height: 280px;
        page-break-inside: avoid;
        justify-content: center;
        align-items: center;
        width: 100%;
    }

    .visualization-container {
        display: flex;
        flex: 1;
        min-width: 48%;
        max-width: 48%;
        border: 1px solid #ccc;
        background: white;
        box-shadow: none;
        height: 270px;
        min-height: 270px;
        max-height: 270px;
        margin: 0 auto;
        padding: 0;
        page-break-inside: avoid;
    }

    .visualization-title {
        background: white;
        color: black;
        font-size: 11pt;
        font-weight: bold;
        padding: 4px;
        border-bottom: 1px solid #333;
        height: 25px;
        min-height: 25px;
        max-height: 25px;
        text-align: center;
    }

    .canvas-wrapper {
        padding: 5px;
        min-height: 240px;
        height: 240px;
        max-height: 240px;
        display: flex;
        justify-content: center;
        align-items: center;
        page-break-inside: avoid;
        margin: 0 auto;
    }

    #developmentCanvas {
        max-width: 100%;
        max-height: 230px;
        height: 230px;
        width: 230px;
        border: 1px solid #aaa;
        page-break-inside: avoid;
        display: block;
        margin: 0 auto;
        object-fit: contain;
    }

    #cone3DCanvas {
        max-width: 100%;
        max-height: 230px;
        height: 230px;
        width: 230px;
        border: 1px solid #aaa;
        page-break-inside: avoid;
        display: block;
        margin: 0 auto;
        object-fit: contain;
    }

    .content {
        display: block;
        padding: 0;
        margin: 0;
        page-break-inside: avoid;
        height: auto;
    }

    .output-section {
        padding: 10px;
        min-width: 100%;
        page-break-inside: avoid;
        margin: 0 auto;
        height: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .results {
        margin-top: 10px;
        padding: 8px;
        page-break-inside: avoid;
        break-inside: avoid;
        background-color: white;
        border: 1px solid #ccc;
        flex-shrink: 0;
        height: auto;
        min-height: auto;
        max-height: none;
        width: 100%;
        max-width: 100%;
    }

    .results h3 {
        font-size: 12pt;
        margin-bottom: 6px;
        color: black;
        break-after: avoid;
        text-align: center;
    }

    .result-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 20px;
        font-size: 9pt;
        width: 100%;
        margin: 0 auto;
    }

    .result-item {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 10px;
        padding: 4px 0;
        break-inside: avoid;
        border-bottom: 1px dashed #eee;
        align-items: center;
    }

    .result-item:last-child {
        border-bottom: none;
    }

    .result-label {
        font-size: 9pt;
        font-weight: bold;
        white-space: nowrap;
        text-align: left;
    }

    .result-value {
        font-size: 9pt;
        font-weight: normal;
        text-align: right;
        color: #000;
        font-family: 'Courier New', monospace;
    }

    .output-section,
    .visualization-container,
    .results {
        break-inside: avoid;
        page-break-inside: avoid;
        break-after: avoid;
    }

    body.print-mode * {
        margin: 0;
        padding: 0;
    }

    @page {
        margin: 1.5cm;
        size: A4 portrait;

        @top-center {
            content: "Sviluppo Tronco di Cono - Lamiereria";
            font-size: 10pt;
            font-weight: bold;
        }

        @bottom-center {
            content: "Pagina " counter(page);
            font-size: 8pt;
        }
    }

    body > *:not(.container) {
        display: none;
    }

    .print-mode {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .container.print-layout {
        width: 100%;
        height: auto;
    }

    .content.print-content > * {
        padding: 0;
        margin: 0;
    }

    .print-info {
        display: block;
        text-align: center;
        font-size: 8pt;
        margin-bottom: 5px;
        color: #666;
        padding: 2px;
        width: 100%;
    }
}
