/* Popup Overlay */
.spm-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.85) 100%);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    animation: spmFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spmFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }
}

/* Popup Container */
.spm-popup-container {
    position: relative;
    background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 4px 8px rgba(0, 0, 0, 0.1);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: spmSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin: auto;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

@keyframes spmSlideUp {
    from {
        transform: translateY(60px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Popup Header with Decorative Element */
.spm-popup-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #4CAF50 0%, #45a049 50%, #4CAF50 100%);
    background-size: 200% 100%;
    animation: spmGradientShift 3s ease infinite;
    border-radius: 20px 20px 0 0;
    z-index: 1;
}

@keyframes spmGradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Close Button */
.spm-popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 4px 12px rgba(255, 68, 68, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: 300;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.spm-popup-close:hover {
    background: linear-gradient(135deg, #ff5555 0%, #dd0000 100%);
    transform: rotate(90deg) scale(1.15);
    box-shadow: 
        0 6px 16px rgba(255, 68, 68, 0.5),
        0 3px 6px rgba(0, 0, 0, 0.3);
}

.spm-popup-close:active {
    transform: rotate(90deg) scale(0.95);
    box-shadow: 
        0 2px 8px rgba(255, 68, 68, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Scrollable Content Wrapper */
.spm-popup-scrollable {
    max-height: calc(90vh - 12px);
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 0 0 20px 20px;
}

/* Popup Content */
.spm-popup-content {
    padding: 50px 45px 45px 45px;
    color: #2c3e50;
    line-height: 1.7;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    position: relative;
}

.spm-popup-content h1,
.spm-popup-content h2,
.spm-popup-content h3,
.spm-popup-content h4 {
    margin-top: 0;
    line-height: 1.4;
    font-weight: 700;
    color: #1a252f;
}

.spm-popup-content h1 {
    font-size: 32px;
    margin-bottom: 20px;
}

.spm-popup-content h2 {
    font-size: 26px;
    margin-bottom: 18px;
}

.spm-popup-content h3 {
    font-size: 22px;
    margin-bottom: 15px;
}

.spm-popup-content h4 {
    font-size: 18px;
    margin-bottom: 12px;
}

.spm-popup-content p {
    margin: 15px 0;
    font-size: 16px;
    color: #34495e;
}

.spm-popup-content a {
    word-wrap: break-word;
    transition: all 0.3s ease;
}

/* Enhanced Button Styling */
.spm-popup-content a[href] {
    display: inline-block;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white !important;
    padding: 16px 36px;
    text-decoration: none;
    border-radius: 50px;
    font-size: 17px;
    font-weight: 600;
    margin-top: 25px;
    box-shadow: 
        0 8px 20px rgba(76, 175, 80, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.spm-popup-content a[href]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.spm-popup-content a[href]:hover::before {
    width: 300px;
    height: 300px;
}

.spm-popup-content a[href]:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-3px);
    box-shadow: 
        0 12px 28px rgba(76, 175, 80, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.spm-popup-content a[href]:active {
    transform: translateY(-1px);
    box-shadow: 
        0 6px 16px rgba(76, 175, 80, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Custom Styling for Lists */
.spm-popup-content ul,
.spm-popup-content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.spm-popup-content li {
    margin: 8px 0;
    line-height: 1.6;
}

/* Emphasis and Strong */
.spm-popup-content strong,
.spm-popup-content b {
    font-weight: 700;
    color: #1a252f;
}

.spm-popup-content em,
.spm-popup-content i {
    font-style: italic;
    color: #2c5f2d;
}

/* Large Desktop (1920px+) */
@media screen and (min-width: 1920px) {
    .spm-popup-container {
        max-width: 800px;
    }
    
    .spm-popup-content {
        padding: 60px 55px 55px 55px;
        font-size: 17px;
    }
    
    .spm-popup-content h2 {
        font-size: 30px;
    }
    
    .spm-popup-content h3 {
        font-size: 24px;
    }
}

/* Standard Desktop (1440px - 1919px) */
@media screen and (min-width: 1440px) and (max-width: 1919px) {
    .spm-popup-container {
        max-width: 750px;
    }
}

/* Laptop (1024px - 1439px) */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    .spm-popup-container {
        max-width: 680px;
    }
    
    .spm-popup-content {
        padding: 45px 40px 40px 40px;
    }
}

/* Tablet Landscape (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .spm-popup-overlay {
        padding: 15px;
    }
    
    .spm-popup-container {
        max-width: 90%;
        border-radius: 16px;
    }
    
    .spm-popup-container::before {
        height: 5px;
        border-radius: 16px 16px 0 0;
    }
    
    .spm-popup-content {
        padding: 45px 35px 35px 35px;
        font-size: 15px;
    }
    
    .spm-popup-content h2 {
        font-size: 24px;
    }
    
    .spm-popup-content h3 {
        font-size: 20px;
    }
    
    .spm-popup-content a[href] {
        padding: 14px 32px;
        font-size: 16px;
    }
    
    .spm-popup-close {
        top: 18px;
        right: 18px;
        width: 38px;
        height: 38px;
        font-size: 24px;
    }
}

/* Tablet Portrait (600px - 767px) */
@media screen and (min-width: 600px) and (max-width: 767px) {
    .spm-popup-overlay {
        padding: 12px;
    }
    
    .spm-popup-container {
        max-width: 95%;
        border-radius: 14px;
    }
    
    .spm-popup-container::before {
        height: 5px;
        border-radius: 14px 14px 0 0;
    }
    
    .spm-popup-content {
        padding: 40px 30px 30px 30px;
        font-size: 15px;
    }
    
    .spm-popup-content h2 {
        font-size: 22px;
        margin-bottom: 15px;
    }
    
    .spm-popup-content h3 {
        font-size: 19px;
        margin-bottom: 12px;
    }
    
    .spm-popup-content p {
        font-size: 15px;
        margin: 12px 0;
    }
    
    .spm-popup-content a[href] {
        padding: 13px 28px;
        font-size: 15px;
        margin-top: 20px;
    }
    
    .spm-popup-close {
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
}

/* Mobile Landscape (480px - 767px in landscape) */
@media screen and (min-width: 480px) and (max-width: 767px) and (orientation: landscape) {
    .spm-popup-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .spm-popup-container {
        margin-top: 0;
    }
    
    .spm-popup-scrollable {
        max-height: 88vh;
    }
    
    .spm-popup-content {
        padding: 35px 25px 25px 25px;
    }
}

/* Mobile Portrait (375px - 599px) */
@media screen and (min-width: 375px) and (max-width: 599px) {
    .spm-popup-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .spm-popup-container {
        max-width: 100%;
        max-height: 88vh;
        border-radius: 12px;
        margin-top: 0;
    }
    
    .spm-popup-container::before {
        height: 4px;
        border-radius: 12px 12px 0 0;
    }
    
    .spm-popup-scrollable {
        max-height: calc(88vh - 8px);
    }
    
    .spm-popup-content {
        padding: 35px 25px 25px 25px;
        font-size: 14px;
    }
    
    .spm-popup-content h2 {
        font-size: 20px;
        margin-bottom: 14px;
        line-height: 1.3;
    }
    
    .spm-popup-content h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .spm-popup-content p {
        font-size: 14px;
        margin: 12px 0;
        line-height: 1.6;
    }
    
    .spm-popup-content a[href] {
        padding: 14px 26px;
        font-size: 15px;
        margin-top: 20px;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    
    .spm-popup-close {
        top: 14px;
        right: 14px;
        width: 34px;
        height: 34px;
        font-size: 20px;
    }
}

/* Small Mobile (320px - 374px) */
@media screen and (max-width: 374px) {
    .spm-popup-overlay {
        padding: 8px;
        padding-top: 15px;
    }
    
    .spm-popup-container {
        border-radius: 10px;
        max-height: 90vh;
    }
    
    .spm-popup-container::before {
        height: 4px;
        border-radius: 10px 10px 0 0;
    }
    
    .spm-popup-scrollable {
        max-height: calc(90vh - 8px);
    }
    
    .spm-popup-content {
        padding: 32px 20px 20px 20px;
        font-size: 13px;
    }
    
    .spm-popup-content h2 {
        font-size: 18px;
        line-height: 1.3;
        margin-bottom: 12px;
    }
    
    .spm-popup-content h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .spm-popup-content p {
        font-size: 13px;
        line-height: 1.5;
        margin: 10px 0;
    }
    
    .spm-popup-content a[href] {
        padding: 12px 22px;
        font-size: 14px;
        margin-top: 18px;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    
    .spm-popup-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}

/* Ultra-wide screens (2560px+) */
@media screen and (min-width: 2560px) {
    .spm-popup-container {
        max-width: 900px;
    }
    
    .spm-popup-content {
        padding: 70px 65px 65px 65px;
        font-size: 18px;
    }
    
    .spm-popup-content h2 {
        font-size: 34px;
    }
    
    .spm-popup-content h3 {
        font-size: 26px;
    }
    
    .spm-popup-content a[href] {
        padding: 18px 40px;
        font-size: 18px;
    }
    
    .spm-popup-close {
        width: 46px;
        height: 46px;
        font-size: 28px;
    }
}

/* Landscape Orientation (General) */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .spm-popup-overlay {
        align-items: flex-start;
        padding-top: 8px;
    }
    
    .spm-popup-container {
        max-height: 96vh;
        margin-top: 0;
    }
    
    .spm-popup-scrollable {
        max-height: calc(96vh - 6px);
    }
    
    .spm-popup-content {
        padding: 30px 25px 25px 25px;
    }
    
    .spm-popup-close {
        top: 10px;
        right: 10px;
    }
}

/* Very Short Landscape (like foldable phones) */
@media screen and (max-height: 400px) and (orientation: landscape) {
    .spm-popup-content {
        padding: 25px 20px 20px 20px;
        font-size: 13px;
    }
    
    .spm-popup-content h2 {
        font-size: 18px;
    }
    
    .spm-popup-content h3 {
        font-size: 16px;
    }
    
    .spm-popup-content p {
        font-size: 13px;
        margin: 8px 0;
    }
}

/* Custom Scrollbar for Popup Content */
.spm-popup-scrollable::-webkit-scrollbar {
    width: 10px;
}

.spm-popup-scrollable::-webkit-scrollbar-track {
    background: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
    border-radius: 0 0 20px 0;
}

.spm-popup-scrollable::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: all 0.3s ease;
}

.spm-popup-scrollable::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.spm-popup-scrollable::-webkit-scrollbar-thumb:active {
    background: linear-gradient(135deg, #3d8b40 0%, #357a38 100%);
}

/* Firefox Scrollbar */
.spm-popup-scrollable {
    scrollbar-width: thin;
    scrollbar-color: #4CAF50 #f5f5f5;
}

/* Prevent body scroll when popup is open */
body.spm-popup-open {
    overflow: hidden;
    padding-right: 0px; /* Prevent layout shift */
}

/* iOS momentum scrolling */
.spm-popup-scrollable {
    -webkit-overflow-scrolling: touch;
}

/* Accessibility - Focus styles */
.spm-popup-close:focus {
    outline: 4px solid rgba(76, 175, 80, 0.5);
    outline-offset: 3px;
    box-shadow: 
        0 6px 16px rgba(255, 68, 68, 0.5),
        0 0 0 4px rgba(76, 175, 80, 0.3);
}

.spm-popup-close:focus:not(:focus-visible) {
    outline: none;
}

.spm-popup-close:focus-visible {
    outline: 4px solid rgba(76, 175, 80, 0.5);
    outline-offset: 3px;
}

/* Link focus states */
.spm-popup-content a:focus {
    outline: 3px solid rgba(76, 175, 80, 0.5);
    outline-offset: 4px;
}

.spm-popup-content a:focus:not(:focus-visible) {
    outline: none;
}

/* Print styles - hide popup when printing */
@media print {
    .spm-popup-overlay {
        display: none !important;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .spm-popup-overlay,
    .spm-popup-container,
    .spm-popup-close,
    .spm-popup-content a[href],
    .spm-popup-container::before {
        animation: none !important;
        transition: none !important;
    }
    
    .spm-popup-overlay {
        opacity: 1;
    }
    
    .spm-popup-container {
        transform: none;
        opacity: 1;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .spm-popup-container {
        border: 3px solid currentColor;
    }
    
    .spm-popup-close {
        border: 3px solid white;
    }
    
    .spm-popup-content a[href] {
        border: 2px solid white;
    }
}

/* Dark mode support (optional - can be enabled) */
@media (prefers-color-scheme: dark) {
    /* Keep light theme for consistency, but can be customized */
    .spm-popup-container {
        background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .spm-popup-close {
        width: 44px;
        height: 44px;
        font-size: 26px;
    }
    
    .spm-popup-content a[href] {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
