/* Chat modal compacto en ficha de propiedad */
.kasalia-chat-modal-root {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.kasalia-chat-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    cursor: pointer;
}

.kasalia-chat-modal-root.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.kasalia-chat-modal__panel {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    /* Más alto útil cuando hay cualificación + CTAs; el hilo hace scroll, el composer no se recorta */
    max-height: min(85vh, calc(100vh - 24px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.kasalia-chat-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #f8faf8 0%, #fff 100%);
    flex-shrink: 0;
}

.kasalia-chat-modal__head h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
}

.kasalia-chat-modal__sub {
    margin: 4px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.kasalia-chat-modal__head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.kasalia-chat-modal__link-full {
    font-size: 12px;
    font-weight: 700;
    color: #166534;
    text-decoration: none;
    white-space: nowrap;
}

.kasalia-chat-modal__link-full:hover {
    text-decoration: underline;
}

.kasalia-chat-modal__close {
    border: none;
    background: #e8eaed;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kasalia-chat-modal__close:hover {
    background: #e2e8f0;
}

.kasalia-chat-modal__thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
}

.kasalia-chat-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: #1e293b;
}

.kasalia-chat-msg.me {
    align-self: flex-end;
    margin-left: auto;
    background: rgba(22, 101, 52, 0.09);
    border-color: rgba(22, 101, 52, 0.2);
}

.kasalia-chat-msg .kasalia-chat-msg__body {
    white-space: pre-wrap;
    word-break: break-word;
}

.kasalia-chat-msg .kasalia-chat-msg__ts {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
}

.kasalia-chat-msg.me .kasalia-chat-msg__ts {
    display: block;
    text-align: right;
    width: 100%;
}

.kasalia-chat-msg--system {
    align-self: center;
    max-width: 95%;
    background: #f1f5f9;
    border-style: dashed;
    font-size: 12px;
    color: #64748b;
}

.kasalia-chat-modal__composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 12px 14px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.kasalia-chat-modal__composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
}

.kasalia-chat-modal__send {
    flex-shrink: 0;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #166534, #15803d);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
}

.kasalia-chat-modal__send:hover {
    filter: brightness(1.05);
}

.kasalia-chat-modal__send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.kasalia-chat-modal__hint {
    margin: 0;
    padding: 12px 16px 16px;
    font-size: 14px;
    font-weight: 700;
    color: #475569;
    text-align: center;
    flex-shrink: 0;
}

.kasalia-chat-modal__hint a {
    color: #166534;
    font-weight: 800;
}

.kasalia-chat-modal__status {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #b45309;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    flex-shrink: 0;
}

/* Panel usuario: por encima de aside / overlays del dashboard */
.kasalia-chat-modal-root--usuario-panel {
    z-index: 10080;
}

/* Misma tipografía que el resto del portal en el modal del panel */
.kasalia-chat-modal-root--usuario-panel .kasalia-chat-modal__panel {
    font-family: "Inter", "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Cualificación de lead + respuestas rápidas */
.kasalia-chat-lead,
.kasalia-chat-quick,
.kasalia-chat-contact {
    padding: 10px 14px 0;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    max-height: min(220px, 40vh);
    overflow-y: auto;
}

.kasalia-chat-lead[hidden],
.kasalia-chat-quick[hidden],
.kasalia-chat-contact[hidden] {
    display: none !important;
}

.kasalia-chat-lead__title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 800;
    color: #0f172a;
}

.kasalia-chat-lead__q {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    line-height: 1.35;
}

.kasalia-chat-lead__opts,
.kasalia-chat-quick__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.kasalia-chat-chip {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1.2;
}

.kasalia-chat-chip:hover {
    border-color: #166534;
    color: #166534;
}

.kasalia-chat-chip--conversion {
    border-color: rgba(22, 101, 52, 0.35);
    background: rgba(22, 101, 52, 0.06);
}

.kasalia-chat-quick__label {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.kasalia-chat-contact__title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
}

.kasalia-chat-contact input[type="tel"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    font-weight: 600;
    margin-bottom: 8px;
}

.kasalia-chat-contact__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.kasalia-chat-contact__actions button {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    font-weight: 800;
    cursor: pointer;
}

.kasalia-chat-contact__actions a.kasalia-chat-contact__save {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

.kasalia-chat-contact__save {
    background: linear-gradient(135deg, #166534, #15803d);
    color: #fff;
}

.kasalia-chat-contact__cancel {
    background: #e2e8f0;
    color: #334155;
}
