/* Message Thread Page Styles */

.message-thread-container {
    padding: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

/* Back Button */
.thread-back {
    margin-bottom: 1.5rem;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Thread Header */
.thread-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.thread-header__sender {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sender-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.sender-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.thread-subject {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Messages */
.thread-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.thread-message {
    display: flex;
    width: 100%;
}

.thread-message--sender {
    justify-content: flex-end;
}

.thread-message--admin {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem;
    border-radius: 12px;
    position: relative;
}

.thread-message--sender .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.thread-message--admin .message-bubble {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    display: block;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* Reply Form */
.thread-reply {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.reply-input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reply-textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.reply-textarea::placeholder {
    color: var(--text-tertiary);
}

.btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-end;
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-send:active {
    transform: translateY(0);
}

/* Scrollbar Styling */
.thread-messages::-webkit-scrollbar {
    width: 8px;
}

.thread-messages::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 4px;
}

.thread-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.thread-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .message-thread-container {
        padding: 1rem;
    }

    .thread-header {
        padding: 1rem;
    }

    .sender-avatar {
        width: 48px;
        height: 48px;
    }

    .sender-info h3 {
        font-size: 1.125rem;
    }

    .thread-subject {
        font-size: 1rem;
    }

    .message-bubble {
        max-width: 85%;
    }

    .thread-messages {
        max-height: 400px;
        padding: 0.75rem;
    }

    .thread-reply {
        padding: 1rem;
    }

    .btn-send {
        width: 100%;
    }
}

/* RTL Support */
[dir="rtl"] .thread-message--sender {
    justify-content: flex-start;
}

[dir="rtl"] .thread-message--admin {
    justify-content: flex-end;
}

[dir="rtl"] .thread-message--sender .message-bubble {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .thread-message--admin .message-bubble {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}
