/* ================================================
   IG Gallery Plugin - Instagram-style Grid + Modal
   ================================================ */

/* ========== GRID 3 KOLOM ========== */
.ig-grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 935px;
    margin: 0 auto;
}

.ig-grid-item {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Rasio 1:1 kotak */
    overflow: hidden;
    cursor: pointer;
    background: #fafafa;
}

.ig-grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.ig-grid-placeholder {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    background: #efefef;
}

/* Hover overlay */
.ig-grid-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ig-grid-item:hover .ig-grid-overlay {
    opacity: 1;
}

.ig-grid-overlay-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
}

/* Icon multi-gambar (slideshow) di pojok kanan atas */
.ig-grid-multi-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* Badge Tanggal di pojok kiri bawah grid */
.ig-grid-date-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    letter-spacing: 0.3px;
}

/* ========== MODAL OVERLAY ========== */
.ig-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 40px;
    box-sizing: border-box;
}

.ig-modal-overlay.active {
    display: flex;
}

/* Modal Box */
.ig-modal {
    position: relative;
    background: #fff;
    border-radius: 4px;
    max-width: 960px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 4px 30px rgba(0,0,0,0.3);
}

.ig-modal-close {
    position: absolute;
    top: -36px;
    right: -4px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    padding: 4px 8px;
}

.ig-modal-close:hover {
    opacity: 0.7;
}

/* Layout: kiri gambar, kanan detail */
.ig-modal-content {
    display: flex;
    flex-direction: row;
    height: 80vh;
    max-height: 80vh;
}

/* ========== MODAL MEDIA (kiri) ========== */
.ig-modal-media {
    flex: 1 1 60%;
    max-width: 60%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.ig-modal-slideshow {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ig-modal-slides {
    display: flex !important;
    flex-wrap: nowrap !important;
    height: 100%;
    transition: transform 0.3s ease-in-out;
}

.ig-modal-slide {
    min-width: 100% !important;
    width: 100% !important;
    flex-shrink: 0 !important;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.ig-modal-slide img {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    margin: 0 !important;
}

/* Navigasi slideshow di dalam modal */
.ig-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.75);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 14px;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.ig-modal-nav.prev { left: 10px; }
.ig-modal-nav.next { right: 10px; }
.ig-modal-nav:hover { background: #fff; }

.ig-modal-dots {
    position: absolute;
    bottom: 12px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    gap: 5px;
    z-index: 10;
}

.ig-modal-dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-block;
}

.ig-modal-dot.active {
    background: #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

/* ========== MODAL DETAIL (kanan) ========== */
.ig-modal-detail {
    flex: 1 1 40%;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #efefef;
    background: #fff;
}

.ig-modal-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #efefef;
    flex-shrink: 0;
}

.ig-modal-avatar {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 1px solid #dbdbdb;
}

.ig-modal-author-name {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

.ig-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #262626;
}

.ig-modal-body p {
    margin: 0 0 10px 0;
}

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

.ig-modal-body a {
    color: #00376b;
    text-decoration: none;
}

.ig-modal-body a:hover {
    text-decoration: underline;
}

.ig-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #efefef;
    flex-shrink: 0;
}

.ig-modal-time {
    font-size: 10px;
    color: #8e8e8e;
    text-transform: uppercase;
}

/* ========== RESPONSIVE ========== */
@media screen and (max-width: 768px) {
    .ig-grid-container {
        gap: 2px;
    }

    .ig-modal-overlay {
        padding: 0;
    }
    
    .ig-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ig-modal-content {
        flex-direction: column;
        height: 100vh;
        max-height: 100vh;
    }
    
    .ig-modal-media {
        flex: 0 0 auto;
        max-width: 100%;
        width: 100%;
        height: 50vh;
    }
    
    .ig-modal-detail {
        flex: 1;
        max-width: 100%;
        width: 100%;
    }
    
    .ig-modal-close {
        top: 8px;
        right: 8px;
        color: #fff;
        background: rgba(0,0,0,0.5);
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        padding: 0;
    }
}

/* ========== DARK MODE SUPPORT ========== */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) .ig-modal {
        background: #000;
    }
    body:not(.light-theme) .ig-modal-detail {
        background: #000;
        border-color: #363636;
    }
    body:not(.light-theme) .ig-modal-header {
        border-color: #363636;
    }
    body:not(.light-theme) .ig-modal-footer {
        border-color: #363636;
    }
    body:not(.light-theme) .ig-modal-author-name,
    body:not(.light-theme) .ig-modal-body {
        color: #f5f5f5;
    }
    body:not(.light-theme) .ig-modal-time {
        color: #a8a8a8;
    }
}
