/**
 * Paper.js Phase 2 Optimizer - Frontend Styles
 * Stili per il popup di selezione ottimizzazione Paper.js
 */

/* Overlay principale */
.phase2-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(3px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Popup principale */
.phase2-popup {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 95vw;
    max-height: 90vh;
    width: 1000px;
    overflow-y: auto;
    animation: phase2-popup-appear 0.3s ease-out;
}

@keyframes phase2-popup-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.phase2-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.phase2-header h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: bold;
}

.phase2-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 16px;
    line-height: 1.4;
}

/* Contenuto principale */
.phase2-content {
    padding: 30px;
}

/* === CONTROLLI ZOOM/PAN SINCRONIZZATI === */

.phase2-zoom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #95a5a6;
}

.phase2-zoom-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2c3e50;
    font-size: 14px;
}

#phase2-zoom-level {
    font-weight: bold;
    background: rgba(255, 255, 255, 0.8);
    padding: 3px 8px;
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
}

.phase2-zoom-separator {
    color: #7f8c8d;
}

.phase2-zoom-buttons {
    display: flex;
    gap: 5px;
}

.phase2-zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #34495e;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phase2-zoom-btn:hover {
    background: #2c3e50;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.phase2-zoom-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* === SVG CONTAINERS === */

.phase2-svg-container {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    border: 1px solid #e9ecef;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.phase2-svg-container:active {
    cursor: grabbing;
}

.phase2-preview-svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: none; /* Disabilita transizioni per performance */
}

/* Disabilita selezione su tutti gli elementi SVG */
.phase2-preview-svg * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Griglia delle preview */
.phase2-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Carte delle preview */
.phase2-preview-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.phase2-preview-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #3498db;
}

.phase2-preview-card.recommended {
    border-color: #f39c12;
    background: linear-gradient(135deg, #fff9e6, #f8f9fa);
}

.phase2-preview-card.recommended::before {
    content: "CONSIGLIATO";
    position: absolute;
    top: -8px;
    right: 10px;
    background: #f39c12;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.phase2-preview-card.skip-card {
    background: linear-gradient(135deg, #ecf0f1, #f8f9fa);
    border-color: #95a5a6;
}

.phase2-preview-card.skip-card:hover {
    border-color: #7f8c8d;
}

/* Header della carta */
.phase2-preview-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    position: relative;
}

.phase2-icon {
    font-size: 20px;
}

.phase2-preview-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
}

.phase2-star {
    position: absolute;
    right: -5px;
    top: -5px;
    font-size: 16px;
}

/* Container preview */
.phase2-preview-container {
    position: relative;
    margin-bottom: 15px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    border: 1px solid #e9ecef;
}

/* Disabilitato - ora usiamo SVG
.phase2-preview-canvas {
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.phase2-preview-canvas:hover {
    transform: scale(1.05);
}
*/

/* Loading spinner */
.phase2-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #6c757d;
}

.phase2-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: phase2-spin 1s linear infinite;
}

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

/* Info preview */
.phase2-preview-info p {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.4;
}

/* Pulsanti */
.phase2-choose-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.phase2-choose-btn:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-1px);
}

.phase2-choose-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.skip-card .phase2-choose-btn {
    background: #6c757d;
}

.skip-card .phase2-choose-btn:hover:not(:disabled) {
    background: #5a6268;
}

/* Pulsante grande per zoom modal */
.phase2-choose-btn-large {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.phase2-choose-btn-large:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Modal zoom */
.phase2-zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.phase2-zoom-content {
    background: white;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: phase2-popup-appear 0.3s ease-out;
}

.phase2-zoom-header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.phase2-zoom-header h3 {
    margin: 0;
    font-size: 18px;
}

.phase2-zoom-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.phase2-zoom-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.phase2-zoom-canvas-container {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
}

.phase2-zoom-canvas-container canvas {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.phase2-zoom-actions {
    padding: 20px;
    text-align: center;
    background: white;
}

/* Footer */
.phase2-footer {
    padding: 0 30px 30px 30px;
    text-align: center;
}

.phase2-progress {
    font-size: 14px;
    margin-bottom: 10px;
}

.phase2-tip {
    color: #6c757d;
    font-size: 13px;
    font-style: italic;
}

/* Stati di errore */
.phase2-preview-card.phase2-error-state {
    border-color: #e74c3c;
    background: #fdf2f2;
}

.phase2-error {
    text-align: center;
    color: #e74c3c;
    font-size: 14px;
    padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .phase2-popup {
        width: 95vw;
        margin: 10px;
    }
    
    .phase2-preview-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 15px;
    }
    
    .phase2-content {
        padding: 20px;
    }
    
    .phase2-header {
        padding: 15px;
    }
    
    .phase2-header h2 {
        font-size: 20px;
    }
    
    .phase2-zoom-content {
        width: 95vw;
        height: 90vh;
    }
}

@media (max-width: 480px) {
    .phase2-preview-grid {
        grid-template-columns: 1fr;
    }
    
    .phase2-content {
        padding: 15px;
    }
    
    /* Controlli zoom responsive */
    .phase2-zoom-controls {
        flex-direction: column;
        gap: 10px;
        padding: 8px 10px;
    }
    
    .phase2-zoom-info {
        order: 2;
        justify-content: center;
        font-size: 12px;
    }
    
    .phase2-zoom-buttons {
        order: 1;
        justify-content: center;
    }
    
    .phase2-zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    #phase2-zoom-level {
        min-width: 70px;
        font-size: 12px;
    }
}