/* ============================
   Floating Chat Widget - User Side
   ============================== */
.ft-chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Burbuja flotante --- */
.ft-chat-bubble {
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, var(--accent-color, #00d166), #00a84f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 209, 102, 0.4), 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ft-chat-bubble:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 25px rgba(0, 209, 102, 0.55), 0 3px 10px rgba(0,0,0,0.4);
}

.ft-chat-bubble:active {
    transform: scale(0.96);
}

.ft-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: #000;
}

/* --- Badge de mensajes no leídos --- */
.ft-chat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e63946;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--bg-color, #0a0a0a);
    animation: ft-badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ft-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* --- Ventana de chat --- */
.ft-chat-window {
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #111;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0,0,0,0.4);
    overflow: hidden;
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
}

.ft-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* --- Header del chat --- */
.ft-chat-header {
    background: linear-gradient(135deg, var(--accent-color, #00d166), #00a84f);
    color: #000;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ft-chat-close-btn {
    background: rgba(0,0,0,0.15);
    border: none;
    color: #000;
    font-size: 1.3rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
}

.ft-chat-close-btn:hover {
    background: rgba(0,0,0,0.25);
}

/* --- Área de mensajes --- */
.ft-chat-messages {
    flex: 1;
    padding: 1rem 1.2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #0a0a0a;
    scroll-behavior: smooth;
}

.ft-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ft-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* --- Burbujas de mensaje --- */
.ft-msg {
    max-width: 82%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    animation: ft-msg-appear 0.2s ease;
}

@keyframes ft-msg-appear {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ft-msg.received {
    align-self: flex-start;
    background: #1e1e1e;
    color: #e0e0e0;
    border-bottom-left-radius: 3px;
}

.ft-msg.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-color, #00d166), #00a84f);
    color: #000;
    font-weight: 500;
    border-bottom-right-radius: 3px;
}

.ft-msg-time {
    font-size: 0.65rem;
    opacity: 0.55;
    display: block;
    margin-top: 0.25rem;
    text-align: right;
}

/* --- Área de input --- */
.ft-chat-input-area {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    gap: 0.6rem;
    align-items: center;
    background: #111;
    flex-shrink: 0;
}

.ft-chat-input-area input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 22px;
    padding: 0.65rem 1rem;
    color: white;
    outline: none;
    font-size: 0.88rem;
    transition: border-color 0.2s;
}

.ft-chat-input-area input:focus {
    border-color: var(--accent-color, #00d166);
}

.ft-chat-input-area input::placeholder {
    color: rgba(255,255,255,0.3);
}

.ft-chat-input-area button {
    background: linear-gradient(135deg, var(--accent-color, #00d166), #00a84f);
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    transition: transform 0.2s, opacity 0.2s;
}

.ft-chat-input-area button:hover {
    transform: scale(1.08);
}

.ft-chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Responsive mobile --- */
@media (max-width: 480px) {
    .ft-chat-widget {
        bottom: 1rem;
        right: 1rem;
    }

    .ft-chat-window {
        width: calc(100vw - 2rem);
        right: -1rem;
        height: 420px;
        bottom: 72px;
        border-radius: 16px;
    }
}

/* Pantallas muy pequeñas 320px (iPhone SE 1ª gen, Galaxy A) */
@media (max-width: 360px) {
    .ft-chat-widget {
        bottom: 0.6rem;
        right: 0.6rem;
    }

    .ft-chat-bubble {
        width: 52px;
        height: 52px;
    }

    .ft-chat-window {
        width: calc(100vw - 1.2rem);
        right: -0.6rem;
        height: 380px;
        bottom: 62px;
        border-radius: 12px;
    }

    .ft-chat-messages {
        padding: 0.8rem;
    }

    .ft-chat-input-area {
        padding: 0.6rem 0.8rem;
    }
}
