/* EF WA CRM - Messages View */

.ef-wa-crm-messages-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--background-secondary);
    overflow: hidden;
}

.ef-wa-crm-messages-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ef-wa-crm-messages-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.ef-wa-crm-messages-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.ef-wa-crm-messages-header-info p {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* Legacy view header - hidden */
.ef-wa-crm-view-header {
    display: none;
}

.ef-wa-crm-back-btn {
    display: none;
}

.ef-wa-crm-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--background-secondary);
    /* Use flex to fill available space */
}

.ef-wa-crm-message-item {
    display: flex;
    margin: 0;
}

.ef-wa-crm-message-item[data-direction="inbound"] {
    justify-content: flex-start;
}

.ef-wa-crm-message-item[data-direction="outbound"] {
    justify-content: flex-end;
}

.ef-wa-crm-message-content {
    max-width: 75%;
    position: relative;
    word-wrap: break-word;
}

.ef-wa-crm-message-item[data-direction="inbound"] .ef-wa-crm-message-content {
    background: var(--surface-color);
    color: var(--text-primary);
    border-radius: 12px 12px 12px 2px;
    padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.ef-wa-crm-message-item[data-direction="outbound"] .ef-wa-crm-message-content {
    background: #afca0b47;
    color: white;
    border-radius: 12px 12px 2px 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    position: relative;
}

.ef-wa-crm-message-item[data-direction="inbound"] .ef-wa-crm-message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-right-color: var(--surface-color);
    border-bottom-color: var(--surface-color);
    border-left: none;
    border-top: none;
}

.ef-wa-crm-message-item[data-direction="outbound"] .ef-wa-crm-message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-left-color: #afca0b47;
    border-bottom-color: #afca0b47;
    border-right: none;
    border-top: none;
}

.ef-wa-crm-message-text {
    margin: 0 0 4px 0;
    line-height: 1.4;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ef-wa-crm-message-meta {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
    margin-top: 2px;
}

.ef-wa-crm-message-time {
    font-weight: 400;
}

.ef-wa-crm-message-type {
    display: none;
}

/* Message date separators - WhatsApp style */
.ef-wa-crm-message-date-separator {
    text-align: center;
    margin: 15px 0 10px 0;
}

.ef-wa-crm-message-date-text {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

/* Empty state */
.ef-wa-crm-messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
}

.ef-wa-crm-messages-empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.ef-wa-crm-messages-empty-text {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.ef-wa-crm-messages-empty-subtext {
    font-size: 14px;
    opacity: 0.7;
    max-width: 300px;
    line-height: 1.4;
}

/* Scrollbar Styling */
.ef-wa-crm-messages-container::-webkit-scrollbar {
    width: 6px;
}

.ef-wa-crm-messages-container::-webkit-scrollbar-track {
    background: var(--background-color);
}

.ef-wa-crm-messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.ef-wa-crm-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Message Input Container */
.ef-wa-crm-message-input-container {
    padding: 12px 20px;
    background: var(--background-secondary);
    border-top: 1px solid #333335;
    flex-shrink: 0;
}

.ef-wa-crm-message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 100%;
}

.ef-wa-crm-message-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    padding: 12px 16px;
    background: var(--surface-color);
    border: 1px solid #333335;
    border-radius: 21px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.ef-wa-crm-message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ef-wa-crm-message-input::placeholder {
    color: var(--text-secondary);
}

.ef-wa-crm-send-button {
    width: 42px;
    height: 42px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ef-wa-crm-send-button:hover {
    background: #9bb009;
    transform: scale(1.05);
}

.ef-wa-crm-send-button:active {
    transform: scale(0.95);
}

.ef-wa-crm-send-button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

.ef-wa-crm-send-button svg {
    width: 18px;
    height: 18px;
}

/* Disabled input state */
.ef-wa-crm-message-input-container.ef-wa-crm-input-disabled {
    opacity: 0.6;
}

.ef-wa-crm-message-input-container.ef-wa-crm-input-disabled .ef-wa-crm-message-input {
    background: var(--surface-dark);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.ef-wa-crm-message-input-container.ef-wa-crm-input-disabled .ef-wa-crm-message-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.ef-wa-crm-message-input-container.ef-wa-crm-input-disabled .ef-wa-crm-send-button {
    background: #444 !important;
    cursor: not-allowed !important;
}