/* ==========================================
   MESSAGES INBOX MODULE
   ========================================== */

.messages-inbox-container {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.messages-header h2 {
    margin: 0;
    font-size: 18px;
    color: #1a1a2e;
}

.messages-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.messages-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.unread-indicator {
    background: #e74c3c;
    color: #fff;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    display: none;
}

.msg-filter-select {
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

.btn-sync {
    padding: 6px 14px;
    border: 1px solid #0050b3;
    background: #fff;
    color: #0050b3;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sync:hover {
    background: #0050b3;
    color: #fff;
}

.btn-sync.syncing {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================
   LAYOUT 2 COLONNE
   ========================================== */

.messages-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Colonna Conversazioni */
.conversations-panel {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.conversations-search {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.msg-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.msg-search-input:focus {
    border-color: #0050b3;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

/* Singola conversazione */
.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
    gap: 10px;
}

.conversation-item:hover {
    background: #f5f8ff;
}

.conversation-item.active {
    background: #ecf4fc;
    border-left: 3px solid #0050b3;
}

.conversation-item.has-unread {
    background: #fefcf0;
}

.conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.conv-avatar.booking { background: #003580; }
.conv-avatar.airbnb { background: #FF5A5F; }
.conv-avatar.expedia { background: #00355F; }
.conv-avatar.direct { background: #0050b3; }

.conv-info {
    flex: 1;
    min-width: 0;
}

.conv-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-preview {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.conv-meta {
    text-align: right;
    flex-shrink: 0;
}

.conv-time {
    font-size: 11px;
    color: #999;
}

.conv-unread-badge {
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
}

/* ==========================================
   CHAT PANEL
   ========================================== */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.chat-header {
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-guest-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.chat-source-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-left: 8px;
}

.chat-source-badge.booking { background: #003580; }
.chat-source-badge.airbnb { background: #FF5A5F; }
.chat-source-badge.expedia { background: #00355F; }
.chat-source-badge.direct { background: #0050b3; }

.chat-booking-info {
    font-size: 12px;
    color: #888;
}

/* Messaggi */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.msg-bubble.incoming {
    background: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.msg-bubble.outgoing {
    background: #0050b3;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.6;
}

.msg-bubble.outgoing .msg-time {
    text-align: right;
    color: rgba(255,255,255,0.7);
}

/* Input area */
.chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.msg-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 100px;
}

.msg-input:focus {
    border-color: #0050b3;
}

.btn-send {
    padding: 10px 20px;
    background: #0050b3;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-send:hover {
    background: #003d8a;
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Loading */
.loading-placeholder {
    padding: 40px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    .messages-layout {
        flex-direction: column;
    }
    .conversations-panel {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    .msg-bubble {
        max-width: 85%;
    }
}
