.madify-wapp-panel {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #111827;
}

.madify-wapp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff, #f9fafb);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.madify-wapp-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.madify-wapp-header p,
.madify-wapp-muted {
    margin: 6px 0 0;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.45;
}

.madify-wapp-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 9px 12px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.madify-wapp-status[data-status="open"],
.madify-wapp-status[data-status="connected"] {
    background: #dcfce7;
    color: #166534;
}

.madify-wapp-status[data-status="close"],
.madify-wapp-status[data-status="desconectado"],
.madify-wapp-status[data-status="desconocido"] {
    background: #fee2e2;
    color: #991b1b;
}

.madify-wapp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.madify-wapp-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.06);
}

.madify-wapp-card.full {
    grid-column: 1 / -1;
}

.madify-wapp-card h4 {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.madify-wapp-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.madify-wapp-row span {
    color: #6b7280;
}

.madify-wapp-row strong {
    color: #111827;
    text-align: right;
}

.madify-wapp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.madify-wapp-btn {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.15s ease;
}

.madify-wapp-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.madify-wapp-btn.primary {
    border-color: #111827;
    background: #111827;
    color: #ffffff;
}

.madify-wapp-btn.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.madify-wapp-message {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
}

.madify-wapp-message.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.madify-wapp-message.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.madify-wapp-qr-box {
    min-height: 260px;
    border: 1px dashed #d1d5db;
    border-radius: 20px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    text-align: center;
    color: #6b7280;
    overflow: auto;
}

.madify-wapp-qr-box img {
    max-width: 240px;
    width: 100%;
    height: auto;
    border-radius: 16px;
    background: #ffffff;
    padding: 10px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.madify-wapp-test {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.madify-wapp-test input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
}

@media (max-width: 760px) {
    .madify-wapp-grid {
        grid-template-columns: 1fr;
    }

    .madify-wapp-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .madify-wapp-test {
        flex-direction: column;
    }
}

/* =========================================================
   CHAT FLOTANTE PROVEEDORES — APPLE STYLE LIMPIO
   ========================================================= */

.madify-wapp-floating-chat {
    position: fixed !important;
    right: 24px !important;
bottom: 34px !important;
z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

.madify-wapp-chat-toggle {
    position: relative !important;
    width: 64px !important;
    height: 64px !important;
    border: 0 !important;
    border-radius: 24px !important;
    background: linear-gradient(145deg, #0f172a, #111827) !important;
    color: #ffffff !important;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.30) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease !important;
}
.madify-wapp-chat-toggle:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.38) !important;
}

.madify-wapp-chat-toggle-icon {
    font-size: 28px !important;
    line-height: 1 !important;
    display: block !important;
}

.madify-wapp-chat-badge {
    display: none !important;
}
.madify-wapp-chat-toggle:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.38) !important;
}

.madify-wapp-chat-toggle::before {
    content: "💬" !important;
    font-size: 28px !important;
    line-height: 1 !important;
    display: block !important;
}

.madify-wapp-chat-toggle-icon {
    display: none !important;
}

.madify-wapp-chat-toggle-icon {
    font-size: 26px !important;
    line-height: 1 !important;
}

.madify-wapp-chat-badge {
    position: absolute !important;
    top: -7px !important;
    right: -7px !important;
    min-width: 22px !important;
    height: 22px !important;
    padding: 0 6px !important;
    border-radius: 999px !important;
    background: #ef4444 !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    line-height: 22px !important;
    border: 2px solid #ffffff !important;
}

.madify-wapp-chat-panel {
    position: fixed !important;
    right: 26px !important;
    bottom: 112px !important;
    top: auto !important;
    width: min(820px, calc(100vw - 360px)) !important;
    height: min(560px, calc(100vh - 170px)) !important;
    max-height: 560px !important;
    min-height: 430px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid rgba(229, 231, 235, 0.95) !important;
    border-radius: 26px !important;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24) !important;
    overflow: hidden !important;
    backdrop-filter: blur(18px) !important;
}

.madify-wapp-chat-shell {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 300px minmax(0, 1fr) !important;
    overflow: hidden !important;
}

.madify-wapp-chat-sidebar {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    border-right: 1px solid #e5e7eb !important;
    background: #f9fafb !important;
}

.madify-wapp-chat-sidebar-header {
    flex: 0 0 auto !important;
    padding: 20px 18px 14px !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
}

.madify-wapp-chat-sidebar-header h3,
.madify-wapp-chat-topbar h3 {
    margin: 0 !important;
    color: #111827 !important;
    font-size: 20px !important;
    font-weight: 900 !important;
    letter-spacing: -0.04em !important;
}

.madify-wapp-chat-sidebar-header p,
.madify-wapp-chat-topbar p {
    margin: 4px 0 0 !important;
    color: #6b7280 !important;
    font-size: 12px !important;
}

.madify-wapp-chat-icon-btn {
    width: 38px !important;
    height: 38px !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    color: #111827 !important;
    font-size: 18px !important;
    font-weight: 900 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.madify-wapp-chat-search {
    flex: 0 0 auto !important;
    padding: 0 18px 14px !important;
}

.madify-wapp-chat-search input {
    width: 100% !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 16px !important;
    padding: 13px 14px !important;
    font-size: 14px !important;
    outline: none !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

.madify-wapp-conversation-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 4px 10px 14px !important;
}

.madify-wapp-conversation-item {
    width: 100% !important;
    border: 0 !important;
    background: transparent !important;
    border-radius: 18px !important;
    padding: 12px !important;
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: center !important;
    cursor: pointer !important;
    text-align: left !important;
}

.madify-wapp-conversation-item:hover,
.madify-wapp-conversation-item.active {
    background: #ffffff !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06) !important;
}

.madify-wapp-conversation-avatar {
    width: 42px !important;
    height: 42px !important;
    border-radius: 15px !important;
    background: linear-gradient(145deg, #111827, #374151) !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 900 !important;
    font-size: 16px !important;
}

.madify-wapp-conversation-info {
    min-width: 0 !important;
}

.madify-wapp-conversation-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
}

.madify-wapp-conversation-row strong {
    color: #111827 !important;
    font-size: 13px !important;
    font-weight: 900 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.madify-wapp-conversation-row span {
    color: #9ca3af !important;
    font-size: 11px !important;
    flex: 0 0 auto !important;
}

.madify-wapp-conversation-preview {
    margin-top: 3px !important;
    color: #6b7280 !important;
    font-size: 12px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-transform: uppercase !important;
}

.madify-wapp-unread-pill {
    min-width: 22px !important;
    height: 22px !important;
    padding: 0 7px !important;
    border-radius: 999px !important;
    background: #10b981 !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 900 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.madify-wapp-chat-main {
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    background:
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.08), transparent 32%),
        linear-gradient(180deg, #ffffff, #f9fafb) !important;
}

.madify-wapp-chat-empty {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: #6b7280 !important;
    text-align: center !important;
    padding: 32px !important;
}

.madify-wapp-chat-empty-icon {
    width: 76px !important;
    height: 76px !important;
    border-radius: 26px !important;
    background: #f3f4f6 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 32px !important;
    margin-bottom: 16px !important;
}

.madify-wapp-chat-empty h3 {
    margin: 0 !important;
    font-size: 21px !important;
    color: #111827 !important;
    font-weight: 900 !important;
    letter-spacing: -0.03em !important;
}

.madify-wapp-chat-empty p {
    max-width: 360px !important;
    margin: 8px 0 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.madify-wapp-chat-active {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.madify-wapp-chat-topbar {
    flex: 0 0 auto !important;
    padding: 18px 20px !important;
    border-bottom: 1px solid #e5e7eb !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.88) !important;
}

.madify-wapp-message-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px 20px 24px !important;
}

.madify-wapp-message-row {
    display: flex !important;
    margin-bottom: 10px !important;
}

.madify-wapp-message-row.inbound {
    justify-content: flex-start !important;
}

.madify-wapp-message-row.outbound {
    justify-content: flex-end !important;
}

.madify-wapp-message-bubble {
    max-width: 72% !important;
    padding: 11px 13px 8px !important;
    border-radius: 18px !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06) !important;
}

.madify-wapp-message-row.inbound .madify-wapp-message-bubble {
    background: #ffffff !important;
    color: #111827 !important;
    border-bottom-left-radius: 6px !important;
}

.madify-wapp-message-row.outbound .madify-wapp-message-bubble {
    background: #111827 !important;
    color: #ffffff !important;
    border-bottom-right-radius: 6px !important;
}

.madify-wapp-message-text {
    font-size: 14px !important;
    line-height: 1.45 !important;
    white-space: pre-wrap !important;
}

.madify-wapp-message-time {
    margin-top: 5px !important;
    font-size: 10px !important;
    opacity: .62 !important;
    text-align: right !important;
}

.madify-wapp-chat-composer {
    flex: 0 0 auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    padding: 14px !important;
    border-top: 1px solid #e5e7eb !important;
    background: rgba(255, 255, 255, 0.98) !important;
}

.madify-wapp-chat-composer textarea {
    width: 100% !important;
    min-height: 48px !important;
    max-height: 96px !important;
    resize: none !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 18px !important;
    padding: 13px 14px !important;
    font-size: 14px !important;
    outline: none !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

.madify-wapp-chat-send {
    min-height: 48px !important;
    border: 0 !important;
    border-radius: 18px !important;
    padding: 0 22px !important;
    background: #111827 !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 900 !important;
    cursor: pointer !important;
    align-self: end !important;
}

.madify-wapp-chat-send:disabled {
    opacity: .55 !important;
    cursor: not-allowed !important;
}

.madify-wapp-empty-state {
    padding: 20px !important;
    color: #6b7280 !important;
    font-size: 13px !important;
    text-align: center !important;
}

/* Mobile / pantallas estrechas */
@media (max-width: 980px) {
    .madify-wapp-floating-chat {
        right: 14px !important;
        bottom: 14px !important;
    }

   .madify-wapp-chat-panel {
    left: 18px !important;
    right: 18px !important;
    top: 88px !important;
    bottom: 88px !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 22px !important;
}

   .madify-wapp-chat-shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(180px, 40%) minmax(0, 1fr) !important;
}

    .madify-wapp-chat-sidebar {
        border-right: 0 !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
}

/* FIX VISIBILIDAD CHAT */
.madify-wapp-hidden {
    display: none !important;
}

/* Tablet friendly */
@media (min-width: 768px) and (max-width: 1180px) {
    .madify-wapp-chat-panel {
        left: auto !important;
        right: 24px !important;
        bottom: 100px !important;
        top: auto !important;
        width: min(760px, calc(100vw - 340px)) !important;
        height: min(540px, calc(100vh - 160px)) !important;
        max-height: 540px !important;
    }

    .madify-wapp-chat-shell {
        grid-template-columns: 285px minmax(0, 1fr) !important;
    }
}

