/**
 * Image Modal Styles
 */

/* Modal overlay */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
}

/* Modal content */
.image-modal-content {
    position: relative;
    max-width: 1200px;
    max-height: 90vh;
    margin: 2rem auto;
    background: #fff;
    border-radius: 0.75rem;
    overflow: hidden;
    z-index: 10000;
}

.dark .image-modal-content {
    background: #212d3d;
}

/* Close button */
.image-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Modal body */
.image-modal-body {
    height: 80vh;
    /* Fixed height for consistency */
    overflow: hidden;
    /* Content scrolls inside containers */
}

/* Flex Container for Desktop */
.modal-flex-container {
    display: flex;
    height: 100%;
}

/* Media Container */
.modal-media-container {
    flex: 0 0 auto;
    /* Don't grow, don't shrink */
    width: 60%;
    /* Roughly space for the image */
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.image-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-image {
    max-width: 100%;
    max-height: 80vh;
    /* Keep within modal body */
    object-fit: contain;
    display: block;
    /* Request 400x400 logical size suggestion */
    min-width: 400px;
    min-height: 400px;
    background: #111;
    /* Placeholder bg */
}

/* Sidebar Container */
.modal-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    height: 100%;
    min-width: 320px;
    /* Minimum width for comments */
}

.dark .modal-sidebar {
    background: #212d3d;
    border-color: #2f3d50;
}

/* Image Info */
.image-info {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    background: #f9fafb;
    flex-shrink: 0;
}

.dark .image-info {
    border-color: #2f3d50;
    background: #1a2332;
    color: #b8c5d6;
}

/* Comments Section */
.comments-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    /* Inner scroll */
}

.comments-section h3 {
    margin: 0;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.dark .comments-section h3 {
    border-color: #2f3d50;
    background: #212d3d;
}

#comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 0;
}

.image-comment {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: #f3f4f6;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.dark .image-comment {
    background: #2a3749;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

/* Comment Form */
#image-comment-form {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
}

.dark #image-comment-form {
    border-color: #2f3d50;
    background: #212d3d;
}

#image-comment-form textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 1.5rem;
    resize: none;
    height: 42px;
    /* Single line height */
    line-height: 1.4;
    overflow: hidden;
}

#image-comment-form textarea:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 2px #22c55e;
}

.dark #image-comment-form textarea {
    background: #1a2332;
    border-color: #2f3d50;
    color: #e8eef5;
}

#image-comment-form button {
    padding: 0.5rem 1rem;
    background: transparent;
    color: #22c55e;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

#image-comment-form button:hover {
    color: #16a34a;
    background: transparent;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .image-modal-content {
        margin: 0;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .image-modal-body {
        height: 100%;
        overflow-y: auto;
        /* Scroll whole body on mobile */
    }

    .modal-flex-container {
        flex-direction: column;
        height: auto;
        /* Allow auto height */
    }

    .modal-media-container {
        width: 100%;
        height: auto;
        min-height: auto;
        background: #000;
        padding: 0;
    }

    #modal-image {
        min-width: auto;
        min-height: auto;
        max-height: 60vh;
        /* Limit image height on mobile */
        width: 100%;
        height: auto;
    }

    .modal-sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }

    #comments-list {
        max-height: none;
        overflow: visible;
    }

    .comments-section {
        overflow: visible;
    }

    /* Hide close button on mobile, assume back/overlay click */
    .image-modal-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 2.5rem;
        height: 2.5rem;
        background: rgba(0, 0, 0, 0.6);
    }
}