/**
 * Stili per il popup di vettorizzazione stile Stampo
 */

/* Overlay del popup */
#vr-vectorizer-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container del popup */
.imorder-popup-container {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.08);
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Container compatto */
.imorder-popup-container.imorder-popup-compact {
    max-width: 1100px;
    width: 95%;
    max-height: 85vh;
}

/* Header del popup */
.imorder-popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 24px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.imorder-popup-compact .imorder-popup-header {
    padding: 16px 20px;
}

.imorder-popup-header h2 {
    margin: 0;
    font-size: 24px;
}

.imorder-popup-header h3 {
    margin: 0;
    font-size: 28px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Rimuovo la regola duplicata che sovrascrive */

.imorder-popup-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s;
    padding: 0;
    width: 30px;
    height: 30px;
}

.imorder-popup-close:hover {
    opacity: 1;
}

/* Body del popup */
.imorder-popup-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    background-color: #fafafa;
}

.imorder-popup-compact .imorder-popup-body {
    padding: 15px;
}

/* Container vettorizzatore */
.vr-vectorizer-container {
    max-width: 100%;
}

/* Top section - immagine originale e testo affiancati */
.vr-vectorizer-top-section {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

/* Container per l'immagine originale */
.vr-original-image-container {
    flex: 0 0 200px;
    height: 200px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e5e7eb;
}

#vr-original-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vr-original-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Info box */
.vr-vectorizer-info {
    flex: 1;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #0ea5e9;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.vr-info-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.vr-vectorizer-info h4 {
    margin: 0 0 10px 0;
    color: #1e293b;
    font-size: 18px;
    font-weight: 600;
}

.vr-vectorizer-info p {
    margin: 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}

/* Preview section */
.vr-vectorizer-preview-section {
    position: relative;
}

/* Controlli inline - posizionati in alto a destra */
.vr-vectorizer-controls-inline {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.vr-control-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.vr-control-item input[type="checkbox"] {
    cursor: pointer;
}

.vr-control-item span {
    font-size: 14px;
    color: #374151;
}

.button-small {
    padding: 6px 12px !important;
    font-size: 14px !important;
}

/* Icon buttons */
.icon-button {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-button:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.icon-button.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.icon-button i {
    font-size: 16px;
}

/* Messaggio */
#vr-vectorizer-msg {
    margin-bottom: 24px;
}

#vr-vectorizer-msg p:first-child {
    font-size: 16px;
    margin: 0 0 8px 0;
    color: #1f2937;
}

#vr-vectorizer-msg p:last-child {
    margin: 0;
    line-height: 1.5;
}

.notice {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.notice-info {
    background-color: #f0f8ff;
    color: #2563eb;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
}

/* Controlli */
.vr-vectorizer-controls {
    margin-bottom: 24px;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
}

.vr-vectorizer-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.vr-vectorizer-controls input[type="checkbox"] {
    cursor: pointer;
}

.vr-vectorizer-controls .button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.vr-vectorizer-controls .button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.vr-vectorizer-controls .button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Preview area */
#vr-vectorizer-preview {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

/* Container per l'originale */
.vr-original-container {
    display: flex;
    justify-content: center;
    padding: 15px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Container per le vettorizzazioni */
.vr-vectors-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    justify-content: center;
    align-items: flex-start;
    padding: 15px;
    padding-top: 50px; /* Spazio per i pulsanti */
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    /* overflow-x: auto; */
    /* overflow-y: visible; */
}

/* Thumbnails */
.vr-thumb {
    width: 200px;
    height: 200px;
    min-width: 200px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
    position: relative;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.vr-thumb:hover {
    border-color: #667eea;
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.25);
    cursor: zoom-in;
}

.vr-thumb.selected {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    transform: translateY(-2px);
}

.vr-thumb small {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    order: 2;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.vr-thumb img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    order: 1;
    border-radius: 8px;
}

/* SVG container */
.svg-container {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    order: 1;
    padding: 8px;
    box-sizing: border-box;
    border-radius: 8px;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.svg-container svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 160px !important;
    max-height: 160px !important;
    object-fit: contain;
}

/* Vector thumb specific */
.vr-thumb.vector {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-style: dashed;
}

.vr-thumb.vector:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Preview ingrandito al hover */
.vr-hover-preview {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 450px;
    height: 450px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    pointer-events: none;
}

.vr-hover-preview.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.vr-hover-preview img,
.vr-hover-preview svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

.vr-thumb.vector.selected {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-style: solid;
}

/* Loading overlay */
.imorder-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.loading-content i {
    margin-bottom: 15px;
}

.loading-content p {
    font-size: 18px;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    /* Overlay full screen su mobile */
    #vr-vectorizer-popup {
        padding: 0;
    }
    
    .imorder-popup-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    /* Header fisso su mobile */
    .imorder-popup-header {
        flex-shrink: 0;
        border-radius: 0;
        padding: 15px 20px;
    }
    
    /* Body scrollabile */
    .imorder-popup-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling iOS */
        flex: 1;
        min-height: 0; /* Importante per flex scroll */
        padding: 15px;
    }
    
    .imorder-popup-compact .imorder-popup-body {
        padding: 10px;
    }
    
    /* Layout mobile: testo sopra, immagine sotto */
    .vr-vectorizer-top-section {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Immagine originale a larghezza piena su mobile */
    .vr-original-image-container {
        flex: 1 1 100%;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        order: 2; /* Immagine sotto */
    }
    
    /* Info box sopra su mobile */
    .vr-vectorizer-info {
        order: 1; /* Testo sopra */
        margin-bottom: 0;
    }
    
    #vr-vectorizer-preview {
        gap: 15px;
    }
    
    .vr-original-container,
    .vr-vectors-container {
        padding: 10px;
    }
    
    /* Anteprime su 2 colonne */
    .vr-vectors-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        justify-content: center;
        overflow-x: hidden;
        padding-top: 50px;
    }
    
    .vr-thumb {
        width: 100%;
        min-width: unset;
        height: 140px;
        padding: 6px;
    }
    
    .svg-container {
        height: 120px;
    }
    
    /* Disabilita hover preview su mobile */
    .vr-hover-preview {
        display: none;
    }
    
    /* Info box mobile */
    .vr-vectorizer-info {
        padding: 15px;
    }
    
    .vr-vectorizer-info h4 {
        font-size: 16px;
    }
    
    .vr-vectorizer-info p {
        font-size: 13px;
    }
    
    .vr-thumb img {
        max-height: 120px;
    }
    
    .vr-vectorizer-controls {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .imorder-popup-body {
        padding: 15px;
    }
    
    #vr-vectorizer-preview {
        padding: 12px;
        gap: 8px;
    }
    
    /* Mantieni le anteprime su 2 colonne anche su schermi piccoli */
    .vr-vectors-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
        padding-top: 45px;
    }
    
    .vr-thumb {
        width: 100%;
        height: 120px;
        min-width: unset;
        padding: 5px;
    }
    
    .svg-container {
        height: 100px;
    }
    
    .vr-thumb img {
        max-height: 100px;
    }
    
    .vr-thumb small {
        font-size: 12px;
        margin-top: 8px;
    }
    
    .vr-vectorizer-controls {
        padding: 12px;
        gap: 12px;
    }
}

/* Animazioni */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#vr-vectorizer-popup {
    animation: fadeIn 0.3s ease-out;
}

/* Scrollbar personalizzata per preview area */
#vr-vectorizer-preview::-webkit-scrollbar {
    height: 8px;
}

#vr-vectorizer-preview::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

#vr-vectorizer-preview::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#vr-vectorizer-preview::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Indicatore di selezione migliorato */
.vr-thumb.selected::before {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 1;
    animation: checkMark 0.3s ease-out;
}

@keyframes checkMark {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Tooltip per le anteprime */
.vr-thumb {
    position: relative;
}

.vr-thumb::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.vr-thumb:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ===== MIGLIORAMENTI MOBILE AGGIUNTIVI PER VECTORIZER ===== */

/* Prevenire overflow orizzontale su mobile */
@media (max-width: 768px) {
    #vr-vectorizer-popup {
        padding: 0;
        box-sizing: border-box;
    }
    
    .imorder-popup-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden;
        box-sizing: border-box;
    }
    
    .imorder-popup-header {
        padding: 15px 20px;
        border-radius: 0;
    }
    
    .imorder-popup-body {
        padding: 10px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box;
    }
    
    #vr-vectorizer-preview {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        box-sizing: border-box;
    }
    
    .vr-original-container,
    .vr-vectors-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box;
    }
    
    .vr-vectors-container {
        overflow-x: hidden !important;
    }
    
    .vr-thumb {
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .svg-container {
        overflow: hidden !important;
        box-sizing: border-box;
    }
    
    .svg-container img,
    .svg-container svg {
        max-width: 100% !important;
        height: auto !important;
        box-sizing: border-box;
    }
}

/* Touch improvements per mobile */
@media (hover: none) and (pointer: coarse) {
    .vr-thumb {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .vr-thumb:hover {
        transform: none;
        cursor: pointer;
    }
    
    .vr-thumb:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Disabilita hover zoom su touch devices */
    .vr-thumb:hover {
        cursor: pointer;
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Mobile molto piccolo - mantieni 2 colonne */
@media (max-width: 380px) {
    .imorder-popup-header h3 {
        font-size: 16px !important;
    }
    
    .vr-vectors-container {
        gap: 5px;
        padding: 8px;
        padding-top: 40px;
    }
    
    .vr-thumb {
        height: 100px;
        padding: 4px;
    }
    
    .svg-container {
        height: 80px;
    }
    
    .vr-thumb small {
        font-size: 11px;
        margin-top: 5px;
    }
    
    .vr-vectorizer-controls {
        padding: 8px !important;
        gap: 8px !important;
    }
    
    .vr-vectorizer-controls button {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
}