/* ==========================================================
   CPTai Chat – Estilos diferidos (no bloquean el primer pintado)
   Contiene: FAB, Chat modal, MiniFichas, EmptyView, Tooltip
   ========================================================== */

/* === FAB estilo WhatsApp (verde original) + pill hover === */

:root {
    --cpt-gae-green: #20B038;
    --cpt-gae-green-hover: #1CA333;
    --cpt-gae-pill-bg: #D9FFE6;
    --cpt-gae-pill-text: #20B038;
}

/* Wrapper flotante */
.cpt-gae-fab-wrap {
    position: fixed;
    right: 36px;
    bottom: 36px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 1;
    transform: translateY(0);
    transition: opacity .16s ease, transform .16s ease;
}

/* Pill (oculto por defecto) */
.cpt-gae-fab-label {
    background: var(--cpt-gae-pill-bg);
    color: var(--cpt-gae-pill-text);
    font-weight: 800;
    font-size: 15.5px;
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: 0 14px 28px rgba(0,0,0,.20);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}

/* Botón */
.cpt-gae-fab {
    width: 60px;
    height: 60px;
    border-radius: 999px;
    border: 0;
    background: var(--cpt-gae-green);
    box-shadow: 0 18px 40px rgba(0,0,0,.28);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
    -webkit-tap-highlight-color: transparent;
}

/* Ícono SVG centrado */
.cpt-gae-fab svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

/* Hover / Focus: muestra pill + crece poquito */
.cpt-gae-fab-wrap:hover .cpt-gae-fab-label,
.cpt-gae-fab-wrap:focus-within .cpt-gae-fab-label {
    opacity: 1;
    transform: translateX(0);
}

.cpt-gae-fab-wrap:hover .cpt-gae-fab,
.cpt-gae-fab-wrap:focus-within .cpt-gae-fab {
    transform: scale(1.06);
    background: var(--cpt-gae-green-hover);
    box-shadow: 0 22px 46px rgba(0,0,0,.34);
}

/* Click feedback */
.cpt-gae-fab:active {
    transform: scale(1.02);
}

/* Accesibilidad: focus visible */
.cpt-gae-fab:focus-visible {
    outline: none;
    box-shadow: 0 22px 46px rgba(0,0,0,.34), 0 0 0 5px rgba(32,176,56,.28);
}

/* Mobile: ajusta posición/tamaño y oculta pill */
@media (max-width: 820px) {
    .cpt-gae-fab-wrap {
        right: 18px;
        bottom: 18px;
        gap: 10px;
    }

    .cpt-gae-fab {
        width: 58px;
        height: 58px;
    }

    .cpt-gae-fab svg {
        width: 28px;
        height: 28px;
    }

    .cpt-gae-fab-label {
        display: none;
    }
}

/* Ocultar FAB cuando el modal (popup) está abierto */
body.modal-open .cpt-gae-fab-wrap {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(10px) !important;
    pointer-events: none !important;
}

/* === Tooltip === */

.custom-tooltip {
    --bs-tooltip-bg: #20B038;
    --bs-tooltip-color: #FFFFFF;
}

/* === dxChat base === */

.dx-chat {
    max-width: 900px;
    width: 100%;
}

.chat-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* === MiniFichas (Carrusel) === */

/* Reset / scope */
#DEVxChatWebsite .cpt-mf-bubble,
#DEVxChatWebsite .cpt-mf-bubble * {
    box-sizing: border-box;
}

#DEVxChatWebsite .cpt-mf-bubble {
    --mf-text: #1f2937;
    --mf-muted: #6b7280;
    --mf-line: rgba(17,24,39,.10);
    --mf-radius: 18px;
    --mf-radius-card: 18px;
    --mf-shadow-card: 0 8px 18px rgba(0,0,0,.06);
    --mf-tag-sale: #6d28d9;
    --mf-tag-rent: #1d4ed8;

    margin: 0 auto;
    max-width: 100%;
    width: 548px;
}

#DEVxChatWebsite .cpt-mf-bubble {
    background: var(--cpt-AgentBackgroundColor);
    border: 1px solid var(--mf-line);
    border-radius: 16px;
    padding: 0px 12px 10px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

#DEVxChatWebsite .scrollHint {
    margin-top: 6px;
    font-size: 1.0rem;
    color: var(--cnvs-themecolor);
    display: flex;
    justify-content: flex-end;
    user-select: none;
}

/* Carrusel / lista de MiniFichas */
#DEVxChatWebsite .cardsWrap {
    box-sizing: border-box;
    margin-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    padding: 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    width: min(520px, 100%);
}

#DEVxChatWebsite .cardsTrack {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

#DEVxChatWebsite .cardsTrack::-webkit-scrollbar {
    height: 10px;
}

#DEVxChatWebsite .cardsTrack::-webkit-scrollbar-thumb {
    background: rgba(17,24,39,.12);
    border-radius: 999px;
}

/* Card base */
#DEVxChatWebsite .estateCard {
    width: min(520px, calc(100vw - 80px));
    background: #fff;
    border: 1px solid var(--mf-line);
    border-radius: var(--mf-radius-card);
    overflow: hidden;
    box-shadow: var(--mf-shadow-card);
    scroll-snap-align: start;
    flex: 0 0 auto;
}

/* Image area */
#DEVxChatWebsite .estateCard__media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #e5e7eb;
    overflow: hidden;
    isolation: isolate;
}

#DEVxChatWebsite .estateCard__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.02);
    display: block;
}

#DEVxChatWebsite .estateCard__media::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58%;
    background: linear-gradient(to top, rgba(0,0,0,.62), rgba(0,0,0,0));
    pointer-events: none;
    z-index: 2;
}

#DEVxChatWebsite .estateCard__mediaLink {
    position: absolute;
    inset: 0;
    z-index: 3;
    cursor: pointer;
    text-decoration: none;
}

/* Tag/Badge */
#DEVxChatWebsite .tag {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 8px 11px;
    border-radius: 12px;
    color: #fff;
    font-weight: 500;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: .2px;
    box-shadow: 0 10px 18px rgba(0,0,0,.10);
    z-index: 4;
    pointer-events: none;
}

#DEVxChatWebsite .tag--sale {
    background: var(--mf-tag-sale);
}

#DEVxChatWebsite .tag--rent {
    background: var(--mf-tag-rent);
}

/* Precio */
#DEVxChatWebsite .priceText {
    position: absolute;
    right: 14px;
    bottom: 12px;
    z-index: 4;
    color: #fff;
    font-size: 1.6rem;
    font-weight: 780;
    letter-spacing: -.04em;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(0,0,0,.40);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 22px);
    pointer-events: none;
}

/* Card body */
#DEVxChatWebsite .estateCard__body {
    padding: 12px 14px 14px;
    background: #fff;
}

#DEVxChatWebsite .estateCard__title {
    margin: 0 0 6px;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -.015em;
    color: var(--mf-text);
}

#DEVxChatWebsite .estateCard__titleLink {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    max-width: 100%;
}

#DEVxChatWebsite .estateCard__titleLink:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

/* Ubicación */
#DEVxChatWebsite .estateCard__loc {
    margin: 0 0 12px;
    font-size: 1rem;
    color: var(--mf-muted);
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#DEVxChatWebsite .pin {
    width: 16px;
    height: 16px;
    opacity: .9;
    flex: 0 0 auto;
}

/* Stats grid */
#DEVxChatWebsite .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin-top: 2px;
}

#DEVxChatWebsite .stat {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#DEVxChatWebsite .stat::after {
    content: none !important;
}

#DEVxChatWebsite .stat__icon {
    width: 18px;
    height: 18px;
    opacity: .88;
    flex: 0 0 auto;
}

#DEVxChatWebsite .stat__txt {
    font-size: 1rem;
    color: var(--mf-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#DEVxChatWebsite .stat__hint {
    font-size: 12px;
    color: var(--mf-muted);
    font-weight: 650;
    margin-left: 2px;
}

/* Ajustes del bubble de DevExpress (cuando contiene MiniFichas) */
@supports selector(:has(*)) {
    #DEVxChatWebsite .dx-chat-messagebubble:has(.cpt-mf-bubble) {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: min(980px, calc(100vw - 52px)) !important;
    }
}

@supports not selector(:has(*)) {
    #DEVxChatWebsite .dx-chat-messagebubble .cpt-mf-bubble {
        margin: -10px -14px;
    }
}

/* Mobile tweaks MiniFichas */
@media (max-width: 560px) {
    #DEVxChatWebsite .cpt-mf-bubble {
        width: 100%;
    }

    #DEVxChatWebsite .estateCard {
        width: calc(100% - 6px);
    }

    #DEVxChatWebsite .cardsTrack {
        gap: 12px;
        padding: 2px 2px 2px;
    }

    #DEVxChatWebsite .priceText {
        font-size: 1.35rem;
        right: 12px;
    }

    #DEVxChatWebsite .tag {
        top: 10px;
        left: 10px;
        padding: 7px 10px;
    }
}

/* Desktop tweaks MiniFichas */
@media (min-width: 980px) {
    #DEVxChatWebsite .stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* === Modal / Chat layout === */

.modal-body {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 120px) !important;
    padding-bottom: 0 !important;
}

.chat-container {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

.dx-chat-messagebox {
    position: sticky !important;
    bottom: 0 !important;
    background-color: #fff !important;
    z-index: 1000 !important;
    border-top: 1px solid #e0e0e0 !important;
    margin-top: auto !important;
    margin-bottom: 0 !important;
    padding-bottom: 4px !important;
}

.dx-chat-message-list {
    overflow-y: auto !important;
    max-height: calc(100vh - 200px) !important;
    padding-bottom: 10px !important;
}

/* dxChat centrado */
.dx-chat {
    max-width: 900px;
    width: 100%;
    margin: 0 auto !important;
}

@media (max-width: 576px) {
    .modal-body {
        padding-bottom: 0 !important;
    }

    .dx-chat-messagebox {
        padding-bottom: 2px !important;
    }
}

@media (min-width: 320px) {
    .dx-chat {
        border: 0px solid #e0e0e0;
    }

    .dx-chat-messagebox {
        border-top-width: 0px;
        padding-left: 5px;
        padding-right: 5px;
    }

    .modal-body {
        padding-left: 0;
        padding-right: 0;
    }

    .dx-chat-messagebubble {
        padding: 3px 6px;
    }

    .dx-chat-messagelist > .dx-scrollable > .dx-scrollable-wrapper > .dx-scrollable-container > .dx-scrollable-content {
        padding-inline: 10px;
        padding-inline-start: 10px;
        padding-inline-end: 10px;
    }
}

@media (min-width: 576px) {
    .dx-chat {
        border: 1px solid #e0e0e0;
    }

    .dx-chat-messagebox {
        border-top-width: 1px;
        padding-left: 20px;
        padding-right: 20px;
    }

    .modal-body {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .dx-chat-messagebubble {
        padding: 8px 16px;
        border-radius: 8px;
    }

    .dx-chat-messagelist > .dx-scrollable > .dx-scrollable-wrapper > .dx-scrollable-container > .dx-scrollable-content {
        padding-inline: 20px;
        padding-inline-start: 20px;
        padding-inline-end: 20px;
    }
}

/* Colores de burbujas */
.dx-chat-messagegroup-alignment-end .dx-chat-messagebubble {
    color: var(--cpt-darkcolor);
    background-color: var(--cpt-UserBackgroundColor);
}

.dx-chat-messagegroup-alignment-start .dx-chat-messagebubble {
    color: var(--cpt-darkcolor);
    background-color: var(--cpt-AgentBackgroundColor);
}

.text-dark {
    color: var(--cpt-darkcolor);
}

.cptai-comfortable .dx-chat-messagebubble {
    padding: 12px 20px;
    line-height: var(--cptai-leading);
}

.cptai-comfortable .dx-texteditor-input {
    min-height: var(--cptai-input-height);
    padding: var(--cptai-input-padding);
}

/* === Modal header === */

#ModalChat .cpt-gae-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    min-height: 72px;
}

#ModalChat .cpt-gae-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#ModalChat .cpt-gae-head-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

#ModalChat .cpt-gae-head-title {
    font-weight: 900;
    font-size: 1.05rem;
    line-height: 1.1;
    color: var(--cpt-heading, #0f172a);
}

#ModalChat .cpt-gae-head-sub {
    font-weight: 700;
    font-size: .95rem;
    color: rgba(15,23,42,.55);
}

#ModalChat .cpt-gae-close {
    opacity: .75;
}

#ModalChat .cpt-gae-close:hover {
    opacity: 1;
}

/* Avatar pill */
#ModalChat .cpt-gae-avatar {
    width: 32px;
    height: 32px;
    border-radius: 14px;
    background: rgba(85,10,189,.08);
    border: 1px solid rgba(85,10,189,.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 950;
    color: var(--cpt-primary);
    user-select: none;
    flex: 0 0 auto;
}

#ModalChat .cpt-gae-avatar--sm {
    width: 30px;
    height: 30px;
    border-radius: 12px;
}

@media (max-width: 640px) {
    #ModalChat .cpt-gae-head {
        justify-content: center;
        position: relative;
    }

    #ModalChat .cpt-gae-close {
        position: absolute;
        right: 12px;
        top: 12px;
    }
}

/* === EmptyView overlay === */

#DEVxChatWebsite .dx-chat-message-list {
    position: relative;
}

#DEVxChatWebsite .dx-chat-message-list .dx-chat-empty-view {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 14px;
    margin: 0;
    pointer-events: none;
    z-index: 1;
}

#DEVxChatWebsite .dx-chat-empty-view .dx-chat-empty-view-icon {
    display: none !important;
}

#DEVxChatWebsite .dx-chat-message-list .dx-chat-empty-view .cpt-ev {
    pointer-events: auto;
}

#DEVxChatWebsite .dx-chat-empty-view .dx-scrollview-content {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* EmptyTileView (2 botones) */
.cpt-ev {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.cpt-ev-hero {
    display: flex;
    justify-content: center;
    padding: 10px 0 8px;
}

.cpt-ev-avatar {
    width: 160px;
    height: 160px;
    border-radius: 999px;
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.10);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(0,0,0,.10);
}

.cpt-ev-img {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    object-fit: cover;
    display: block;
}

.cpt-ev-hint {
    margin: 8px 0 14px;
    text-align: center;
    color: rgba(15,23,42,.60);
    font-weight: 600;
    font-size: .95rem;
}

/* Actions (2 columnas desktop / 1 columna mobile) */
.cpt-actions {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .cpt-actions {
        grid-template-columns: 1fr;
        max-width: 420px;
    }
}

.cpt-action {
    width: 100%;
    border-radius: 18px;
    border: 1px solid rgba(15,23,42,.10);
    background: #fff;
    box-shadow: 0 10px 30px rgba(15,23,42,.06);
    padding: 14px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
    transition: transform .12s ease;
}

.cpt-action:active {
    transform: translateY(1px);
}

.cpt-tile-ico {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(85, 10, 189, .10);
    color: #550ABD;
    font-weight: 900;
    flex: 0 0 40px;
}

.cpt-tile-title {
    font-weight: 800;
    font-size: .98rem;
    line-height: 1.15;
    color: var(--cpt-heading, #0f172a);
    text-align: left;
}

.cpt-tile-sub {
    margin-top: 2px;
    font-size: .84rem;
    color: rgba(15,23,42,.60);
    line-height: 1.2;
}

/* === FIX Scroll SOLO en dxChat (ModalChat) === */

#ModalChat .modal-dialog,
#ModalChat .modal-content,
#ModalChat .modal-body {
    overflow: hidden !important;
}

#ModalChat .chat-container {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

#ModalChat #DEVxChatWebsite {
    height: 100% !important;
    min-height: 0 !important;
}

#ModalChat #DEVxChatWebsite .dx-chat-messagelist {
    min-height: 0 !important;
}

#ModalChat #DEVxChatWebsite .dx-chat-messagelist > .dx-scrollable {
    height: 100% !important;
}
