/* ============================================
   Asistente BarraTouch — Chat Widget
   Botón flotante + panel de chat
   ============================================ */

/* ─── Botón flotante ──────────────────────── */
.bt-chat-button {
    position: fixed;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    right: 24px;
    z-index: 950;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.35);
    cursor: pointer;
    border: none;
    color: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: btChatFadeSlideUp 0.5s 0.5s ease-out both;
}

.bt-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.5);
}

.bt-chat-button:active {
    transform: scale(0.96);
}

.bt-chat-button .material-icons {
    font-size: 26px;
    pointer-events: none;
}

/* ─── Tooltip ─────────────────────────────── */
.bt-chat-button::after {
    content: 'Consultar al asistente';
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: #fff;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.bt-chat-button:hover::after {
    opacity: 1;
}

/* ─── Panel de chat ───────────────────────── */
.bt-chat-panel {
    position: fixed;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    right: 24px;
    z-index: 949;
    width: 380px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    animation: btChatPanelIn 0.3s ease-out;
}

.bt-chat-panel.open {
    display: flex;
}

/* ─── Header ──────────────────────────────── */
.bt-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: #fff;
    flex-shrink: 0;
}

.bt-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bt-chat-header-left .material-icons {
    font-size: 22px;
}

.bt-chat-header-title {
    font-size: 15px;
    font-weight: 600;
}

.bt-chat-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.bt-chat-header-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.bt-chat-header-close .material-icons {
    font-size: 20px;
}

/* ─── Messages area ───────────────────────── */
.bt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}

.bt-chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bt-chat-message.bot {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.bt-chat-message.user {
    align-self: flex-end;
    background: #e91e63;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* ─── Typing indicator ────────────────────── */
.bt-chat-typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.bt-chat-typing.active {
    display: flex;
}

.bt-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: btChatTyping 1.4s infinite ease-in-out;
}

.bt-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.bt-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ─── Input area ──────────────────────────── */
.bt-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}

.bt-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.bt-chat-input:focus {
    border-color: #e91e63;
}

.bt-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e91e63;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.bt-chat-send:hover {
    background: #c2185b;
}

.bt-chat-send:active {
    transform: scale(0.92);
}

.bt-chat-send .material-icons {
    font-size: 20px;
}

.bt-chat-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* ─── Error message ───────────────────────── */
.bt-chat-error {
    align-self: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
}

/* ─── Animations ──────────────────────────── */
@keyframes btChatFadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes btChatPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes btChatTyping {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ─── Scrollbar ───────────────────────────── */
.bt-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.bt-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.bt-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ─── Mobile ──────────────────────────────── */
@media (max-width: 768px) {
    .bt-chat-button {
        width: 56px;
        height: 56px;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        right: 16px;
    }

    .bt-chat-button .material-icons {
        font-size: 28px;
    }

    .bt-chat-button::after {
        display: none;
    }

    .bt-chat-panel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - 110px);
    }
}
