/* messages.css - v5.0.0 Definitive Layout Fix */

/* --- CORE LAYOUT OVERRIDE (Most Aggressive Version) --- */
/* This targets all potential parent containers on the specific messaging page ID */
/* to force full width and remove all padding/margins. */

body.page-id-579,
body.page-id-579 > div,
body.page-id-579 #main-wrapper,
body.page-id-579 .page-wrapper,
body.page-id-579 .container-fluid,
body.page-id-579 .container,
body.page-id-579 .row,
body.page-id-579 .col-xs-12,
body.page-id-579 .card,
body.page-id-579 #main-content,
body.page-id-579 .site-content,
body.page-id-579 .card.nopadding.mb-4
{
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    float: none !important;
}

body.page-id-579 .card-body,
body.page-id-579 .card-block {
    padding: 0 !important;
}

body.page-id-579 .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* --- Specific Override for #frame's width --- */
#frame {
  width: 100% !important; /* Force 100% width, overriding inline styles */
  height: calc(100vh - 150px); /* Keep height calculation */
  min-height: 650px;
  background: #fff;
  display: flex;
  border-top: 1px solid #e0e0e0;
}

#sidepanel {
  min-width: 280px;
  max-width: 340px;
  width: 30%;
  height: 100%;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.content {
  width: 70%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
}

.contact-profile {
  height: 60px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
}

/* --- Component Styles --- */
#sidepanel #profile { width: 90%; margin: 25px auto; }
#sidepanel #profile .wrap { height: 60px; line-height: 60px; }
#sidepanel #profile .wrap img { width: 50px; border-radius: 50%; padding: 3px; border: 2px solid #2ecc71; float: left; }
#sidepanel #profile .wrap p { float: left; margin-left: 15px; font-weight: 600; }

#sidepanel #search { border-top: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0; padding: 10px; background: #f1f1f1; }
#sidepanel #search label { position: absolute; margin: 10px 0 0 10px; color: #999; }
#sidepanel #search input.bar { padding: 10px 0 10px 36px; width: 100%; border: 1px solid #ccc; border-radius: 5px; }

#sidepanel #contacts { flex-grow: 1; overflow-y: auto; }
#sidepanel #contacts ul { padding: 0; margin: 0; list-style-type: none; }
#sidepanel #contacts ul li.contact { padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #e0e0e0; display: flex; align-items: center; position: relative; }
#sidepanel #contacts ul li.contact:hover { background: #f1f1f1; }
#sidepanel #contacts ul li.contact.active { background: #e9ecef; font-weight: bold; }
#sidepanel #contacts ul li.contact .wrap { display: flex; align-items: center; width: 100%; }
#sidepanel #contacts ul li.contact .wrap img { width: 40px; border-radius: 50%; margin-right: 10px; }
#sidepanel #contacts ul li.contact .wrap .meta { flex-grow: 1; }
#sidepanel #contacts ul li.contact .wrap .meta .name { font-weight: 600; margin-bottom: 2px; }
#sidepanel #contacts ul li.contact .wrap .meta .preview { margin-top: 0px; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9em; }
#sidepanel #contacts ul li.contact .wrap .meta .time { font-size: 0.8em; color: #999; position: absolute; right: 15px; top: 10px; }


/* Online/Offline Status Dot */
.contact-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: absolute;
    top: 38px;
    left: 40px;
    border: 2px solid #f8f9fa;
    z-index: 10;
}

.contact-status.online {
    background-color: #2ecc71; /* Green */
}

.contact-status.offline {
    background-color: #ccc; /* Grey */
}

/* Unread Message Count */
.unread-count {
    background-color: #dc3545; /* Red */
    color: white;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 10px;
    position: absolute;
    right: 15px;
    bottom: 10px;
    font-weight: bold;
}


.profile-info-group { display: flex; align-items: center; gap: 10px; }
.contact-profile img { width: 40px; height: 40px; border-radius: 50%; }
.contact-profile p { margin-left: 10px; font-weight: 600; }

.messages ul { list-style-type: none; padding: 0; margin: 0; }
.messages ul li { display: flex; margin-bottom: 15px; }
.messages ul li.sent { justify-content: flex-end; }
.messages ul li img { width: 32px; height: 32px; border-radius: 50%; margin: 0 10px; order: 0; }
.messages ul li.sent img { order: 1; }
.messages ul li p { padding: 10px 15px; border-radius: 18px; line-height: 1.4; max-width: 75%; }
.messages ul li.sent p { background: #0d6efd; color: #f5f5f5; }
.messages ul li.replies p { background: #e9ecef; color: #333; }

.message-input { background: #f8f9fa; border-top: 1px solid #e0e0e0; flex-shrink: 0; }
.message-input .wrap { display: flex; align-items: center; padding: 10px; }
.message-input .wrap input[type="text"] { flex-grow: 1; border: none; padding: 15px; background: transparent; }
.message-input .wrap input[type="text"]:focus { outline: none; }
.message-input .wrap button.submit { width: 60px; border: none; cursor: pointer; background: #0d6efd; color: #f5f5f5; font-size: 1.2em; border-radius: 40px; }
.message-input .wrap button.submit:hover { background: #0b5ed7; }

/* File Attachment Button */
.file-attach-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    font-size: 1.5em;
    margin-right: 10px;
    padding: 5px;
    border-radius: 50%;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.file-attach-button:hover {
    color: #007bff;
    background-color: #e9ecef;
}

/* File Name Display */
.message-input-file {
    font-size: 0.9em;
    color: #555;
    margin-left: 10px;
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* --- NEW: File Preview Styling --- */
.chat-file-preview {
    display: inline-flex; /* Use inline-flex to keep them in line, but allow flex properties */
    flex-direction: column; /* Stack icon/image and text vertically */
    align-items: center; /* Center content horizontally */
    margin: 5px; /* Space between multiple file previews */
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: background-color 0.2s ease;
    max-width: 100px; /* Limit preview width */
    text-align: center; /* Center text for file name */
    vertical-align: top; /* Align to top if mixed with text */
}

.messages ul li.sent p .chat-file-preview {
    background-color: #0c5ed7; /* Darker background for sent messages */
    border-color: #0c5ed7;
}
.messages ul li.replies p .chat-file-preview {
    background-color: #e0e0e0; /* Lighter background for replies */
    border-color: #e0e0e0;
}

.chat-file-preview:hover {
    background-color: #e0e0e0;
}
.messages ul li.sent p .chat-file-preview:hover {
    background-color: #0a4da3; /* Darker blue on hover for sent */
}


.chat-file-preview img {
    max-width: 60px; /* Thumbnail size */
    max-height: 60px;
    height: auto;
    border-radius: 4px;
    object-fit: contain;
    margin-bottom: 5px; /* Space between image and file name */
}

.chat-file-preview i.fa {
    font-size: 3em; /* Icon size */
    color: #555; /* Icon color */
    margin-bottom: 5px;
}
.messages ul li.sent p .chat-file-preview i.fa {
    color: #fff; /* White icon for sent messages */
}


.chat-file-preview span {
    font-size: 0.8em;
    color: #333;
    word-break: break-all; /* Break long file names */
    white-space: normal; /* Allow wrapping */
    max-height: 2.4em; /* Limit to 2 lines */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.messages ul li.sent p .chat-file-preview span {
    color: #fff; /* White text for sent messages */
}

/* --- NEW: Media Modal Styling --- */
.chat-media-modal {
    display: flex;
    position: fixed;
    z-index: 9999; /* High z-index to be on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9); /* Black background with transparency */
    justify-content: center;
    align-items: center;
}

.chat-media-modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    background-color: #000; /* Ensure content background is black */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chat-modal-media {
    max-width: 100%;
    max-height: 80vh; /* Limit height to viewport height */
    display: block;
    object-fit: contain;
}

.chat-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10000;
}

.chat-modal-close:hover,
.chat-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.chat-modal-download-btn {
    background-color: #0d6efd;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.chat-modal-download-btn:hover {
    background-color: #0b5ed7;
}
.chat-modal-download-btn i {
    color: white; /* Ensure icon color is white */
}


/* Styling for the Zoom Button */
#zoom-controls-group { display: flex; align-items: center; gap: 15px; }
#zoom-invites-label { font-weight: 600; color: #555; white-space: nowrap; }
.zoom-button-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 36px;
    background-color: #0d6efd;
    color: white;
    font-weight: bold;
    font-size: 14px;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.zoom-button-circle:hover { background-color: #0b5ed7; }

/* Styling for the 'is typing' message */
#is_typing {
    margin-right: 15px;
    color: #777;
    font-style: italic;
    font-size: 13px;
    flex-grow: 1;
    text-align: right;
    display: none;
}

/* --- UPDATED: General Link Styling in Chat for better visibility --- */
/* For sent messages (blue background) - Changed to White as requested */
.messages ul li.sent p a:link,
.messages ul li.sent p a:visited {
    color: #FFFFFF !important;
    text-decoration: underline;
    font-weight: bold;
}

.messages ul li.sent p a:hover {
    color: #E0E0E0 !important;
}

/* For replies (light grey background) */
.messages ul li.replies p a:link,
.messages ul li.replies p a:visited {
    color: #007bff !important;
    text-decoration: underline;
    font-weight: bold;
}

.messages ul li.replies p a:hover {
    color: #0056b3 !important;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    #pt-connection-requests-list li {
        flex-direction: column;
        align-items: flex-start;
    }

    #pt-connection-requests-list li .request-actions {
        margin-top: 10px;
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    #pt-connection-requests-list li .request-actions button {
        margin-left: 0;
        margin-right: 10px;
        flex-grow: 1;
    }

    /* Adjustments for chat header on small screens */
    .contact-profile {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: 10px;
    }

    .contact-profile > div:first-child {
        margin-bottom: 10px;
    }

    #zoom-controls-group {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 10px;
        transform: none;
    }

    #is_typing {
        width: 100%;
        text-align: right;
        margin-right: 0;
        margin-bottom: 10px;
    }
}
