/**
 * MPR Instagram Integration - Styles
 *
 * @author    mypresta.rocks <info@mypresta.rocks>
 * @copyright Copyright (c) mypresta.rocks
 * @license   Commercial license
 */

/* --- Section Container ---------------------------------------------------- */

.mprinstagram-section {
    padding: 32px 0;
    margin: 24px 0;
}

/* --- Header (title left, profile right) ---------------------------------- */

.mprinstagram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e1e8ed;
}

.mprinstagram-header__left {
    min-width: 0;
}

.mprinstagram-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #262626;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.mprinstagram-icon {
    flex-shrink: 0;
    color: #E4405F;
}

/* --- Profile Link (header pill) ------------------------------------------ */

.mprinstagram-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.82rem;
    border-radius: 9999px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(225, 48, 108, 0.25);
}

.mprinstagram-profile-link:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(225, 48, 108, 0.35);
}

/* --- Grid Layout --------------------------------------------------------- */

.mprinstagram-grid {
    display: grid;
    grid-template-columns: repeat(var(--mprinstagram-columns, 4), 1fr);
    gap: var(--mprinstagram-gap, 10px);
}

/* Adaptive: if only 1-2 posts, don't stretch across full grid */
[data-count="1"] .mprinstagram-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
}

[data-count="2"] .mprinstagram-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 640px;
}

/* --- Post Item ----------------------------------------------------------- */

.mprinstagram-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--mprinstagram-radius, 8px);
    background: #fafafa;
    border: 1px solid #e1e8ed;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.mprinstagram-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.mprinstagram-image-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    overflow: hidden;
    background: #efefef;
}

.mprinstagram-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

/* Lazy load placeholder */
.mprinstagram-lazy {
    opacity: 0;
    background: linear-gradient(135deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
    background-size: 400% 100%;
    animation: mprinstagram-shimmer 1.5s ease infinite;
}

.mprinstagram-lazy.mprinstagram-loaded {
    opacity: 1;
    animation: none;
    background: none;
}

@keyframes mprinstagram-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Media Type Badges --------------------------------------------------- */

.mprinstagram-video-badge,
.mprinstagram-carousel-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

/* --- Overlay (hover effect: overlay) ------------------------------------- */

.mprinstagram-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.mprinstagram-overlay-content {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

.mprinstagram-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Hover effects */
[data-hover="overlay"] .mprinstagram-item:hover .mprinstagram-overlay {
    opacity: 1;
}

[data-hover="zoom"] .mprinstagram-item:hover .mprinstagram-image {
    transform: scale(1.1);
}

[data-hover="fade"] .mprinstagram-item:hover .mprinstagram-image {
    opacity: 0.75;
}

[data-hover="overlay"] .mprinstagram-item:hover .mprinstagram-image {
    transform: scale(1.05);
}

[data-hover="none"] .mprinstagram-overlay {
    display: none;
}

/* Item hover elevation */
.mprinstagram-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-color: #dbdbdb;
}

/* --- Post Metadata ------------------------------------------------------- */

.mprinstagram-meta {
    padding: 10px 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: #262626;
    border-top: 1px solid #eff3f4;
}

.mprinstagram-author {
    display: block;
    font-weight: 700;
    color: #262626;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.mprinstagram-caption {
    margin: 0 0 6px 0;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mprinstagram-date {
    display: block;
    color: #8e8e8e;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* --- Slider Layout ------------------------------------------------------- */

.mprinstagram-slider-wrapper {
    position: relative;
    padding: 0 50px;
}

.mprinstagram-slider {
    overflow: hidden;
    width: 100%;
}

.mprinstagram-slider-track {
    display: flex;
    gap: var(--mprinstagram-gap, 10px);
    transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
}

.mprinstagram-slide {
    flex: 0 0 calc((100% - var(--mprinstagram-gap, 10px) * (var(--mprinstagram-columns, 4) - 1)) / var(--mprinstagram-columns, 4));
    min-width: 0;
}

.mprinstagram-slide .mprinstagram-item {
    height: 100%;
}

.mprinstagram-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e1e8ed;
    background: #fff;
    color: #262626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 0;
}

.mprinstagram-slider-btn:hover {
    background: #fafafa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #cfd9de;
}

.mprinstagram-slider-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.mprinstagram-slider-prev {
    left: 4px;
}

.mprinstagram-slider-next {
    right: 4px;
}

/* --- Follow Button (bottom CTA) ----------------------------------------- */

.mprinstagram-follow {
    text-align: center;
    margin-top: 24px;
}

.mprinstagram-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 24px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(225, 48, 108, 0.3);
}

.mprinstagram-follow-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(225, 48, 108, 0.4);
}

/* ========================================================================= */
/* Gallery Mode — PhotoSwipe Integration                                     */
/* ========================================================================= */

/* Lightbox icon (bottom-right corner) */
.mprinstagram-lightbox-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mprinstagram-gallery-item:hover .mprinstagram-lightbox-icon {
    opacity: 1;
}

/* Gallery item cursor */
.mprinstagram-gallery-item .mprinstagram-link {
    cursor: zoom-in;
}

/* --- PhotoSwipe Caption Overlay ------------------------------------------ */

.mprinstagram-pswp-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0;
    pointer-events: auto;
    z-index: 10;
}

.mprinstagram-pswp-caption__inner {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    padding: 40px 24px 20px;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.5;
}

.mprinstagram-pswp-author {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.mprinstagram-pswp-text {
    margin: 0 0 8px;
    opacity: 0.9;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mprinstagram-pswp-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    opacity: 0.85;
}

.mprinstagram-pswp-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mprinstagram-pswp-link {
    display: inline-block;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    transition: background 0.2s ease;
    margin-top: 4px;
}

.mprinstagram-pswp-link:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    text-decoration: none;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 991px) {
    .mprinstagram-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .mprinstagram-slide {
        flex: 0 0 calc((100% - var(--mprinstagram-gap, 10px) * 2) / 3);
    }
}

@media (max-width: 767px) {
    .mprinstagram-grid {
        grid-template-columns: repeat(var(--mprinstagram-mobile-columns, 2), 1fr);
    }

    .mprinstagram-section {
        padding: 20px 0;
    }

    .mprinstagram-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .mprinstagram-title {
        font-size: 1.1rem;
    }

    .mprinstagram-slider-wrapper {
        padding: 0 35px;
    }

    .mprinstagram-slider-btn {
        width: 30px;
        height: 30px;
    }

    .mprinstagram-slide {
        flex: 0 0 calc((100% - var(--mprinstagram-gap, 10px)) / 2);
    }

    .mprinstagram-meta {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .mprinstagram-caption {
        -webkit-line-clamp: 1;
    }

    .mprinstagram-follow-btn {
        padding: 8px 22px;
        font-size: 0.85rem;
    }

    .mprinstagram-profile-link {
        padding: 6px 16px;
        font-size: 0.8rem;
    }

    .mprinstagram-pswp-caption__inner {
        padding: 30px 16px 16px;
        font-size: 0.82rem;
    }
}

@media (max-width: 479px) {
    .mprinstagram-slider-wrapper {
        padding: 0 5px;
    }

    .mprinstagram-slider-btn {
        display: none;
    }

    .mprinstagram-slider {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .mprinstagram-slider::-webkit-scrollbar {
        display: none;
    }

    .mprinstagram-slide {
        scroll-snap-align: start;
        flex: 0 0 calc(100% / var(--mprinstagram-mobile-columns, 2) - var(--mprinstagram-gap, 10px));
    }
}
