/* WP Simple Guest Chat - media.css */
/* Styles for image attachments, video, audio players, file links, upload progress */

/* Media Message specific structure (complementing messaging.css) */
.wsgc-message-entry:has(.wsgc-media-message-content) .wsgc-media-message-content {
    display: flex;
    flex-direction: column;
}
.wsgc-media-message-content .wsgc-nickname {
    font-weight: bold;
    color: #0073aa; /* Default, overridden by dynamic styles */
    margin-right: 5px; /* For LTR, might need adjustment for RTL */
    display: block; /* Nickname on its own line */
}
.wsgc-media-message-content .wsgc-text { /* Container for media element and filename */
    line-height: 1.4;
}
.wsgc-message-meta-row { /* Contains timestamp and download/delete for media */
    display: flex;
    align-items: center;
    margin-top: 4px;
    gap: 8px;
}
.wsgc-message-meta-row .wsgc-timestamp {
    font-size: 0.75em;
    color: #888;
}

/* Own Media Message Alignment */
.wsgc-chat-instance-wrapper .wsgc-message-entry.own-message .wsgc-media-message-content .wsgc-nickname {
    color: #0277bd; /* Default, overridden by dynamic styles */
    text-align: right;
}
.wsgc-chat-instance-wrapper .wsgc-message-entry.own-message .wsgc-media-message-content .wsgc-text {
    text-align: right; /* Align content like filename to the right */
}
.wsgc-chat-instance-wrapper .wsgc-message-entry.own-message .wsgc-message-meta-row {
    justify-content: flex-end;
}

/* Other Media Message Alignment */
.wsgc-chat-instance-wrapper .wsgc-message-entry.other-message .wsgc-media-message-content .wsgc-nickname {
    text-align: left;
}
.wsgc-chat-instance-wrapper .wsgc-message-entry.other-message .wsgc-media-message-content .wsgc-text {
    text-align: left;
}
.wsgc-chat-instance-wrapper .wsgc-message-entry.other-message .wsgc-message-meta-row {
    justify-content: flex-start;
}


/* Image Attachments */
.wsgc-media-message-content .wsgc-text .wsgc-image-attachment {
    display: inline-block; /* Allows text-align to work on parent */
    width: 100%;
    max-width: 250px; /* Max width for thumbnail */
    margin-top: 5px;
}
.wsgc-media-message-content .wsgc-text .wsgc-image-attachment a.wsgc-image-popup-trigger {
    display: block;
    text-decoration: none;
    cursor: pointer;
}
.wsgc-media-message-content .wsgc-text img.wsgc-chat-image-thumbnail {
    display: block;
    max-width: 100%;
    max-height: 250px; /* Max height for thumbnail */
    width: auto; /* Maintain aspect ratio */
    height: auto; /* Maintain aspect ratio */
    border-radius: 3px;
}

/* File Links (non-image/video/audio) */
.wsgc-media-message-content .wsgc-text a.wsgc-chat-file-link {
    display: inline-block;
    padding: 8px 12px;
    background-color: #e9e9e9;
    border-radius: 3px;
    text-decoration: none;
    color: #333;
    font-size: 0.9em;
    margin-top: 5px;
}
.wsgc-media-message-content .wsgc-text a.wsgc-chat-file-link:hover {
    background-color: #dcdcdc;
}

/* Video Attachments */
.wsgc-media-message-content .wsgc-text .wsgc-video-attachment {
    display: inline-block;
    width: 100%;
    max-width: 300px; /* Max width for video player */
    margin-top: 5px;
}
.wsgc-media-message-content .wsgc-text .wsgc-chat-video {
    max-width: 100%;
    max-height: 220px; /* Max height for video player */
    height: auto;
    display: block;
    border-radius: 3px;
    background-color: #000; /* Fallback background */
}

/* Inline Audio Player */
.wsgc-media-message-content .wsgc-text .wsgc-inline-audio-player {
    display: inline-flex; /* Allows text-align from parent */
    align-items: center;
    background-color: #e9f5fd;
    padding: 8px 12px;
    border-radius: 15px; /* Pill shape */
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid #cce7fa;
    min-width: 120px;
    max-width: 100%; /* Can take full width of its container */
    box-sizing: border-box;
    gap: 8px;
    margin-top: 5px;
}
.wsgc-media-message-content .wsgc-text .wsgc-inline-audio-player:hover,
.wsgc-media-message-content .wsgc-text .wsgc-inline-audio-player:focus {
    background-color: #d1e9fb;
    outline: none;
}
.wsgc-media-message-content .wsgc-text .wsgc-audio-icon {
    font-size: 1.3em;
    color: #0073aa;
    line-height: 1;
}
.wsgc-inline-audio-player .wsgc-audio-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden; /* For text ellipsis */
}
.wsgc-inline-audio-player .wsgc-audio-top-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.wsgc-inline-audio-player .wsgc-media-filename {
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    min-width: 0;
}
.wsgc-progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: #ddd;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    margin-bottom: 4px;
}
.wsgc-progress-bar {
    height: 100%;
    width: 0%;
    background-color: #0073aa; /* Or primary color */
    border-radius: 4px;
    transition: width 0.1s linear;
}
.wsgc-media-time {
    font-size: 0.75em;
    color: #666;
    text-align: left;
}
.wsgc-media-message-content .wsgc-text .wsgc-hidden-audio-element {
    display: none !important;
}


/* Media Download Link (in meta row) */
.wsgc-media-download-link {
    display: inline-block;
    font-size: 1em; /* Adjust if needed relative to timestamp */
    text-decoration: none;
    color: #555;
    vertical-align: middle;
    line-height: 1; /* Match timestamp line height */
}
.wsgc-media-download-link:hover {
    color: #0073aa; /* Or primary color */
}

/* Upload Progress Indicator */
.wsgc-chat-instance-wrapper .wsgc-upload-progress-indicator {
    margin-top: 5px;
    padding: 5px;
    background-color: #eef;
    border-radius: 3px;
    font-size: 0.9em;
    color: #337ab7;
}

.wsgc-media-filename-overlay {
    display: block;
    font-size: 0.8em;
    color: #555;
    padding: 3px 6px;
    background-color: rgba(240, 240, 240, 0.9);
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
    text-align: center;
    word-break: break-all;
    margin-top: -3px;
    position: relative;
}

/* --- MODIFICATION START: Image Popup/Lightbox Styles --- */

.wsgc-chat-instance-wrapper .wsgc-image-modal .wsgc-modal-content {
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    position: relative; 
    width: auto;
    height: auto;
}

.wsgc-chat-instance-wrapper .wsgc-image-modal-content-img {
    display: block;
    
    /* THE FIX: Constraints are applied without !important for better maintainability. */
    max-width: 90vw;
    max-height: 90vh;
    
    width: auto;
    height: auto;
    
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.wsgc-chat-instance-wrapper .wsgc-image-modal-caption {
    display: none !important;
}

.wsgc-chat-instance-wrapper .wsgc-image-modal-close {
    position: absolute;
    top: -15px;         
    right: -15px;       
    color: #fff;
    background-color: #e53935; /* Vibrant red */
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 32px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    border: 2px solid #fff;
    z-index: 10;
}

.wsgc-chat-instance-wrapper .wsgc-image-modal-close:hover {
    background-color: #c62828; /* Darker red on hover */
}

/* --- MODIFICATION END --- */