/* css/messages.css */

#messages-list {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.messages-mobile-list-header {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 4px;
    border-bottom: 1px solid var(--border);
}

.messages-mobile-list-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.messages-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.messages-list-actions .messages-new-btn {
    flex: 1 1 auto;
}

.messages-list-actions .messages-exit-btn {
    flex: 0 0 auto;
}

#messages-thread-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.messages-content-host {
    height: 100%;
}

#messages-list .message-thread-item {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    position: relative;
}

#messages-list .message-thread-item:hover {
    background: var(--bg-hover);
}

#messages-list .message-thread-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--accent);
}

#messages-list .message-thread-item.unread {
    border-left: 3px solid var(--accent);
}

#messages-list .message-thread-item.unread:not(.active) {
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel) 88%);
}

.thread-subject {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 30px;
}

.unread-subject {
    font-weight: 900;
}

.thread-participants {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-preview {
    font-size: 0.8em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-preview {
    color: var(--text);
    font-weight: 700;
}

.thread-date {
    font-size: 0.75em;
    color: var(--text-muted);
    float: right;
}

.message-thread-clear {
    clear: both;
}

.thread-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 700;
    opacity: 0;
    transition: all 0.2s;
    background: color-mix(in srgb, var(--bg-dark) 80%, transparent 20%);
}

.message-thread-item:hover .thread-delete-btn {
    opacity: 1;
}

.thread-delete-btn:hover {
    background: var(--btn-red);
    color: #fff;
}

.compose-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    background: var(--bg-dark);
}

.compose-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.compose-field label {
    font-size: 0.9em;
    color: var(--text-muted);
    font-weight: 700;
}

.compose-input,
.compose-textarea {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px;
    border-radius: 4px;
    font-family: inherit;
}

.compose-textarea {
    flex: 1;
    resize: none;
}

.messages-compose-actions {
    text-align: right;
}

.messages-recipient-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.messages-recipient-tag {
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.messages-recipient-remove {
    cursor: pointer;
    font-weight: 700;
}

.thread-view-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.thread-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}

.thread-header h2 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
}

.thread-header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.thread-header-top h2 {
    margin: 0;
}

.thread-header .participants-list {
    font-size: 0.9em;
    color: var(--text-muted);
}

.messages-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message-bubble {
    background: color-mix(in srgb, var(--bg-panel) 84%, #5a6070 16%);
    padding: 12px;
    border-radius: 8px;
    max-width: 80%;
    align-self: flex-start;
    border: 1px solid var(--border);
}

.message-bubble.mine {
    background: color-mix(in srgb, var(--accent) 30%, var(--bg-panel) 70%);
    align-self: flex-end;
}

.message-author {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 700;
}

.message-bubble.mine .message-author {
    color: var(--text);
    text-align: right;
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.4;
    color: var(--text);
}

.message-time {
    font-size: 0.7em;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: right;
}

.reply-area {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
    display: flex;
    gap: 10px;
}

.reply-input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 4px;
    resize: none;
    height: 40px;
}

.autocomplete-suggestions {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    max-height: 150px;
    overflow-y: auto;
    width: 300px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:hover {
    background: var(--accent);
    color: #fff;
}

.invite-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.invite-actions .btn {
    padding: 4px 8px;
    font-size: 0.8em;
}

.invite-status {
    margin-top: 8px;
    font-size: 0.75em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.invite-status.invite-accepted {
    color: #4caf50;
}

.invite-status.invite-rejected {
    color: #f56c6c;
}

.invite-status.invite-cancelled {
    color: var(--text-muted);
}

.invite-status.invite-pending {
    color: #e6a23c;
}

.message-content-state {
    padding: 20px;
    color: var(--text-muted);
}

.message-content-state.error {
    color: var(--btn-red);
}

body.light-theme .message-bubble {
    background: color-mix(in srgb, var(--bg-panel) 88%, #d6deea 12%);
}

body.light-theme .message-bubble.mine {
    background: color-mix(in srgb, var(--accent) 16%, #ffffff 84%);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
}

@media (max-width: 900px) {
    .messages-mobile-list-header.mobile-only {
        display: flex !important;
    }

    .messages-list-actions .messages-exit-btn.mobile-only {
        display: inline-flex !important;
    }
}
