/* Instagram Feed Catcher Frontend Gallery */

.ig-feed-container {
    display: grid;
    gap: 16px;
    width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
}

/* Responsive Column Layouts */
.ig-cols-1 { grid-template-columns: 1fr; }
.ig-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ig-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ig-cols-4 { grid-template-columns: repeat(4, 1fr); }
.ig-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Tablet (iPad / Tablets): 3 cards per row for 3-column feeds */
@media (max-width: 1024px) {
    .ig-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .ig-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .ig-cols-4, .ig-cols-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .ig-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .ig-cols-2, .ig-cols-4, .ig-cols-6 { grid-template-columns: repeat(2, 1fr); }
    .ig-cols-1 { grid-template-columns: 1fr; }

    /* Explicit tablet column overrides */
    .ig-cols-tablet-1 { grid-template-columns: 1fr !important; }
    .ig-cols-tablet-2 { grid-template-columns: repeat(2, 1fr) !important; }
    .ig-cols-tablet-3 { grid-template-columns: repeat(3, 1fr) !important; }
    .ig-cols-tablet-4 { grid-template-columns: repeat(4, 1fr) !important; }
}

/* Mobile Phones: 2 cards per row */
@media (max-width: 600px) {
    .ig-feed-container {
        gap: 10px;
    }

    .ig-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .ig-cols-2, .ig-cols-4, .ig-cols-6 { grid-template-columns: repeat(2, 1fr); }
    .ig-cols-1 { grid-template-columns: 1fr; }

    /* Explicit mobile column overrides */
    .ig-cols-mobile-1 { grid-template-columns: 1fr !important; }
    .ig-cols-mobile-2 { grid-template-columns: repeat(2, 1fr) !important; }
    .ig-cols-mobile-3 { grid-template-columns: repeat(3, 1fr) !important; }

    /* Mobile adjustments for 2 cards per row */
    .ig-card-bottom-bar {
        padding: 30px 10px 10px 10px;
    }

    .ig-avatar-ring {
        width: 30px;
        height: 30px;
        padding: 1.5px;
    }

    .ig-username-text {
        font-size: 13px;
    }

    .ig-card-caption-line {
        font-size: 11.5px;
    }

    .ig-top-icon {
        width: 26px;
        height: 26px;
    }

    .ig-top-icon svg {
        width: 14px;
        height: 14px;
    }

    .ig-stat-pill {
        padding: 2px 7px;
        font-size: 11px;
    }
}

@media (max-width: 400px) {
    .ig-feed-container {
        gap: 8px;
    }
}

/* Individual Item & Aspect Ratio */
.ig-feed-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
}

.ig-feed-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.ig-item-link {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    width: 100%;
    height: 100%;
}

.ig-media-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: #121212;
}

.ig-media-wrapper img,
.ig-media-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ig-feed-item:hover .ig-media-wrapper img {
    transform: scale(1.03);
}

.ig-media-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e1e1e;
    color: #fff;
}

/* Top-Right Floating Icons (Play / Video / Carousel) */
.ig-card-top-icons {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.ig-top-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease;
}

.ig-top-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* Lower-Third Bottom Bar (Always visible with dark gradient) */
.ig-card-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 44px 18px 16px 18px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.48) 55%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    z-index: 4;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ig-feed-item:hover .ig-card-bottom-bar,
.ig-feed-item.ig-touch-active .ig-card-bottom-bar {
    opacity: 0;
    transform: translateY(6px);
}

.ig-user-badge-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Instagram Gradient Ring around Avatar */
.ig-avatar-ring {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.ig-user-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50% !important;
    object-fit: cover;
    display: block;
    background: #000;
}

.ig-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #333;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.ig-user-info-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ig-username-line {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    margin-bottom: 4px;
}

.ig-username-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.ig-verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ig-avatar-hashtag {
    background: linear-gradient(135deg, #1877f2, #e1306c) !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: 800 !important;
}

.ig-hashtag-pill-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(24, 119, 242, 0.85);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 10px;
    line-height: 1.2;
    flex-shrink: 0;
}

.ig-card-caption-line {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Hover Overlay (Full details & metrics) */
.ig-card-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.6) 45%, rgba(0, 0, 0, 0.15) 85%);
    z-index: 6;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    box-sizing: border-box;
    color: #fff;
    pointer-events: none;
}

.ig-feed-item:hover .ig-card-hover-overlay,
.ig-feed-item.ig-touch-active .ig-card-hover-overlay {
    opacity: 1;
    visibility: visible;
}

.ig-hover-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ig-hover-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 700;
}

.ig-stat-pill {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ig-hover-full-caption {
    font-size: 13px;
    line-height: 1.45;
    color: #f5f5f5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ig-hover-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.ig-hover-date {
    color: rgba(255, 255, 255, 0.7);
}

.ig-hover-link-btn {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ig-feed-empty {
    padding: 30px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
    color: #777;
}

/* Lightbox Modal & Carousel Slider */
.ig-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.ig-modal-container {
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    max-width: 960px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.ig-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: none;
    font-size: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ig-modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.08);
}

.ig-modal-body {
    display: flex;
    height: 100%;
    min-height: 520px;
    max-height: 88vh;
    width: 100%;
}

/* 7. Left Side Section: Responsive for all Images, Videos, Reels, & Carousels */
.ig-modal-media-wrap {
    flex: 1.35;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 360px;
    user-select: none;
}

.ig-media-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-media-stage img,
.ig-media-stage video,
.ig-stage-media {
    max-width: 100%;
    max-height: 84vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: auto;
    border: none;
    outline: none;
}

/* 8. Dots at bottom of carousel (NO arrows) */
.ig-slide-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 20px;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.ig-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    outline: none;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ig-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.ig-dot.active {
    width: 22px;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* Right Content Section */
.ig-modal-sidebar {
    flex: 1;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
}

/* 6. Header Section: User Image, Name, Username */
.ig-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ig-modal-avatar-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #f09433, #dc2743, #bc1888);
    padding: 2px;
    box-sizing: border-box;
}

.ig-modal-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: #ffffff;
}

.ig-modal-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #262626;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.ig-modal-user-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ig-modal-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ig-modal-name {
    font-size: 15px;
    font-weight: 700;
    color: #111111;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-modal-verified-badge {
    display: inline-flex;
    align-items: center;
}

.ig-modal-verified-badge svg {
    display: block;
    flex-shrink: 0;
}

.ig-modal-sub-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #737373;
}

.ig-modal-username {
    color: #737373;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-modal-dot {
    color: #a8a8a8;
    font-size: 10px;
}

.ig-modal-date {
    color: #8e8e8e;
    white-space: nowrap;
}

/* 5. Caption Area: Displayed FIRST on Right Content */
.ig-modal-caption-area {
    flex: 1;
    overflow-y: auto;
    padding: 18px 0;
    margin-right: -4px;
    padding-right: 4px;
}

.ig-modal-caption {
    font-size: 14px;
    line-height: 1.6;
    color: #262626;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    margin: 0;
}

/* 5. Engagement Stats: Total Likes, Comments, Repost/Shares */
.ig-modal-engagement-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 0;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ig-eng-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #333333;
    font-size: 13px;
    font-weight: 600;
    cursor: default;
    user-select: none;
}

.ig-eng-item svg {
    display: block;
    color: #555555;
    transition: color 0.2s ease;
}

.ig-eng-likes svg {
    color: #e1306c;
}

.ig-eng-comments:hover svg {
    color: #3897f0;
}

.ig-eng-repost:hover svg {
    color: #10b981;
}

.ig-eng-count {
    color: #262626;
}

/* 5. Last: View on Instagram Button */
.ig-modal-footer {
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ig-modal-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 18px;
    background: linear-gradient(135deg, #405de6, #833ab4, #e1306c);
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(225, 48, 108, 0.28);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
}

.ig-modal-link:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    color: #ffffff;
}

.ig-modal-link svg {
    display: block;
    fill: #ffffff;
    flex-shrink: 0;
}

/* Responsive Modal (Tablet & Mobile) */
@media (max-width: 768px) {
    .ig-modal-overlay {
        padding: 12px;
    }

    .ig-modal-container {
        max-height: 92vh;
        width: 100%;
        border-radius: 14px;
    }

    .ig-modal-body {
        flex-direction: column;
        min-height: auto;
        overflow-y: auto;
        max-height: 92vh;
    }

    .ig-modal-media-wrap {
        flex: none;
        width: 100%;
        height: 48vh;
        max-height: 48vh;
        min-height: 240px;
    }

    .ig-media-stage img,
    .ig-media-stage video,
    .ig-stage-media {
        max-height: 48vh;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .ig-modal-sidebar {
        flex: none;
        width: 100%;
        padding: 16px;
        overflow: visible;
    }

    .ig-modal-caption-area {
        max-height: 180px;
    }
}
