/* Paleta tomada de WhatsApp Web real: verde oscuro de header, fondo de chat con
   patrón beige claro, burbujas verde claro (salientes) y blancas (entrantes). */

.wa-shell {
    display: flex;
    height: calc(100vh - 60px); /* ajustá el 60px si tu topbar del CRM mide distinto */
    background: #fff;
    border-top: 1px solid #d1d7db;
    font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* -------- Sidebar -------- */
.wa-sidebar {
    width: 32%;
    min-width: 300px;
    max-width: 420px;
    border-right: 1px solid #d1d7db;
    display: flex;
    flex-direction: column;
}

.wa-sidebar-header {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wa-title {
    font-size: 19px;
    font-weight: 600;
    color: #111b21;
}

.wa-search-box {
    padding: 8px 12px;
    background: #fff;
}

    .wa-search-box input {
        width: 100%;
        background: #f0f2f5;
        border: none;
        border-radius: 8px;
        padding: 9px 12px;
        font-size: 14px;
        outline: none;
    }

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

.wa-conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
}

    .wa-conversation-item:hover {
        background: #f5f6f6;
    }

    .wa-conversation-item.selected {
        background: #f0f2f5;
    }

.wa-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #dfe5e7;
    color: #54656f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    margin-right: 14px;
}

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

.wa-conversation-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.wa-contact-name {
    font-size: 15px;
    color: #111b21;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-time {
    font-size: 12px;
    color: #667781;
    flex-shrink: 0;
    margin-left: 6px;
}

.wa-conversation-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.wa-preview {
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-typing-preview {
    color: #25d366;
    font-style: normal;
}

.wa-unread-badge {
    background: #25d366;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 8px;
}

.wa-pin-icon {
    font-size: 12px;
    margin-left: 6px;
    opacity: .7;
}

.wa-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #667781;
    font-size: 14px;
}

/* -------- Panel de chat -------- */
.wa-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    background-image: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,.55));
}

.wa-no-selection {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #667781;
}

.wa-no-selection-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.wa-chat-header {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #d1d7db;
}

.wa-chat-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wa-chat-subtitle {
    font-size: 12px;
    color: #667781;
}

.wa-header-actions {
    display: flex;
    gap: 6px;
}

.wa-icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #54656f;
    padding: 6px;
    border-radius: 50%;
    line-height: 1;
}

    .wa-icon-btn:hover {
        background: rgba(0,0,0,.05);
    }

    .wa-icon-btn.active {
        background: #d9fdd3;
    }

/* -------- Mensajes -------- */
.wa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 6% 8px;
}

.wa-load-more {
    text-align: center;
    font-size: 12px;
    color: #667781;
    padding: 8px;
}

.wa-load-more-link {
    cursor: pointer;
    color: #008069;
    font-weight: 600;
}

.wa-date-separator {
    text-align: center;
    margin: 14px 0;
}

    .wa-date-separator span {
        background: #e1f2fb;
        color: #54656f;
        font-size: 12px;
        padding: 5px 12px;
        border-radius: 8px;
    }

.wa-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 4px;
}

    .wa-bubble-row.outbound {
        justify-content: flex-end;
    }

    .wa-bubble-row.inbound {
        justify-content: flex-start;
    }

.wa-bubble {
    max-width: 65%;
    padding: 6px 9px;
    border-radius: 8px;
    box-shadow: 0 1px .5px rgba(0,0,0,.13);
    position: relative;
}

.wa-bubble-row.outbound .wa-bubble {
    background: #d9fdd3;
}

.wa-bubble-row.inbound .wa-bubble {
    background: #fff;
}

.wa-bubble-text {
    font-size: 14.2px;
    color: #111b21;
    white-space: pre-wrap;
    word-break: break-word;
}

.wa-reply-preview {
    border-left: 3px solid #25d366;
    background: rgba(0,0,0,.04);
    padding: 4px 8px;
    font-size: 12.5px;
    color: #667781;
    margin-bottom: 4px;
    border-radius: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-bubble-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.wa-bubble-time {
    font-size: 11px;
    color: #667781;
}

.wa-ticks {
    font-size: 13px;
    color: #667781;
}

.wa-ticks-read {
    color: #53bdeb;
}

.wa-media-image {
    max-width: 100%;
    border-radius: 6px;
    display: block;
    margin-bottom: 4px;
}

.wa-media-file {
    display: block;
    color: #008069;
    font-size: 13.5px;
    text-decoration: none;
    margin-bottom: 4px;
}

.wa-reply-btn {
    background: none;
    border: none;
    color: #667781;
    cursor: pointer;
    opacity: 0;
    font-size: 14px;
    transition: opacity .15s;
}

.wa-bubble-row:hover .wa-reply-btn {
    opacity: 1;
}

/* -------- Barra de "respondiendo a" -------- */
.wa-reply-bar {
    background: #f0f2f5;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #d1d7db;
}

.wa-reply-bar-text {
    font-size: 13px;
    color: #54656f;
    border-left: 3px solid #25d366;
    padding-left: 8px;
}

/* -------- Barra de entrada -------- */
.wa-input-bar {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wa-file-input {
    display: none;
}

.wa-text-input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
}

.wa-send-btn {
    background: #00a884;
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

    .wa-send-btn:disabled {
        opacity: .5;
        cursor: default;
    }

.wa-pending-file {
    background: #f0f2f5;
    padding: 6px 16px;
    font-size: 13px;
    color: #54656f;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .wa-pending-file button {
        background: none;
        border: none;
        cursor: pointer;
        color: #667781;
    }

/* -------- Responsive (mismo criterio que el resto del CRM) --------
   En mobile se muestra UNA columna a la vez, igual que WhatsApp: la lista
   hasta que se elige una conversación, después el chat con botón "←" para
   volver (wa-back-btn, oculto en desktop). */
.wa-back-btn {
    display: none;
}

@media (max-width: 768px) {
    .wa-shell {
        flex-direction: column;
        height: calc(100vh - 56px);
    }

    .wa-sidebar {
        width: 100%;
        max-width: none;
        height: 100%;
    }

    .wa-chat-panel {
        display: none;
    }

    .wa-shell.wa-has-selection .wa-sidebar {
        display: none;
    }

    .wa-shell.wa-has-selection .wa-chat-panel {
        display: flex;
    }

    .wa-back-btn {
        display: inline-block;
    }
}

/* -------- Multi-línea -------- */
.wa-session-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
    overflow-x: auto;
}

.wa-session-tab {
    background: #f0f2f5;
    border: none;
    border-radius: 14px;
    padding: 5px 12px;
    font-size: 12.5px;
    color: #54656f;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

    .wa-session-tab.active {
        background: #00a884;
        color: #fff;
        font-weight: 600;
    }

.wa-session-badge {
    font-size: 11px;
    color: #667781;
    background: #f0f2f5;
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    margin-top: 2px;
}

/* -------- Bot / Humano -------- */
.wa-bot-toggle {
    border: none;
    border-radius: 14px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

    .wa-bot-toggle.bot-on {
        background: #d9fdd3;
        color: #016a3e;
    }

    .wa-bot-toggle.bot-off {
        background: #fde8d9;
        color: #a34c02;
    }

.wa-human-badge {
    font-size: 11px;
    color: #a34c02;
    background: #fde8d9;
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    margin-top: 2px;
    font-weight: 600;
}

/* -------- Nota de voz estilo WhatsApp -------- */
.wa-voice-note {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,.03);
    border-radius: 20px;
    padding: 4px 10px;
    margin-bottom: 4px;
}

.wa-voice-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.wa-voice-note audio {
    height: 32px;
    max-width: 220px;
}
