
/* Popup Styles */
.spm-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 0; /* Ökat från 9998 */
}

.spm-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    background-color: #fff;
    padding: 0;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 0; /* Ökat från 9999 */
    animation: popupFadeIn 0.3s ease-out;
    max-height: 90vh;
    overflow: hidden;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.spm-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1;
    background: rgba(255, 255, 255, 0.9);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.spm-close:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* Standard popup content */
.spm-popup-content {
    padding: 30px;
    overflow-y: auto;
    max-height: 90vh;
}

.spm-popup h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

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

.spm-button {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: opacity 0.3s;
}

.spm-button:hover {
    opacity: 0.9;
}

/* Button wrapper and alignment */
.spm-button-wrapper {
    margin-top: 20px;
	margin-bottom:30px;
}

.spm-button-wrapper.align-left {
    text-align: left;
}

.spm-button-wrapper.align-center {
    text-align: center;
}

.spm-button-wrapper.align-right {
    text-align: right;
}

.spm-button-wrapper.align-full .spm-button {
    width: 100%;
}

.spm-button-fixed-wrapper {
    position: sticky;
    bottom: 0;
    padding: 20px 30px;
    background: inherit;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Two column layouts - special handling */
.spm-popup-content.layout-two-columns,
.spm-popup-content.layout-image-left,
.spm-popup-content.layout-image-right {
    display: flex;
    padding: 0;
    height: auto;
    max-height: 90vh;
}

/* Image column for two-column layouts */
.spm-popup-content.layout-image-left .spm-image-column,
.spm-popup-content.layout-image-right .spm-image-column {
    flex: 0 0 50%;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

/* Cover mode - default */
.spm-popup-content[data-image-fit="cover"] .spm-image-column img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}

/* Contain mode - show full image with padding */
.spm-popup-content[data-image-fit="contain"] .spm-image-column {
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
    padding: 40px; /* Lägg till padding för contain mode */
}

.spm-popup-content[data-image-fit="contain"] .spm-image-column img {
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px; /* Lite rundade hörn för snyggare look */
}

/* Auto mode - natural size */
.spm-popup-content[data-image-fit="auto"] {
    align-items: stretch;
}

.spm-popup-content[data-image-fit="auto"] .spm-image-column {
    flex: 0 0 auto;
    background: inherit;
    padding: 40px;
}

.spm-popup-content[data-image-fit="auto"] .spm-image-column img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 600px;
    object-fit: none;
}

/* Text column for two-column layouts */
.spm-popup-content.layout-image-left .spm-text-column,
.spm-popup-content.layout-image-right .spm-text-column {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 300px;
}

/* Responsive text sizing - Desktop with !important */
.spm-popup-content .spm-text-column h1,
.spm-popup-content h1 {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem) !important;
    line-height: 1.2 !important;
    margin-bottom: 1rem !important;
}

.spm-popup-content .spm-text-column h2,
.spm-popup-content h2 {
    font-size: clamp(1.3rem, 3vw, 2rem) !important;
    line-height: 1.3 !important;
    margin-bottom: 1rem !important;
}

.spm-popup-content .spm-text-column h3,
.spm-popup-content h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem) !important;
    line-height: 1.3 !important;
    margin-bottom: 0.875rem !important;
}

.spm-popup-content .spm-text-column p,
.spm-popup-content p {
    font-size: clamp(0.875rem, 1.5vw, 1rem) !important;
    line-height: 1.6 !important;
}

/* Two independent columns */
.spm-popup-content.layout-two-columns .spm-column {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.spm-popup-content.layout-two-columns .spm-column-1 {
    border-right: 1px solid #eee;
}

/* Single column layouts */
.spm-popup-content.layout-single-column {
    padding: 30px;
}

.spm-popup-content.layout-single-column img {
    margin-bottom: 20px;
    border-radius: 5px;
}

/* Background image layout */
.spm-popup-content.layout-image-bg {
    min-height: 400px;
    padding: 40px;
    position: relative;
    background-size: cover;
    background-position: center;
}

.spm-popup-content.layout-image-bg::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.spm-popup-content.layout-image-bg > * {
    position: relative;
    z-index: 0;
}

.spm-popup-content.layout-image-bg,
.spm-popup-content.layout-image-bg h2,
.spm-popup-content.layout-image-bg .spm-content,
.spm-popup-content.layout-image-bg .spm-button {
    color: #ffffff;
}

/* Responsive */
@media (max-width: 768px) {
    .spm-popup {
        width: 90%;
        max-width: none;
        max-height: 75vh;
        margin: auto;
		margin-top:10vh;
        display: flex;
        flex-direction: column;
    }
    
    .spm-popup-content {
        padding: 20px;
        max-height: 85vh;
        overflow-y: auto;
        overflow-x: hidden;
        height: 100%;
    }
    
    /* Stack layout on mobile - HELT OMSKRIVEN */
    .spm-popup-content[data-mobile-layout="stack"].layout-two-columns,
    .spm-popup-content[data-mobile-layout="stack"].layout-image-left,
    .spm-popup-content[data-mobile-layout="stack"].layout-image-right {
        display: block !important; /* Byt från flex till block */
        padding: 0;
        height: auto;
        max-height: none;
    }
    
    /* Image column on mobile */
    .spm-popup-content[data-mobile-layout="stack"] .spm-image-column {
        display: block;
        width: 100%;
        height: auto;
        position: relative;
        margin-bottom: 0;
    }
    
    /* Different handling for contain mode on mobile */
    .spm-popup-content[data-mobile-layout="stack"][data-image-fit="contain"] .spm-image-column {
        min-height: 200px;
        max-height: 35vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
		margin-top:20px;
    }
    
    .spm-popup-content[data-mobile-layout="stack"][data-image-fit="contain"] .spm-image-column img {
        object-fit: contain;
        width: 100%;
        height: 100%;
        max-height: 100%;
    }
    
    /* Cover mode on mobile */
    .spm-popup-content[data-mobile-layout="stack"][data-image-fit="cover"] .spm-image-column {
        height: 200px;
        padding: 0;
    }
    
    .spm-popup-content[data-mobile-layout="stack"][data-image-fit="cover"] .spm-image-column img {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    
    /* Text column on mobile - VIKTIGT */
    .spm-popup-content[data-mobile-layout="stack"] .spm-text-column {
        display: block;
        padding: 20px;
        position: relative;
        width: 100%;
        min-height: auto;
    }
    
    /* Mobile text sizing - smaller with !important */
    .spm-popup-content h1 {
        font-size: clamp(1.25rem, 5vw, 1.5rem) !important;
        margin-top: 0 !important;
    }
    
    .spm-popup-content h2 {
        font-size: clamp(1.125rem, 4.5vw, 1.375rem) !important;
        margin-top: 0 !important;
    }
    
    .spm-popup-content h3 {
        font-size: clamp(1rem, 4vw, 1.25rem) !important;
        margin-top: 0 !important;
    }
    
    .spm-popup-content p {
        font-size: clamp(0.875rem, 3.5vw, 1rem) !important;
    }
    
    /* Mobile order */
    .spm-popup-content[data-mobile-layout="stack"][data-mobile-order="text-first"] {
        display: flex !important;
        flex-direction: column;
    }
    
    .spm-popup-content[data-mobile-layout="stack"][data-mobile-order="text-first"] .spm-image-column {
        order: 2;
    }
    
    .spm-popup-content[data-mobile-layout="stack"][data-mobile-order="text-first"] .spm-text-column {
        order: 1;
    }
    
    /* Hide image on mobile */
    .spm-popup-content[data-mobile-layout="hide-image"] .spm-image-column {
        display: none !important;
    }
    
    .spm-close {
        top: 10px;
        right: 10px;
        font-size: 20px;
        width: 30px;
        height: 30px;
    }
    
    .spm-button-fixed-wrapper {
        padding: 15px 20px;
    }
}
