/**
 * Vivaia Sticky Popup Trigger - Frontend Styles
 *
 * @package Vivaia_Sticky_Popup_Trigger
 */

/* Container - main wrapper */
.vivaia-spt-container {
    position: fixed;
    z-index: 9998;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
    transition: transform 0.2s ease;
}

/* Position modifiers */
.vivaia-spt-pos-bottom-left {
    bottom: 20px;
    left: 20px;
}

.vivaia-spt-pos-bottom-right {
    bottom: 20px;
    right: 20px;
}

.vivaia-spt-pos-top-left {
    top: 20px;
    left: 20px;
}

.vivaia-spt-pos-top-right {
    top: 20px;
    right: 20px;
}

/* Image element */
.vivaia-spt-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

/* Rotation animation */
@keyframes vivaiaSptRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.vivaia-spt-rotating {
    animation: vivaiaSptRotate 10s linear infinite;
}

/* Pause rotation on hover */
.vivaia-spt-container:hover .vivaia-spt-rotating {
    animation-play-state: paused;
}

/* Hover scale effect */
.vivaia-spt-container:hover .vivaia-spt-image {
    transform: scale(1.1);
}

/* Rotating image should not scale and rotate at the same time */
.vivaia-spt-container:hover .vivaia-spt-rotating {
    transform: scale(1.1);
}

/* Focus state for accessibility */
.vivaia-spt-container:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.vivaia-spt-container:focus:not(:focus-visible) {
    outline: none;
}

.vivaia-spt-container:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Open state */
.vivaia-spt-container.vivaia-spt-open .vivaia-spt-image {
    opacity: 0.8;
}

.vivaia-spt-container.vivaia-spt-open .vivaia-spt-text {
    opacity: 0.8;
}

/* Text mode element */
.vivaia-spt-text {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    line-height: 1.3;
    padding: 10px;
    box-sizing: border-box;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    word-break: break-word;
}

/* Hover scale effect for text mode */
.vivaia-spt-container:hover .vivaia-spt-text {
    transform: scale(1.1);
}

/* Rotating text should not scale and rotate at the same time */
.vivaia-spt-container:hover .vivaia-spt-text.vivaia-spt-rotating {
    transform: scale(1.1);
}

/* Pause rotation on hover for text mode */
.vivaia-spt-container:hover .vivaia-spt-text.vivaia-spt-rotating {
    animation-play-state: paused;
}

/* Combined image + text mode */
.vivaia-spt-combined {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.vivaia-spt-combined-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.vivaia-spt-combined-text {
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    line-height: 1.2;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    word-break: break-word;
    max-width: 90px;
}

/* Hover effects for combined mode */
.vivaia-spt-container:hover .vivaia-spt-combined-image {
    transform: scale(1.1);
}

.vivaia-spt-container:hover .vivaia-spt-combined-image.vivaia-spt-rotating {
    animation-play-state: paused;
    transform: scale(1.1);
}

/* Open state for combined mode */
.vivaia-spt-container.vivaia-spt-open .vivaia-spt-combined-image,
.vivaia-spt-container.vivaia-spt-open .vivaia-spt-combined-text {
    opacity: 0.8;
}

/* Tablet responsive (max-width: 768px) */
@media (max-width: 768px) {
    .vivaia-spt-image {
        width: 70px;
        height: 70px;
    }

    .vivaia-spt-text {
        width: 70px;
        height: 70px;
        font-size: 9px;
        padding: 8px;
    }

    .vivaia-spt-combined-image {
        width: 45px;
        height: 45px;
    }

    .vivaia-spt-combined-text {
        font-size: 9px;
        padding: 5px 8px;
        max-width: 80px;
    }

    .vivaia-spt-pos-bottom-left {
        bottom: 15px;
        left: 15px;
    }

    .vivaia-spt-pos-bottom-right {
        bottom: 15px;
        right: 15px;
    }

    .vivaia-spt-pos-top-left {
        top: 15px;
        left: 15px;
    }

    .vivaia-spt-pos-top-right {
        top: 15px;
        right: 15px;
    }
}

/* Mobile responsive (max-width: 480px) */
@media (max-width: 480px) {
    /* Hide image in image-only mode */
    .vivaia-spt-image {
        display: none;
    }

    /* Hide image in combined (image+text) mode */
    .vivaia-spt-combined-image {
        display: none;
    }

    .vivaia-spt-image {
        width: 60px;
        height: 60px;
    }

    .vivaia-spt-text {
        width: 60px;
        height: 60px;
        font-size: 8px;
        padding: 6px;
    }

    .vivaia-spt-combined-image {
        width: 40px;
        height: 40px;
    }

    .vivaia-spt-combined-text {
        font-size: 11px;
        padding: 8px 8px;
        max-width: 100px;
    }

    .vivaia-spt-pos-bottom-left {
        bottom: 10px;
        left: 10px;
    }

    .vivaia-spt-pos-bottom-right {
        bottom: 10px;
        right: 10px;
    }

    .vivaia-spt-pos-top-left {
        top: 10px;
        left: 10px;
    }

    .vivaia-spt-pos-top-right {
        top: 10px;
        right: 10px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .vivaia-spt-rotating {
        animation: none;
    }

    .vivaia-spt-container,
    .vivaia-spt-image,
    .vivaia-spt-text,
    .vivaia-spt-combined-image {
        transition: none;
    }
}

/* ===================================
   Image Popup Styles
   =================================== */

/* Prevent body scroll when popup is open */
body.vivaia-spt-body-no-scroll {
    overflow: hidden;
}

/* Full-screen overlay */
.vivaia-spt-image-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Visible state */
.vivaia-spt-image-popup-overlay.vivaia-spt-image-popup-visible {
    opacity: 1;
    visibility: visible;
}

/* Centered image container */
.vivaia-spt-image-popup-content {
    position: relative;
    max-width: min(90vw, 800px);
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The popup image itself */
.vivaia-spt-image-popup-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

/* Image scale animation when visible */
.vivaia-spt-image-popup-visible .vivaia-spt-image-popup-image {
    transform: scale(1);
}

/* Close button (X) */
.vivaia-spt-image-popup-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 36px;
    height: 36px;
    background-color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #333333;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 1;
}

.vivaia-spt-image-popup-close:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

.vivaia-spt-image-popup-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.vivaia-spt-image-popup-close:focus:not(:focus-visible) {
    outline: none;
}

.vivaia-spt-image-popup-close:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Tablet responsive for image popup */
@media (max-width: 768px) {
    .vivaia-spt-image-popup-content {
        max-width: 95vw;
        max-height: 85vh;
    }

    .vivaia-spt-image-popup-image {
        max-height: 85vh;
    }

    .vivaia-spt-image-popup-close {
        top: -12px;
        right: -12px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
}

/* Mobile responsive for image popup */
@media (max-width: 480px) {
    .vivaia-spt-image-popup-content {
        max-width: 98vw;
        max-height: 80vh;
    }

    .vivaia-spt-image-popup-image {
        max-height: 80vh;
        border-radius: 2px;
    }

    .vivaia-spt-image-popup-close {
        top: -10px;
        right: -10px;
        width: 28px;
        height: 28px;
        font-size: 18px;
    }
}

/* Reduced motion support for image popup */
@media (prefers-reduced-motion: reduce) {
    .vivaia-spt-image-popup-overlay {
        transition: none;
    }

    .vivaia-spt-image-popup-image {
        transition: none;
        transform: scale(1);
    }

    .vivaia-spt-image-popup-close {
        transition: none;
    }
}
