/**
 * Frontend Styles for Popup Manager
 */

/* Overlay */
.pm-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.pm-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Container */
.pm-popup-container {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.pm-popup-overlay.active .pm-popup-container {
    transform: scale(1);
}

/* Close Button */
.pm-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: none;
    border-radius: 10%;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s ease, transform 0.2s ease;
}

.pm-popup-close:hover {
    background: rgba(0, 0, 0, 1);
}

.pm-popup-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.pm-popup-close svg {
    width: 20px;
    height: 20px;
}

/* Content */
.pm-popup-content {
    padding: 40px 30px;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #1a1a1a;
    background: #fff;
}

/* Reset common elements inside popup */
.pm-popup-content h1,
.pm-popup-content h2,
.pm-popup-content h3,
.pm-popup-content h4,
.pm-popup-content h5,
.pm-popup-content h6 {
    margin: 0 0 15px 0;
    padding: 0;
    font-weight: 600;
    line-height: 1.3;
    color: #1a1a1a;
}

.pm-popup-content h1 { font-size: 32px; }
.pm-popup-content h2 { font-size: 28px; }
.pm-popup-content h3 { font-size: 24px; }
.pm-popup-content h4 { font-size: 20px; }
.pm-popup-content h5 { font-size: 18px; }
.pm-popup-content h6 { font-size: 16px; }

.pm-popup-content p {
    margin: 0 0 15px 0;
    padding: 0;
    line-height: 1.6;
    color: #4a5568;
}

.pm-popup-content ul,
.pm-popup-content ol {
    margin: 0 0 15px 20px;
    padding: 0;
}

.pm-popup-content li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.pm-popup-content a {
    color: #2271b1;
    text-decoration: underline;
}

.pm-popup-content a:hover {
    color: #135e96;
}

.pm-popup-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.pm-popup-content > *:first-child {
    margin-top: 0;
}

.pm-popup-content > *:last-child {
    margin-bottom: 0;
}

/* Instagram Embeds in Popup - Fully Responsive */
.pm-popup-content .ig-embed-multi {
    margin: 20px 0;
    display: grid;
    gap: 20px;
    width: 100%;
}

/* Desktop: Multiple columns based on data-cols attribute */
@media screen and (min-width: 768px) {
    .pm-popup-content .ig-embed-multi[data-cols="2"] {
        grid-template-columns: repeat(2, 1fr);
    }
    .pm-popup-content .ig-embed-multi[data-cols="3"] {
        grid-template-columns: repeat(3, 1fr);
    }
    .pm-popup-content .ig-embed-multi[data-cols="4"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet & Mobile: Always single column */
@media screen and (max-width: 767px) {
    .pm-popup-content .ig-embed-multi {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* Instagram embed items */
.pm-popup-content .ig-embed-item {
    position: relative;
    width: 100%;
    max-width: 100%;
}

/* Instagram media - Base responsive settings */
.pm-popup-content .instagram-media {
    margin: 10px auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
}

/* Desktop Large: Full height for best view */
@media screen and (min-width: 1200px) {
    .pm-popup-content .instagram-media {
        min-height: 550px;
        height: 650px;
        max-height: 800px;
    }
    
    .pm-popup-content .ig-embed-item {
        min-height: 550px;
    }
}

/* Desktop: Standard height */
@media screen and (min-width: 1024px) and (max-width: 1199px) {
    .pm-popup-content .instagram-media {
        min-height: 500px;
        height: 650px;
        max-height: 700px;
    }
    
    .pm-popup-content .ig-embed-item {
        min-height: 500px;
    }
}

/* Tablet: Medium height */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .pm-popup-content .instagram-media {
        min-height: 450px;
        height: 580px;
        max-height: 620px;
    }
    
    .pm-popup-content .ig-embed-item {
        min-height: 450px;
    }
}

/* Mobile Large: Comfortable height */
@media screen and (min-width: 481px) and (max-width: 767px) {
    .pm-popup-content .instagram-media {
        min-height: 400px;
        height: 650px;
        max-height: 700px;
    }
    
    .pm-popup-content .ig-embed-item {
        min-height: 400px;
    }
}

/* Mobile Small: Compact but readable */
@media screen and (max-width: 480px) {
    .pm-popup-content .instagram-media {
        min-height: 350px;
        height: 650px;
        max-height: 700px;
    }
    
    .pm-popup-content .ig-embed-item {
        min-height: 350px;
    }
}

/* Instagram iframe - Force full width */
.pm-popup-content .instagram-media iframe {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Loading state for Instagram embeds */
.pm-popup-content .instagram-media:not(.instagram-media-rendered) {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.pm-popup-content .instagram-media:not(.instagram-media-rendered)::before {
    content: 'Loading Instagram...';
    color: #999;
    font-size: 14px;
}

/* Animation: Fade In */
.pm-popup-overlay[data-animation="fadeIn"] {
    animation: pmFadeIn 0.3s ease;
}

@keyframes pmFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Animation: Slide Down */
.pm-popup-overlay[data-animation="slideDown"].active .pm-popup-container {
    animation: pmSlideDown 0.4s ease;
}

@keyframes pmSlideDown {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Animation: Slide Up */
.pm-popup-overlay[data-animation="slideUp"].active .pm-popup-container {
    animation: pmSlideUp 0.4s ease;
}

@keyframes pmSlideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Animation: Zoom In */
.pm-popup-overlay[data-animation="zoomIn"].active .pm-popup-container {
    animation: pmZoomIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pmZoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animation: None */
.pm-popup-overlay[data-animation="none"] {
    transition: none;
}

.pm-popup-overlay[data-animation="none"] .pm-popup-container {
    transition: none;
    transform: scale(1);
}

/* Scrollbar Styling */
.pm-popup-container::-webkit-scrollbar {
    width: 8px;
}

.pm-popup-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

.pm-popup-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.pm-popup-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Body lock when popup is active */
body.pm-popup-active {
    overflow: hidden;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .pm-popup-overlay {
        padding: 10px;
    }
    
    .pm-popup-container {
        max-height: 95vh;
        border-radius: 6px;
    }
    
    .pm-popup-content {
        padding: 30px 20px;
    }
    
    .pm-popup-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
    }
    
    .pm-popup-close svg {
        width: 18px;
        height: 18px;
    }
}

@media screen and (max-width: 480px) {
    .pm-popup-content {
        padding: 25px 15px;
    }
    
    /* Make Instagram embeds more mobile friendly */
    .pm-popup-content .ig-embed-multi {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* Print styles - hide popups when printing */
@media print {
    .pm-popup-overlay {
        display: none !important;
    }
}

/* Accessibility */
.pm-popup-overlay:focus-within {
    outline: none;
}

.pm-popup-container:focus {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .pm-popup-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .pm-popup-close {
        background: #000;
        border: 2px solid #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .pm-popup-overlay,
    .pm-popup-container,
    .pm-popup-close {
        transition: none !important;
        animation: none !important;
    }
}

/* Loading State */
.pm-popup-loading {
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
}

.pm-popup-loading p {
    margin-top: 20px;
    color: #646970;
    font-size: 14px;
}

.pm-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: pm-spin 1s linear infinite;
}

@keyframes pm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pm-popup-content.loading {
    pointer-events: none;
    opacity: 0.6;
}