* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pinch-zoom;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    -webkit-touch-callout: none;
    touch-action: pan-y pinch-zoom;
}

.schema-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
    position: relative;
}

.schema-header {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 1.3em;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-left p {
    font-size: 0.75em;
    opacity: 0.7;
    margin: 2px 0 0 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-back,
.btn-print,
.btn-download {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.btn-back .icon,
.btn-print .icon,
.btn-download .icon {
    font-size: 1.1em;
}

.btn-back:hover,
.btn-print:hover,
.btn-download:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.schema-content {
    flex: 1;
    overflow: auto;
    display: flex;
    gap: 20px;
    padding: 20px;
    background: #0a0a0a;
    position: relative;
}

.schema-image-wrapper {
    flex: 1;
    min-width: 0;
    display: block;
    overflow: auto;
    position: relative;
    background: #0f0f0f;
    border-radius: 8px;
    padding: 20px;
}

.schema-image {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: width 0.2s ease, height 0.2s ease;
    cursor: grab;
    user-select: none;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.schema-image:active {
    cursor: grabbing;
}

.schema-info {
    width: 380px;
    flex-shrink: 0;
    background: rgba(30, 30, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    position: sticky;
    top: 80px;
    align-self: flex-start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.info-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-header h2 {
    color: white;
    font-size: 1.2em;
    margin: 0;
    font-weight: 600;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-item strong {
    display: block;
    color: #3498db;
    font-size: 0.9em;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin: 0;
    font-size: 0.9em;
}


.schema-zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.btn-zoom {
    background: rgba(52, 152, 219, 0.2);
    color: white;
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-zoom:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: rgba(52, 152, 219, 0.5);
    transform: scale(1.05);
}

.btn-zoom:active {
    transform: scale(0.95);
}

.zoom-level {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    min-width: 50px;
    text-align: center;
    font-size: 0.85em;
    padding: 0 8px;
}

/* Scrollbar personalizzata per info panel */
.schema-info::-webkit-scrollbar {
    width: 6px;
}

.schema-info::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.schema-info::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.schema-info::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Stili per la stampa */
@media print {
    body {
        background: white;
        overflow: visible;
    }
    
    .schema-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
    }
    
    .schema-header {
        background: #2c3e50;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .header-actions,
    .schema-zoom-controls,
    .schema-info {
        display: none;
    }
    
    .schema-image-wrapper {
        height: auto;
        min-height: 80vh;
        padding: 20px;
    }
    
    .schema-image {
        transform: scale(1) !important;
        max-width: 100%;
        max-height: none;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .schema-content {
        flex-direction: column;
    }
    
    .schema-image-wrapper {
        width: 100%;
        min-height: 400px;
    }
    
    .schema-info {
        width: 100%;
        position: relative;
        top: 0;
        transform: none;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .schema-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }
    
    .header-left {
        width: 100%;
        text-align: center;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .btn-back .text,
    .btn-print .text,
    .btn-download .text {
        display: none;
    }
    
    .btn-back,
    .btn-print,
    .btn-download {
        padding: 8px 12px;
    }
    
    .schema-content {
        padding: 15px;
        gap: 15px;
    }
    
    .schema-zoom-controls {
        bottom: 15px;
        right: 15px;
        padding: 6px;
    }
    
    .btn-zoom {
        width: 32px;
        height: 32px;
        font-size: 1em;
    }
    
    .zoom-level {
        font-size: 0.75em;
        min-width: 40px;
    }
}
