/**
 * MEDIA MODAL - Full Screen Image/GIF/Video Viewer
 * Shows media in center of screen when clicked
 */

/* Modal overlay */
.media-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.media-modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Close button */
.media-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: all 0.2s ease;
}

.media-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Media container */
.media-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: zoomIn 0.3s ease-out;
}
/* The actual enlarged image/video — big enough to read, but always fits the screen. */
.mm-media {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Images */
.media-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* GIFs (same as images) */
.media-modal-content img[src$=".gif"],
.media-modal-content img[src*=".gif?"] {
    max-width: 100%;
    max-height: 90vh;
}

/* Videos */
.media-modal-content video {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .media-modal-overlay {
        padding: 0.5rem;
    }

    .media-modal-close {
        top: env(safe-area-inset-top, 0.5rem);
        right: 0.5rem;
        width: 40px;
        height: 40px;
    }

    .media-modal-content {
        max-width: 95vw;
        max-height: 85vh;
    }

    .media-modal-content img,
    .media-modal-content video {
        max-height: 85vh;
    }
}

/* Loading state */
.media-modal-content.loading::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Prevent body scroll when modal is open */
body.media-modal-open {
    overflow: hidden;
}

/* Click anywhere to close hint */
.media-modal-overlay::after {
    content: 'Click anywhere to close';
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    pointer-events: none;
    animation: fadeIn 0.5s ease-out 0.5s both;
}

@media (max-width: 768px) {
    .media-modal-overlay::after {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0));
        font-size: 0.75rem;
    }
}

/* ── Photo/video viewer: image + the relocated actions/comments/composer must all
   fit on screen and never bleed off the bottom. Make the dialog a flex column with
   a scrollable foot. ─────────────────────────────────────────────────────────── */
.media-modal-dialog {
    display: flex;
    flex-direction: column;
    height: 94vh;           /* FILL the space — no empty black gap */
    max-height: 94vh;
    max-width: 96vw;
    width: 100%;
}
/* Image fills the top area (contained), pushing the comments/Post to the bottom. */
.media-modal-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.media-modal-content img,
.media-modal-content video,
.media-modal-content .mm-media { max-height: 100% !important; max-width: 100%; width: auto; height: auto; object-fit: contain; }
/* Foot sits at the bottom: actions + comments (scroll) + the Post composer. */
.media-modal-foot {
    flex: 0 0 auto;
    max-height: 48vh;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #0a1628;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.media-modal-foot > *,
.media-modal-foot .dc-inline-composer,
.media-modal-foot .pc-comment-form,
.media-modal-foot input,
.media-modal-foot textarea { max-width: 100% !important; box-sizing: border-box; }
