/* ── Sofia AI Widget ───────────────────────────────────────────────────────
   Colores de marca: morado #973887, blanco #ffffff
   z-index: 9990 (por debajo del PWA banner 9999)
──────────────────────────────────────────────────────────────────────────── */

/* Burbuja flotante */
#sofia-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffcc00;
    box-shadow: 0 4px 16px rgba(255, 204, 0, 0.5);
    cursor: pointer;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    border: none;
    padding: 0;
    overflow: hidden;
}
#sofia-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(255, 204, 0, 0.6);
}
#sofia-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Badge de notificación */
#sofia-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #e91e63;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* Burbuja oculta cuando el panel está abierto */
#sofia-bubble.sofia-bubble-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.7);
}

/* Panel de chat */
#sofia-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 420px;
    max-height: 75vh;
    margin: 0 auto;
    background: #f1f3f7;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(15, 23, 42, 0.18);
    z-index: 9990;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom center;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#sofia-panel.sofia-hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

/* Header del panel */
#sofia-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#sofia-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}
#sofia-header-info {
    flex: 1;
    min-width: 0;
}
#sofia-header-info strong {
    display: block;
    font-size: 0.93rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
#sofia-header-info span {
    font-size: 0.75rem;
    opacity: 0.85;
}
#sofia-close-btn {
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
#sofia-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Área de mensajes */
#sofia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#sofia-messages::-webkit-scrollbar { width: 4px; }
#sofia-messages::-webkit-scrollbar-thumb { background: #d8b4e2; border-radius: 4px; }

/* Burbujas de mensaje */
.sofia-msg {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.5;
    word-break: break-word;
}
.sofia-msg.bot {
    background: #ffffff;
    color: #2d1a3e;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.sofia-msg.user {
    background: #973887;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.sofia-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 9px 13px;
    background: #ffffff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.sofia-typing span {
    width: 7px;
    height: 7px;
    background: #973887;
    border-radius: 50%;
    animation: sofia-bounce 1.1s infinite ease-in-out;
}
.sofia-typing span:nth-child(2) { animation-delay: 0.18s; }
.sofia-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes sofia-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* Input área */
#sofia-input-area {
    padding: 10px 12px 12px;
    border-top: 1px solid #d8dce4;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #e8ebf0;
}
#sofia-input {
    flex: 1;
    border: 1.5px solid #e2d0ef;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 0.83rem;
    resize: none;
    outline: none;
    max-height: 90px;
    line-height: 1.4;
    color: #2d1a3e;
    background: #f1f3f7;
    transition: border-color 0.15s;
    font-family: inherit;
}
#sofia-input:focus {
    border-color: #973887;
}
#sofia-send-btn {
    width: 36px;
    height: 36px;
    background: #973887;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
#sofia-send-btn:hover { background: #7e2e72; }
#sofia-send-btn:active { transform: scale(0.92); }
#sofia-send-btn:disabled { background: #c9a8d8; cursor: not-allowed; }

/* Desktop: panel anclado a la derecha */
@media (min-width: 480px) {
    #sofia-panel {
        left: auto;
        right: 24px;
        bottom: 0;
        width: 360px;
        border-radius: 16px 16px 0 0;
        max-height: 560px;
    }
}

/* Responsivo móvil pequeño */
@media (max-width: 400px) {
    #sofia-bubble {
        right: 16px;
        bottom: 16px;
    }
}

/* Cuando hay un modal abierto, Sofia queda debajo */
.modal-open #sofia-bubble,
.modal-open #sofia-panel {
    z-index: 1040 !important;
}

