/**
 * Silva Customer Portal - Messages Styles
 * 
 * Styling for messaging interface, thread list, and conversation view
 * 
 * @package Silva_Customer_Portal
 * @version 2.5.0
 */

/* ========== Messages Container Layout ========== */
#messages-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 12px;
    height: calc(100vh - 220px);
    min-height: 500px;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    width: 100%;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    #messages-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 180px);
        gap: 0;
        padding-bottom: 100px;
    }
    
    #messages-container.thread-open #threads-panel {
        display: none;
    }
    
    #messages-container:not(.thread-open) #conversation-panel {
        display: none !important;
    }
}

/* ========== Threads Panel ========== */
#threads-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.threads-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #2271b1 0%, #1a5a8e 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.threads-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.threads-actions {
    display: flex;
    gap: 8px;
}

.threads-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.threads-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

#message-threads-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
}

/* ========== Thread Items ========== */
.message-thread-item {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    background: #f8f9fa;
}

.message-thread-item:hover {
    background: #e8f0fe;
    border-color: #2271b1;
}

.message-thread-item.active {
    background: #e8f0fe;
    border-color: #2271b1;
    box-shadow: 0 2px 4px rgba(34, 113, 177, 0.1);
}

.message-thread-item.has-unread {
    background: #fff;
    border-color: #00a32a;
}

.thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.thread-subject {
    font-weight:3px;
    color: #1e1e1e;
    flex: 1;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word
    line-height: 1.4;
}

.unread-badge {
    background: #00a32a;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    display: inline-block;
}

.thread-job-label {
    display: inline-block;
    background: #2271b1;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    margin-bottom: 6px;
}

.thread-preview {
    font-size: 13px;
    color: #646970;
    line-height: 1.4;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #999;
}

/* ========== No Threads State ========== */
.no-threads {
    text-align: center;
    padding: 60px 20px;
    color: #646970;
}

.no-threads-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-threads p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ========== Conversation Panel ========== */
#conversation-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
2px 14px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.conversation-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #1e1e1e;
    word-break: break-word;
    overflow-wrap: break-wordx 0;
    font-size: 18px;
    color: #1e1e1e;
}

#conversation-job-link {
    font-size: 13px;
    color: #2271b1;
}

#conversation-job-link a {
    color: #2271b1;
    text-decoration: none;
}

#conversation-job-link a:hover {
    text-decoration: underline;
}

#back-to-threads-btn {
    display: none;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    #back-to-threads-btn {
        display: inline-block;
    }
}

/* =overflow-x: hidden;
    padding: 12px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-messages {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}
80%;
    animation: messageSlide 0.3s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    .message-item {
        max-width: 85%;
    }
.message-item {
    max-width: 75%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-customer {
    align-self: flex-end;
    margin-left: auto;
}

.message-admin {
    align-self: flex-start;
    margin-right: auto;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 12px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #646970;
}

.message-time {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.message-body {
    background: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #1e1e1e;
    word-wrap: break-word;
    border: 1px solid #e0e0e0;
}

.message-customer .message-body {
    background: #e8f0fe;
    border-color: #2271b1;
}

.message-admin .message-body {
    background: #fff;
    border-color: #e0e0e0;
}

/* ========== Message Input ========== */
.message-input-container {
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

.message-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 44px;
    max-height: 150px;
    transition: border-color 0.2s;
}

#message-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

#send-message-btn {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#send-message-btn:hover:not(:disabled) {
    background: #1a5a8e;
}

#send-message-btn:disabled {
    background: #999;
    cursor: not-allowed;
}

/* ========== Loading States ========== */
#threads-loading,
#messages-loading {
    padding: 40px;
    text-align: center;
    color: #646970;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite; /* Animation defined in base.css */
    margin: 0 auto 12px;
}

#threads-error {
    padding: 16px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    margin: 12px;
    font-size: 14px;
}

/* ========== Modal Styles ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-messages);
    animation: fadeIn 0.2s; /* Animation defined in base.css */
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
}

.modal-close:hover {
    color: #1e1e1e;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== Form Controls ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: #1e1e1e;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* ========== Buttons ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(180deg, #014385 0%, #012f6b 100%) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(1, 67, 133, 0.15);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #01356a 0%, #012951 100%) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(1, 67, 133, 0.2);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background: transparent;
    color: #014385;
    border: 1px solid #d0d7e2;
}

.btn-secondary:hover {
    background: #f3f7ff;
    border-color: #014385;
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== Unread Badge in Tab ========== */
#messages-tab-badge {
    display: none;
    background: #d63638;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    min-width: 18px;
    text-align: center;
}

/* ========== Scrollbar Styling ========== */
#message-threads-list::-webkit-scrollbar,
#messages-list::-webkit-scrollbar {
    width: 8px;
}

#message-threads-list::-webkit-scrollbar-track,
#messages-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#message-threads-list::-webkit-scrollbar-thumb,
#messages-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#message-threads-list::-webkit-scrollbar-thumb:hover,
#messages-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
