/**
 * Popply Pro - Frontend Styles
 * Mobile-first, accessible popup styling
 */

/* Overlay - Fixed fullscreen */
.popply-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0;
    padding: 15px;
    box-sizing: border-box !important;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    /* Break out of any containing blocks created by transforms */
    transform: none !important;
    -webkit-transform: none !important;
    filter: none !important;
    -webkit-filter: none !important;
    perspective: none !important;
    contain: none !important;
    will-change: auto !important;
}

.popply-overlay.popply-visible {
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* Modal Container */
.popply-modal {
    position: relative !important;
    width: 100%;
    max-height: calc(100vh - 30px);
    max-height: calc(100dvh - 30px);
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: popplyFadeIn 0.3s ease-out;
    -webkit-overflow-scrolling: touch;
    margin: auto;
}

@keyframes popplyFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Close button */
.popply-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    left: auto !important;
    bottom: auto !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background-color: rgba(0, 0, 0, 0.1) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    z-index: 10 !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color 0.2s ease;
}

.popply-close:hover {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

.popply-close:focus {
    outline: none;
}

.popply-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.popply-close-icon {
    font-size: 24px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    color: #333 !important;
    display: block !important;
}

/* Content area */
.popply-content {
    padding-top: 20px;
    padding-right: 50px;
}

.popply-body {
    margin-bottom: 20px;
    line-height: 1.6;
}

.popply-body:last-child {
    margin-bottom: 0;
}

.popply-body p:first-child {
    margin-top: 0;
}

.popply-body p:last-child {
    margin-bottom: 0;
}

/* Button */
.popply-button-wrap {
    margin-top: 20px;
    text-align: center;
}

.popply-button {
    display: inline-block;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.popply-button:hover {
    opacity: 0.9;
    text-decoration: none;
}

.popply-button:active {
    transform: scale(0.98);
}

/* Mobile-specific enhancements */
@media (max-width: 600px) {
    .popply-overlay {
        padding: 10px;
        padding-top: 40px;
    }
    
    .popply-overlay.popply-visible {
        -webkit-box-align: start;
        -ms-flex-align: start;
        align-items: flex-start;
    }
    
    .popply-modal {
        max-height: calc(100vh - 60px);
        max-height: calc(100dvh - 60px);
    }
    
    .popply-close {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    .popply-close-icon {
        font-size: 26px !important;
    }
    
    .popply-button {
        display: block;
        width: 100%;
        padding: 16px 28px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .popply-overlay {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    @media (max-width: 600px) {
        .popply-overlay {
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
        }
    }
}

/* Prevent body scroll when popup is open */
body.popply-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* High contrast / accessibility */
@media (prefers-reduced-motion: reduce) {
    .popply-modal {
        animation: none;
    }
    
    .popply-close-icon,
    .popply-button {
        transition: none;
    }
}

/* Focus trap visual indicator */
.popply-modal:focus {
    outline: none;
}

/* Screen reader only text */
.popply-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
