/**
 * Frontend Styles - Simple Popup Manager
 * Stili per popup responsive con animazioni
 */

/* Wrapper principale del popup */
.spm-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.spm-popup-wrapper.spm-active {
    display: flex;
}

/* Overlay (sfondo scuro) */
.spm-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0.7;
    z-index: 1;
}

/* Container del popup */
.spm-popup-container {
    position: relative;
    z-index: 2;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease-in-out;
}

.spm-popup-wrapper.spm-active .spm-popup-container {
    transform: scale(1);
    opacity: 1;
}

/* Pulsante chiusura */
.spm-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.spm-close-btn:hover {
    background: rgba(0,0,0,0.8);
    transform: rotate(90deg);
}

.spm-close-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Contenuto del popup */
.spm-popup-content {
    position: relative;
}

.spm-popup-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.spm-popup-content p:first-child {
    margin-top: 0;
}

.spm-popup-content p:last-child {
    margin-bottom: 0;
}

/* Scrollbar personalizzata per popup con molto contenuto */
.spm-popup-container::-webkit-scrollbar {
    width: 8px;
}

.spm-popup-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

.spm-popup-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.spm-popup-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

/* ========================================
   ANIMAZIONI
   ======================================== */

/* Fade In/Out (default) */
.spm-animation-fade {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.spm-popup-wrapper.spm-active .spm-animation-fade {
    animation-name: spmFadeIn;
}

.spm-popup-wrapper.spm-closing .spm-animation-fade {
    animation-name: spmFadeOut;
}

@keyframes spmFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spmFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Slide Down */
.spm-animation-slide-down {
    animation-duration: 0.4s;
    animation-fill-mode: both;
}

.spm-popup-wrapper.spm-active .spm-animation-slide-down {
    animation-name: spmSlideDown;
}

.spm-popup-wrapper.spm-closing .spm-animation-slide-down {
    animation-name: spmSlideUp;
}

@keyframes spmSlideDown {
    from {
        opacity: 0;
        transform: translateY(-100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spmSlideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-100px);
    }
}

/* Slide Up */
.spm-animation-slide-up {
    animation-duration: 0.4s;
    animation-fill-mode: both;
}

.spm-popup-wrapper.spm-active .spm-animation-slide-up {
    animation-name: spmSlideUpIn;
}

.spm-popup-wrapper.spm-closing .spm-animation-slide-up {
    animation-name: spmSlideUpOut;
}

@keyframes spmSlideUpIn {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spmSlideUpOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100px);
    }
}

/* Zoom */
.spm-animation-zoom {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.spm-popup-wrapper.spm-active .spm-animation-zoom {
    animation-name: spmZoomIn;
}

.spm-popup-wrapper.spm-closing .spm-animation-zoom {
    animation-name: spmZoomOut;
}

@keyframes spmZoomIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spmZoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Nessuna animazione */
.spm-animation-none {
    transition: none !important;
    animation: none !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
    .spm-popup-wrapper {
        padding: 15px;
    }
    
    .spm-popup-container {
        max-height: 85vh;
        width: 100% !important;
        max-width: 95% !important;
    }
    
    .spm-close-btn {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .spm-popup-wrapper {
        padding: 10px;
    }
    
    .spm-popup-container {
        max-height: 80vh;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 8px !important;
    }
    
    .spm-close-btn {
        top: 5px;
        right: 5px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
    
    /* Riduci padding interno su mobile */
    .spm-popup-content {
        font-size: 14px;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .spm-popup-container {
        max-height: 95vh;
    }
}

/* Accessibilità */
@media (prefers-reduced-motion: reduce) {
    .spm-popup-container,
    .spm-close-btn {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus visibile per accessibilità */
.spm-popup-container:focus {
    outline: 3px solid #0073aa;
    outline-offset: 3px;
}

/* Previeni scroll del body quando popup è aperto */
body.spm-popup-open {
    overflow: hidden;
}
