/* Responsive CSS by Daniel Kohler
For www.hkhikersclub.com
Unified Messaging Styles for Admin and User */

/* --- Keyframes --- */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.97);}
    to   { opacity: 1; transform: scale(1);}
}

/* --- General Layout --- */
.grid-container-messages {
    display: flex;
    flex-direction: column;
    width: calc(100% - 20px); /* Adjust for left and right margins */
    max-width: calc(100vw - 20px);
    margin: 0 auto;
    margin-right: 10px;
    margin-left: 10px;
    gap: 0px;
    box-sizing: border-box;
}

/* --- Inbox --- */
.inbox-header {
    background: #e5d8b1ff;
    border: 1px solid #ececec;
    border-radius: 8px;
    padding: 1.2em 1.5em 1em 1.5em;
    margin-top: 1em;
    margin-bottom: 0.5em;
    max-width: 100%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    width: 100%;
    box-sizing: border-box;
}
.inbox-title {
    margin: 0 0 0.7em 0;
    font-size: 1.7em;
    color: #7a7005;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.inbox-subtitle {
    margin: 0;
    font-size: 1.15em;
    color: #444;
    font-weight: 500;
}

/* --- Menu Bar (Admin & User) --- */
.menu-bar,
.menu-bar-inbox {
    width: 100%;
    margin-bottom: 1.5em;
}
.menu-bar-inner,
.menu-bar-inbox-inner {
    background: #7a7005;
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 0.7em 1em;
    border-radius: 6px;
}
.menu-bar-btn,
.menu-btn {
    background: #fff;
    color: #7a7005;
    font-weight: 600;
    padding: 0.5em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
}
.menu-bar-btn:hover, .menu-bar-btn:focus,
.menu-btn:hover, .menu-btn:focus {
    background: #eae9e6ff;
    color: #b3a81a;
}
@media (max-width: 700px) {
    .menu-bar {
        width: 96vw;
        min-width: 0;
        margin-left: 0vw;
        margin-right: 0vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .menu-bar-inner {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5em;
        align-items: stretch;
        justify-content: flex-start;
        width: 100%;
        box-sizing: border-box;
        padding: 0.7em 0.5em;
    }
    .menu-bar-btn {
        flex: 1 1 45%;
        min-width: 110px;
        max-width: 100%;
        font-size: 1em;
        white-space: nowrap;
        box-sizing: border-box;
        margin: 0;
    }
}
/* --- Menu Bar for Gallery End User & Admin --- */
.menu-bar-gallery {
    width: 100%;
    margin-bottom: 1.5em;
}
.menu-bar-gallery-inner {
    background: #7a7005;
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 0.7em 1em;
    border-radius: 6px;
}
.menu-bar-gallery-btn,
.menu-gallery-btn {
    background: #fff;
    color: #7a7005;
    font-weight: 600;
    padding: 0.5em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
}
.menu-bar-gallery-btn:hover, .menu-bar-gallery-btn:focus,
.menu-gallery-btn:hover, .menu-gallery-btn:focus {
    background: #eae9e6ff;
    color: #b3a81a;
}
@media (max-width: 700px) {
    .menu-bar-gallery {
        width: 80vw;
        min-width: 0;
        margin-left: 0vw;
        margin-right: 0vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .menu-bar-gallery-inner {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5em;
        align-items: stretch;
        justify-content: flex-start;
        width: 100%;
        box-sizing: border-box;
        padding: 0.7em 0.5em;
    }
    .menu-bar-gallery-btn {
        flex: 1 1 45%;
        min-width: 110px;
        max-width: 100%;
        font-size: 0.8em;
        white-space: nowrap;
        box-sizing: border-box;
        margin: 0;
    }
}

/* --- Inbox Table --- */
.inbox-table,
.archived-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2em;
}
.inbox-table th, .inbox-table td,
.archived-table th, .archived-table td {
    padding: 0.75em 1em 0.5em 1em;
    border-bottom: 1px solid #847e7e;
    text-align: left;
}
.inbox-table th,
.archived-table th {
    background: #f5f5f5;
    font-weight: bold;
}
.inbox-table tr:hover,
.archived-table tr:hover {
    background: #f9f9f9;
}
.inbox-table .row-unread,
.archived-table .row-unread {
    background: #fffbe6 !important;
}
.inbox-table .row-read,
.archived-table .row-read {
    background: #dcdbd5 !important;
}

/* --- Compact mobile thread listing --- */
.thread-list-mobile { display: none; }
.thread-card {
    display: block;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    margin-bottom: 0.7em;
    padding: 0.9em 1em 0.7em 1em;
    text-decoration: none;
    color: #222;
    border: 1px solid #e0e0e0;
    position: relative;
}
.thread-card-row {
    display: flex;
    align-items: center;
    gap: 0.7em;
    font-size: 1.08em;
    font-weight: bold;
}
.thread-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}
.thread-unread-badge {
    background: #e53935;
    color: #fff;
    border-radius: 1em;
    font-size: 0.95em;
    padding: 0.1em 0.7em;
    margin-left: auto;
    font-weight: bold;
}
.thread-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.97em;
    color: #888;
    margin-top: 0.2em;
}
.row-unread {
    background: #fffbe6 !important;
}

/* --- Thread/Conversation --- */
.conversation-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: #faf9f6;
    border: 1px solid #ececec;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    padding: 1em 0.7em 0.7em 0.7em;
    margin-top: 1em;
    margin-bottom: 0.5em;
}
.conversation-title {
    margin: 0 0 0.7em 0;
    font-size: 1.7em;
    color: #7a7005;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.conversation-participants {
    font-size: 1.08em;
    color: #444;
    margin-bottom: 0.2em;
    word-break: break-word;
}

/* --- Thread Container & Messages --- */
.thread-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    box-sizing: border-box;
    gap: 2em;
}
.thread-messages,
.reply-form-container {
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    padding: 1em;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}
.thread-messages {
    background: #fff;
}
.reply-form-container {
    background: #faf9f6;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #ececec;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.7em;
    max-width: 420px;
    width: 95%;
    position: relative;
}
.reply-form-container textarea {
    width: 100%;
    padding: 0.7em 1em;
    border: 1.5px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1.05em;
    background: #faf9f6;
    margin-bottom: 1.3em;
    min-height: 110px;
    resize: vertical;
    transition: border 0.2s;
    box-sizing: border-box;
}
.reply-form-container textarea:focus {
    border-color: #7a7005;
    outline: none;
    background: #fff;
}
.reply-form-container button {
    width: 100%;
    margin-top: 0.5em;
    padding: 0.7em 0;
    font-size: 1.1em;
    border-radius: 4px;
    border: none;
    background-color: #7a7005;
    color: #fff !important;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: center;
}
.reply-form-container button:hover,
.reply-form-container button:focus {
    background-color: #7a700587;
    color: black !important;
}

/* --- Reply Actions --- */
.reply-actions {
    display: flex;
    gap: 1em;
    justify-content: center;
    align-items: center;
    margin-top: 1em;
}

/* --- Emoji Bar --- */
.emoji-bar {
    margin-bottom: 0.7em;
    position: relative;
}
.emoji-bar button {
    padding: 0.3em 1em;
    font-size: 1.1em;
    border-radius: 4px;
    border: none;
    background: #eae9e6ff;
    color: #7a7005;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 0.5em;
}
.emoji-bar button:hover, .emoji-bar button:focus {
    background: #f5f5f5;
    color: #b3a81a;
}
.edit-emoji-bar {
    margin-bottom: 0.7em;
    position: relative;
}
.edit-emoji-bar button {
    padding: 0.3em 1em;
    font-size: 1.1em;
    border-radius: 4px;
    border: none;
    background: #eae9e6ff;
    color: #7a7005;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 0.5em;
}
.edit-emoji-bar button:hover, .edit-emoji-bar button:focus {
    background: #f5f5f5;
    color: #b3a81a;
}
emoji-picker {
    display: none;
    position: absolute;
    top: 2.5em;
    left: 0;
    z-index: 5000;
    max-width: 350px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    border-radius: 8px;
}

/* --- Message Read/Unread --- */
.message-read {
    background: #d9d3d36e;
    border-left: 4px solid #e0e0e0;
    padding: 0.5em;
    margin-bottom: 1em;
    margin-left: 5px;
    margin-right: 5px;
}
.message-unread {
    background: #fffbe6;
    border-left: 4px solid #ffc107;
    padding: 0.5em;
    margin-bottom: 1em;
    margin-left: 5px;
    margin-right: 5px;
}

/* --- Back to Inbox --- */
.back-to-inbox {
    display: inline-block;
    margin-bottom: 1.5em;
    padding: 0.7em 1.2em 0.7em 2.2em;
    background-color: #7a7005;
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    position: relative;
    transition: background 0.2s, color 0.2s;
}
.back-to-inbox::before {
    position: absolute;
    left: 1em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    color: #fff;
}
.back-to-inbox:hover, .back-to-inbox:focus {
    background-color: #7a700587;
    color: black !important;
    text-decoration: none;
}

/* --- Menu Bar for Thread View --- */
.menu-bar-thread {
    background: #7a7005;
    display: flex;
    align-items: stretch;
    gap: 1em;
    padding: 0.7em 1em;
    border-radius: 6px;
}
.menu-bar-thread .menu-btn {
    background: #fff;
    color: #7a7005;
    font-weight: 600;
    padding: 0.5em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
    margin: 0; /* Remove extra margin for consistency */
}
.menu-bar-thread .menu-btn:hover, .menu-bar-thread .menu-btn:focus {
    background: #eae9e6ff;
    color: #b3a81a;
}

/* --- Pagination Controls --- */
.pagination-controls {
    width: 100%;
    max-width: 100vw;
    text-align: center;
    margin: 1em 0;
    box-sizing: border-box;
}

/* --- Edit Message Modal --- */
.edit-message-modal,
#add-people-overlay .edit-message-modal,
#reply-overlay .edit-message-modal,
#edit-message-overlay .edit-message-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.18);
    padding: 2em 1.5em 1.5em 1.5em;
    max-width: 420px;
    width: 94vw;
    margin: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.edit-message-modal h3 {
    margin: 0 0 1.2em 0;
    font-size: 1.35em;
    color: #7a7005;
    text-align: center;
    letter-spacing: 0.01em;
}
.edit-label {
    font-weight: 500;
    color: #444;
    margin-bottom: 0.5em;
    display: block;
}
.edit-textarea {
    width: 100%;
    padding: 0.7em 1em;
    border: 1.5px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1.05em;
    background: #faf9f6;
    margin-bottom: 1.3em;
    min-height: 110px;
    resize: vertical;
    transition: border 0.2s;
    box-sizing: border-box;
}
.edit-textarea:focus {
    border-color: #7a7005;
    outline: none;
    background: #fff;
}
.edit-actions {
    display: flex;
    gap: 1em;
    justify-content: center;
    align-items: center;
}
.menu-btn.save-btn {
    background: #7a7005;
    color: #fff;
    font-weight: 600;
    padding: 0.7em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.05em;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
}
.menu-btn.save-btn:hover, .menu-btn.save-btn:focus {
    background: #b3a81a;
    color: #fff;
}
.menu-btn.cancel-btn {
    background: #eae9e6ff;
    color: #7a7005;
    font-weight: 600;
    padding: 0.7em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.05em;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
}
.menu-btn.cancel-btn:hover, .menu-btn.cancel-btn:focus {
    background: #f5f5f5;
    color: #b3a81a;
}
.menu-btn.close-btn {
    position: absolute;
    top: 0.7em;
    right: 1em;
    background: none;
    color: #888;
    font-size: 1.7em;
    padding: 0.1em 0.5em;
    min-width: unset;
    width: auto;
    height: auto;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}
.menu-btn.close-btn:hover, .menu-btn.close-btn:focus {
    color: #7a7005;
    background: none;
}

/* --- Add People Select --- */
.add-people-select {
    width: 100%;
    margin-bottom: 1.2em;
    padding: 0.7em 1em;
    border: 1.5px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1.05em;
    background: #faf9f6;
    min-height: 120px;
    box-sizing: border-box;
    display: block;
}
.add-people-select:focus {
    border-color: #7a7005;
    outline: none;
    background: #fff;
}

/* --- Highlight Buttons --- */
.highlight-edit-btn {
    background: #e67e22 !important;
    color: #fff !important;
    border: none;
    font-weight: 700;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(230,126,34,0.10);
    transition: background 0.2s, color 0.2s;
}
.highlight-edit-btn:hover, .highlight-edit-btn:focus {
    background: #ca6f1e !important;
    color: #fff !important;
}
.highlight-delete-btn {
    background: #e74c3c !important;
    color: #fff !important;
    border: none;
    font-weight: 700;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(231,76,60,0.10);
    transition: background 0.2s, color 0.2s;
}
.highlight-delete-btn:hover, .highlight-delete-btn:focus {
    background: #c0392b !important;
    color: #fff !important;
}
.highlight-restore-btn {
    background: #585438 !important;
    color: #fff !important;
    border: none;
    font-weight: 700;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(231,76,60,0.10);
    transition: background 0.2s, color 0.2s;
}
.highlight-restore-btn:hover, .highlight-restore-btn:focus {
    background: #7c7962 !important;
    color: #fff !important;
}

/* --- Message Actions --- */
.msg-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5em;
}

/* --- Image Popup Overlay --- */
#image-popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 5000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#image-popup-overlay.active {
    display: flex !important;
}
#popup-image {
    max-width: 95vw;
    max-height: 85vh;
    border-radius: 10px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.25);
    background: #fff;
    display: block;
    margin: auto;
    object-fit: contain;
}
#close-image-popup {
    position: absolute;
    top: 24px;
    right: 32px;
    background: #fff;
    color: #e74c3c;
    font-size: 2em;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    z-index: 5100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
#close-image-popup:hover, #close-image-popup:focus {
    background: #e74c3c;
    color: #fff;
}

/* --- File Input --- */
.styled-file-input {
    display: block;
    margin-bottom: 1.3em;
    padding: 0.5em 0.5em;
    border-radius: 5px;
    border: 1.5px solid #e0e0e0;
    background: #faf9f6;
    font-size: 1.05em;
    color: #444;
    cursor: pointer;
    transition: border 0.2s, background 0.2s;
}
.styled-file-input:focus {
    border-color: #7a7005;
    background: #fff;
    outline: none;
}

/* --- Form Container (Admin only) --- */
.form-container {
    max-width: 480px;
    margin: 2em auto 1em auto;
    padding: 2em 1.5em 1.5em 1.5em;
    background: #faf9f6;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #ececec;
}
.form-container label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 500;
    color: #444;
}
.form-container select,
.form-container input[type="text"],
.form-container textarea {
    width: 100%;
    padding: 0.6em 0.8em;
    margin-bottom: 1.2em;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    background: #fff;
    transition: border 0.2s;
}
.form-container select:focus,
.form-container input[type="text"]:focus,
.form-container textarea:focus {
    border-color: #7a7005;
    outline: none;
}
.form-container .new-thread-link {
    width: 100%;
    margin-top: 0.5em;
    padding: 0.7em 0;
    font-size: 1.1em;
    border-radius: 4px;
    border: none;
    background-color: #7a7005;
    color: #fff !important;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: center;
}
.form-container .new-thread-link:hover, .form-container .new-thread-link:focus {
    background-color: #7a700587;
    color: black !important;
}

/* --- Overlay for New Thread --- */
.new-thread-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.45); /* semi-transparent overlay */
    z-index: 3000;
    align-items: center;
    justify-content: center;
}
.new-thread-overlay.active {
    display: flex !important;
}
.new-thread-modal {
    background: #fff;
    padding: 2.5em 2em 2em 2em;
    border-radius: 12px;
    max-width: 420px;
    width: 95vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    animation: fadeInScale 0.2s;
}
.new-thread-modal .form-container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
    background: transparent;
}

/* --- Responsive Rules --- */
@media (max-width: 700px) {
    .inbox-header {
        max-width: 99vw;
        padding: 1em 0.7em 0.7em 0.7em;
        margin-top: 1em;
        margin-bottom: 0.5em;
    }
    .inbox-title {
        font-size: 1.2em;

    }
    .inbox-subtitle {
        font-size: 1em;
    }
    .inbox-table { display: none; }
    .thread-list-mobile { display: block; }
    .menu-bar-thread,
    .pagination-controls {
        padding-left: 0.5em !important;
        padding-right: 0.5em !important;
    }
    .conversation-header {
        margin-top: 1em !important;
        padding-left: 1em !important;
        padding-right: 1em !important;
    }
    .menu-bar-thread .menu-btn {
        margin-left: 0.5em;
        margin-right: 0.5em;
    }
    .grid-container-messages,
    .conversation-header,
    .thread-container,
    .thread-messages,
    .menu-bar-thread,
    .pagination-controls {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    .thread-list-mobile {
        width: 100vw;
        min-width: 0;
        margin-left: -2vw;
        margin-right: -2vw;
        box-sizing: border-box;
        padding: 0 0.5em;
        overflow-x: hidden;
    }
    .thread-card {
        border: 1px solid #e0e0e0;
        display: block;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        margin-bottom: 1em;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.07);
        padding: 1em 0.7em;
        text-decoration: none;
        color: inherit;
        overflow-x: auto;
        word-break: break-word;
    }
    .thread-card-link {
        display: block;
        text-decoration: none;
        color: inherit;
        /* Make the link fill the card except where the button is */
    }
    .thread-card-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5em;
        align-items: center;
        min-width: 0;
        font-size: 1.08em;
        font-weight: bold;
    }
    .thread-subject {
        flex: 1 1 60%;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .thread-count-mobile {
        display: inline !important;
        color: #5c5757;
        font-size: 1em;
    }
    .thread-unread-badge {
        display: inline !important;
        background: #e53935;
        color: #fff;
        border-radius: 1em;
        font-size: 0.95em;
        padding: 0.1em 0.7em;
        margin-left: 0.5em;
        font-weight: bold;
    }
    .thread-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5em;
        align-items: center;
        min-width: 0;
    }
    .thread-date {
        color: #888;
        font-size: 0.97em;
    }
    .archive-thread-mobile-form {
        position: absolute;
        top: 50%;
        right: 1em;
        transform: translateY(-50%);
        margin: 0;
        z-index: 2;
    }
    .archive-btn-mobile {
        margin-left: 1em;
        padding: 0.4em 1.2em;
        font-size: 1em;
        border-radius: 4px;
        background: #fff;
        color: #7a7005;
        border: 1px solid #ececec;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s, color 0.2s;
    }
    .archive-btn-mobile:hover, .archive-btn-mobile:focus {
        background: #eae9e6ff;
        color: #b3a81a;
    }
    /* Restrict modal forms to 95vw on mobile for better appearance */
    .edit-message-modal,
    #add-people-overlay .edit-message-modal,
    #reply-overlay .edit-message-modal,
    #edit-message-overlay .edit-message-modal {
        padding: 1em 0.5em 1em 0.5em;
        max-width: 95vw;
        width: 95vw;
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
    .edit-actions {
        flex-direction: row !important;
        gap: 0.5em;
        justify-content: center;
    }
    .thread-container {
        padding: 0 0.5em;
        gap: 1em;
    }
    .thread-messages,
    .reply-form-container {
        padding: 1em 0.5em;
    }
    .conversation-title {
        font-size: 1.2em;
        padding-left: 1em !important;
        padding-right: 1em !important;
    }
    .conversation-participants {
        font-size: 1em;
        padding-left: 1em !important;
        padding-right: 1em !important;
    }
}
@media (min-width: 701px) {
    .thread-list-mobile { display: none !important; }
}
@media (max-width: 600px) {
    .form-container {
        padding: 1em 0.5em 1em 0.5em;
    }
    .add-people-select {
        font-size: 1em;
        padding: 0.5em 0.7em;
    }
    .edit-message-modal {
        padding: 1.2em 0.5em 1em 0.5em;
        max-width: 99vw;
    }
    .edit-actions {
        flex-direction: column;
        gap: 0.5em;
    }
}
@media (min-width: 700px) {
    .edit-message-modal,
    #add-people-overlay .edit-message-modal,
    #reply-overlay .edit-message-modal,
    #edit-message-overlay .edit-message-modal {
        max-width: 500px;
        width: min(500px, 90vw);
        padding: 2.5em 2em 2em 2em;
    }
}
/* Responsive invitations table */
.inbox-invitations-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.inbox-invitations-header {
    display: table-row;
    background: #f5f5f5;
    font-weight: bold;
}
.inbox-invitations-header > div {
    display: table-cell;
    padding: 0.7em 1em;
    border-bottom: 1px solid #e0e0e0;
}
.inbox-invitations-row {
    display: table-row;
}
.inbox-invitations-cell {
    display: table-cell;
    padding: 0.7em 1em;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.inbox-invitations-row:last-child .inbox-invitations-cell {
    border-bottom: none;
}

/* Responsive for mobile */
@media (max-width: 700px) {
    .inbox-invitations-table, .inbox-invitations-header, .inbox-invitations-row, .inbox-invitations-cell {
        display: block;
        width: 100%;
    }
    .inbox-invitations-header {
        display: none;
    }
    .inbox-invitations-row {
        margin-bottom: 1em;
        background: #f9f9f9;
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.03);
        padding: 0.7em 0.5em;
    }
    .inbox-invitations-cell {
        border: none;
        padding: 0.4em 0.7em;
        position: relative;
    }
    .inbox-invitations-cell[data-label]:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #888;
        display: inline-block;
        min-width: 90px;
    }
}
.archive-btn {
    background: #6c6b68;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5em 1.2em;
    margin-left: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.archive-btn:hover {
    background: #161616;
    color: #fff;
}
.thread-delete-btn {
    background: #6c6b68;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5em 1.2em;
    margin-left: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.thread-delete-btn:hover {
    background: #161616;
    color: #fff;
}

/* --- Custom Confirm Archive Button for Threads --- */
#custom-confirm-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(30, 34, 40, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

/* Modal Box */
#custom-confirm-overlay .custom-confirm-modal {
    background: #fff;
    padding: 2.2em 2.5em 2em 2.5em;
    border-radius: 12px;
    max-width: 370px;
    width: 92vw;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    position: relative;
    animation: fadeInScale 0.25s;
}

/* Title */
#custom-confirm-overlay .custom-confirm-title {
    font-weight: 700;
    color: #d32f2f;
    font-size: 1.25em;
    margin-bottom: 0.7em;
    letter-spacing: 0.01em;
}

/* Subtitle */
#custom-confirm-overlay .custom-confirm-subtitle {
    font-weight: 400;
    color: #444;
    font-size: 1em;
    margin-bottom: 1.5em;
    display: block;
}

/* Buttons */
#custom-confirm-overlay .menu-btn {
    min-width: 120px;
    padding: 0.6em 1.2em;
    font-size: 1em;
    border-radius: 6px;
    border: none;
    margin: 0 0.3em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

#custom-confirm-overlay .archive-btn {
    background: #626667;
    color: #fff;
}
#custom-confirm-overlay .archive-btn:hover {
    background: #262524;
}

#custom-confirm-overlay .cancel-btn {
    background: #e0e0e0;
    color: #444;
}
#custom-confirm-overlay .cancel-btn:hover {
    background: #bdbdbd;
    color: #222;
}
/* --- Custom Confirm Deletion Button for Threads --- */
#custom-confirm-delete-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(30, 34, 40, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

/* Modal Box */
#custom-confirm-delete-overlay .custom-confirm-modal {
    background: #fff;
    padding: 2.2em 2.5em 2em 2.5em;
    border-radius: 12px;
    max-width: 370px;
    width: 92vw;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    position: relative;
    animation: fadeInScale 0.25s;
}

/* Title */
#custom-confirm-delete-overlay .custom-confirm-title {
    font-weight: 700;
    color: #d32f2f;
    font-size: 1.25em;
    margin-bottom: 0.7em;
    letter-spacing: 0.01em;
}

/* Subtitle */
#custom-confirm-delete-overlay .custom-confirm-subtitle {
    font-weight: 400;
    color: #444;
    font-size: 1em;
    margin-bottom: 1.5em;
    display: block;
}

/* Buttons */
#custom-confirm-delete-overlay .menu-btn {
    min-width: 120px;
    padding: 0.6em 1.2em;
    font-size: 1em;
    border-radius: 6px;
    border: none;
    margin: 0 0.3em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

#custom-confirm-delete-overlay .archive-btn {
    background: #626667;
    color: #fff;
}
#custom-confirm-delete-overlay .archive-btn:hover {
    background: #262524;
}

#custom-confirm-delete-overlay .cancel-btn {
    background: #e0e0e0;
    color: #444;
}
#custom-confirm-delete-overlay .cancel-btn:hover {
    background: #bdbdbd;
    color: #222;
}
.read-indicator {
  margin-left: 0.5em;
  font-size: 1.1em;
  vertical-align: middle;
}
/* Add this CSS for mobile responsiveness - Used in archived_threads.php */
@media (max-width: 700px) {
  .grid-container-messages {
    padding: 0 2vw;
    overflow-x: auto;
  }
  .archived-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 1em;
    font-size: 0.98em;
    background: none;
  }
  .archived-table thead {
    display: none;
  }
  .archived-table tr {
    display: block;
    margin-bottom: 1.2em;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 1em 0.7em;
  }
  .archived-table td {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
    background-color: #cac4b3;
    border: none;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 1em;
    width: 100%;
  }
  .archived-table td:before {
    content: attr(data-label);
    font-weight: bold;
    color: #030303;
    flex-basis: 20%;
    text-align: left;
    padding-right: 1em;
  }
  .archived-table td:last-child {
    flex-direction: row;
    gap: 5px;
    justify-content: flex-start;
    align-items: center;
    background-color: transparent;
  }
  #custom-alert-restore > div,
  #custom-alert-delete > div {
    width: 95vw;
    max-width: 350px;
    padding: 1.2em 0.5em 1em 0.5em;
  }
  .archived-table .hide-mobile,
  .archived-table th.hide-mobile,
  .archived-table td.hide-mobile {
    display: none !important;
  }
}
@media (max-width: 700px) {
    .admin-thread-list-mobile {
        width: 100vw;
        min-width: 0;
        margin-left: -2vw;
        margin-right: -2vw;
        box-sizing: border-box;
        padding: 0 0.5em;
        overflow-x: hidden;
    }
    .admin-thread-card {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        margin-bottom: 1em;
        border-radius: 8px;
        background: #f9f9f9;
        box-shadow: 0 2px 8px rgba(0,0,0,0.07);
        padding: 1em 0.7em 0.7em 0.7em;
        position: relative;
    }
    .admin-thread-card-row-main {
        display: flex;
        align-items: center;
        gap: 0.7em;
        min-width: 0;
        margin-bottom: 0.4em;
    }
    .admin-thread-icon {
        font-size: 1.3em;
        flex-shrink: 0;
    }
    .admin-thread-subject {
        font-weight: bold;
        color: #222;
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }
    .admin-thread-card-row-meta {
        display: flex;
        align-items: center;
        gap: 0.7em;
        font-size: 0.98em;
        color: #888;
        margin-bottom: 0.5em;
        flex-wrap: wrap;
    }
    .admin-thread-unread-badge {
        background: #e53935;
        color: #fff;
        border-radius: 1em;
        font-size: 0.95em;
        padding: 0.1em 0.7em;
        font-weight: bold;
        margin-left: 0.2em;
    }
    .admin-archive-thread-mobile-form {
        margin-top: 0.7em;
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
    .admin-archive-btn-mobile {
        width: 100%;
        max-width: 180px;
        padding: 0.6em 0;
        font-size: 1em;
        background: #6c6b68;
        color: #fff;
        border: none;
        border-radius: 5px;
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(25,118,210,0.10);
        cursor: pointer;
        transition: background 0.2s;
    }
    .admin-archive-btn-mobile:hover,
    .admin-archive-btn-mobile:focus {
        background: #353433;
    }
}