/* =========================================
   COMPONENT: COMMENT MODAL (Instagram Style)
   ========================================= */

/* 1. OVERLAY (Backdrop) */
.comment-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport for mobile keyboard awareness */
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.comment-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 2. MODAL CONTAINER (Desktop) */
.comment-modal {
    width: 90%;
    max-width: 1100px;
    height: 85vh;
    /* Fixed height for clean layout */
    background: white;
    border-radius: 12px;
    /* iOS style rounded corners */
    overflow: hidden;
    display: flex;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.comment-overlay.active .comment-modal {
    transform: scale(1);
}

/* Close Button (Desktop Outside) */
.modal-close-desktop {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10001;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.modal-close-desktop:hover {
    opacity: 1;
}

/* 3. SPLIT VIEW layout */
.cm-media-col {
    flex: 1.5;
    /* Takes 60% of space */
    background: black;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* TEXT POST MODE (White Background) */
.cm-media-col.text-mode {
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.cm-text-preview {
    padding: 60px;
    color: #1c1e21;
    /* Facebook/Standard Black */
    font-size: 1.6rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    line-height: 1.5;
    font-weight: 600;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: transparent;
}

.cm-comments-col {
    flex: 1;
    /* Takes 40% of space */
    background: white;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* Media Styling */
.cm-media-img,
.cm-media-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure full image is visible without cropping */
}

/* 4. COMMENTS COLUMN INTERNALS */
.cm-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.cm-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.cm-author-name {
    font-weight: 700;
    font-size: 1rem;
    color: #333;
    text-decoration: none;
}

.cm-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* Reuse existing comment styles but scoped if needed */
.cm-scroll-area .comment-item {
    margin-bottom: 15px;
}

/* Actions Bar inside Modal */
.cm-actions-bar {
    margin-top: auto;
    /* Push to bottom of flex container if space permits */
    background: #fff;
    z-index: 5;
}

.cm-actions-bar .act-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #555;
    transition: all 0.2s ease;
}

.cm-actions-bar .act-btn:hover {
    color: var(--color-primary);
    transform: scale(1.05);
}

.cm-actions-bar .act-btn.active {
    color: #ff0055;
}

.cm-actions-bar .act-btn.active .act-icon {
    animation: heartBeat 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cm-footer {
    padding: 15px;
    border-top: none;
    /* Removed border since actions bar has it */
    background: white;
}

/* 5. MOBILE BOTTOM SHEET (Slide Up) */
@media (max-width: 1023px) {
    .comment-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        height: 100dvh;
        /* Full screen, dynamic height */
        border-radius: 0;
        /* No borders for full screen */
        flex-direction: column;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .comment-overlay.active .comment-modal {
        transform: translateY(0);
    }

    /* Hide Media Column on Mobile (Instagram Style - Focus on comments) */
    .cm-media-col {
        display: none;
    }

    .cm-comments-col {
        border-left: none;
        width: 100%;
    }

    .modal-close-desktop {
        display: none;
        /* Use mobile drag handle or back button concept */
    }

    /* Mobile Drag Handle */
    .cm-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 4px;
    }

    .cm-header {
        position: relative;
        justify-content: center;
        padding-top: calc(25px + env(safe-area-inset-top));
        /* Clear iOS notch */
    }
}