/* ===========================================================
   Sofía — Widget flotante de chat (Gemini tool-use)
   Dorado #BEAF87 · Negro #0B0B0B · Superficie #FFF / #FAFAFA
   =========================================================== */

.c21-sofia,
.c21-sofia * { box-sizing: border-box; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

.c21-sofia {
    position: fixed;
    right: 20px;
    bottom: 95px; /* queda por encima del botón de WhatsApp del tema */
    z-index: 999999;
    color: #111;
}

/* --- Launcher (botón flotante cerrado) --- */
.c21-sofia__launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px 10px 10px;
    background: #0B0B0B;
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.22);
    transition: transform .2s ease, box-shadow .2s ease;
    font-size: 14px;
    max-width: 260px;
}
.c21-sofia__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(0,0,0,0.28);
}
.c21-sofia__launcher:focus-visible {
    outline: 2px solid #BEAF87;
    outline-offset: 3px;
}
.c21-sofia__launch-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: left;
}
.c21-sofia__launch-text strong { font-weight: 700; font-size: 14px; }
.c21-sofia__launch-text small {
    font-size: 11px;
    color: #BEAF87;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.c21-sofia__launch-text small::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
    animation: c21-sofia-pulse 2s infinite;
}
@keyframes c21-sofia-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* --- Avatar --- */
.c21-sofia__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #BEAF87 0%, #d6c8a8 100%);
    color: #0B0B0B;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .5px;
    flex-shrink: 0;
}
.c21-sofia__avatar--lg { width: 40px; height: 40px; font-size: 17px; }

/* --- Panel (abierto) --- */
.c21-sofia__panel {
    position: fixed;
    right: 20px;
    bottom: 95px;
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 115px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: c21-sofia-in .25s ease-out;
}
@keyframes c21-sofia-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.c21-sofia__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #0B0B0B;
    color: #fff;
    border-bottom: 2px solid #BEAF87;
}
.c21-sofia__header strong { display: block; font-weight: 700; font-size: 15px; }
.c21-sofia__header small { display: block; color: #BEAF87; font-size: 11.5px; margin-top: 1px; }
.c21-sofia__close,
.c21-sofia__reset {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.c21-sofia__reset { margin-left: auto; padding: 6px 8px; }
.c21-sofia__close:hover,
.c21-sofia__reset:hover { background: rgba(255,255,255,0.1); }

/* --- Mensajes --- */
.c21-sofia__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #FAFAFA;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.c21-sofia__messages::-webkit-scrollbar { width: 6px; }
.c21-sofia__messages::-webkit-scrollbar-thumb { background: #d8d2bf; border-radius: 3px; }

.c21-sofia__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: c21-sofia-msg-in .2s ease-out;
}
@keyframes c21-sofia-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.c21-sofia__msg--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
    color: #111;
}
.c21-sofia__msg--user {
    align-self: flex-end;
    background: #0B0B0B;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.c21-sofia__msg--typing {
    display: inline-flex;
    gap: 4px;
    padding: 14px;
}
.c21-sofia__msg--typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #BEAF87;
    animation: c21-sofia-dot 1.2s infinite ease-in-out;
}
.c21-sofia__msg--typing span:nth-child(2) { animation-delay: .15s; }
.c21-sofia__msg--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes c21-sofia-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: .5; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* --- Cards de propiedades dentro del chat --- */
.c21-sofia__cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}
.c21-sofia__card {
    display: flex;
    gap: 10px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 8px;
    text-decoration: none !important;
    color: #111 !important;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.c21-sofia__card:hover {
    transform: translateY(-2px);
    border-color: #BEAF87;
    box-shadow: 0 6px 16px rgba(190,175,135,0.2);
}
.c21-sofia__card-img {
    width: 84px;
    height: 84px;
    border-radius: 8px;
    background: #f0ede3 center/cover no-repeat;
    flex-shrink: 0;
}
.c21-sofia__card-body { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.c21-sofia__card-title {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.c21-sofia__card-zone { font-size: 11.5px; color: #666; margin: 2px 0 4px; }
.c21-sofia__card-price { font-size: 14px; font-weight: 700; color: #0B0B0B; }
.c21-sofia__card-meta { font-size: 11px; color: #888; margin-top: 2px; display: flex; gap: 8px; }

/* --- CTA WhatsApp --- */
.c21-sofia__wa {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 13px;
    margin-top: 6px;
    transition: transform .15s, box-shadow .15s;
    align-self: flex-start;
}
.c21-sofia__wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37,211,102,0.35);
}

/* --- Input / Form --- */
.c21-sofia__form {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #eee;
}
.c21-sofia__input {
    flex: 1;
    border: 1px solid #e5e5e5;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    color: #111;
    background: #fafafa;
    transition: border-color .15s, background .15s;
    min-width: 0;
}
.c21-sofia__input:focus {
    border-color: #BEAF87;
    background: #fff;
}
.c21-sofia__send,
.c21-sofia__mic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, transform .15s, color .15s;
}
.c21-sofia__send {
    background: #BEAF87;
    color: #0B0B0B;
}
.c21-sofia__send:hover { background: #a89974; transform: scale(1.05); }
.c21-sofia__send:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.c21-sofia__mic {
    background: #f2efe6;
    color: #8a7d5d;
}
.c21-sofia__mic:hover { background: #e7e1cc; }
.c21-sofia__mic.is-recording {
    background: #ef4444;
    color: #fff;
    animation: c21-sofia-rec 1s infinite;
}
@keyframes c21-sofia-rec {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50%     { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* --- Responsive mobile --- */
@media (max-width: 480px) {
    .c21-sofia { right: 12px; bottom: 80px; } /* deja espacio al WA del tema */
    .c21-sofia__launcher { padding: 8px 14px 8px 8px; font-size: 13px; }
    .c21-sofia__launch-text small { font-size: 10.5px; }
    .c21-sofia__panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
