/* ============================================================
   BARBIER LUXE — Chat Widget CSS
   ============================================================ */

/* Prevent body scroll when chat is open on mobile */
body.bl-chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

#bl-chat-bubble {
    position: fixed;
    bottom: 32px;
    right: 28px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #E8C96A, #C9A84C, #8B6A1F);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 24px rgba(201,168,76,0.55);
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
#bl-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(201,168,76,0.75);
}
#bl-chat-bubble svg { pointer-events: none; }

#bl-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #e74c3c;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: sans-serif;
    border: 2px solid #0b1627;
    padding: 0 4px;
    pointer-events: none;
}

/* ── Window ── */
#bl-chat-window {
    position: fixed;
    bottom: 102px;
    right: 28px;
    width: 360px;
    height: 540px;
    background: #0D1628;
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 99998;
    box-shadow: 0 12px 48px rgba(0,0,0,0.7);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transition: opacity 0.28s cubic-bezier(.4,0,.2,1), transform 0.28s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
#bl-chat-window.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ── Header ── */
#bl-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1E2D4A, #162038);
    border-bottom: 1px solid rgba(201,168,76,0.18);
    flex-shrink: 0;
}
.bl-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8C96A, #C9A84C, #8B6A1F);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(201,168,76,0.4);
}
.bl-chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.bl-chat-avatar-text { font-family: Georgia, serif; font-weight: 700; font-size: 0.85rem; color: #0b1627; display: none; }
.bl-chat-header-info { flex: 1; }
.bl-chat-name { font-family: Georgia, serif; font-size: 0.9rem; font-weight: 700; color: #F7F0E0; letter-spacing: 0.03em; }
.bl-chat-status {
    font-size: 0.66rem; color: #27ae60;
    display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.bl-chat-status::before {
    content: ''; width: 6px; height: 6px;
    background: #27ae60; border-radius: 50%; display: inline-block;
    animation: bl-pulse 2s infinite;
}
@keyframes bl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

#bl-chat-close {
    background: transparent; border: none; color: #7A8FA8;
    font-size: 1.15rem; cursor: pointer; padding: 6px; line-height: 1;
    transition: color 0.2s; border-radius: 50%;
}
#bl-chat-close:hover { color: #F7F0E0; background: rgba(255,255,255,0.06); }

/* ── Messages ── */
#bl-chat-messages {
    flex: 1; overflow-y: auto;
    padding: 16px 12px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
#bl-chat-messages::-webkit-scrollbar { width: 3px; }
#bl-chat-messages::-webkit-scrollbar-track { background: transparent; }
#bl-chat-messages::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.25); border-radius: 3px; }

.bl-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.6;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    word-wrap: break-word;
    animation: bl-fadein 0.2s ease;
}
@keyframes bl-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bl-msg.bot {
    background: #1A2740;
    color: #F7F0E0;
    border: 1px solid rgba(201,168,76,0.12);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}
.bl-msg.bot strong { color: #C9A84C; }
.bl-msg.bot em { color: #C8B98A; font-style: normal; }
.bl-msg.bot a { color: #C9A84C; text-decoration: underline; }
.bl-msg.user {
    background: linear-gradient(135deg, #E8C96A, #C9A84C, #8B6A1F);
    color: #0b1627;
    font-weight: 600;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}
.bl-msg.success {
    background: rgba(39,174,96,0.1);
    border: 1px solid rgba(39,174,96,0.35);
    color: #F7F0E0;
}
.bl-msg.error {
    background: rgba(231,76,60,0.08);
    border: 1px solid rgba(231,76,60,0.3);
    color: #F7F0E0;
}

/* Typewriter cursor */
.bl-cursor {
    display: inline-block;
    width: 2px; height: 14px;
    background: #C9A84C;
    margin-left: 2px;
    vertical-align: middle;
    animation: bl-blink 0.7s infinite;
}
@keyframes bl-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Typing indicator ── */
.bl-typing {
    align-self: flex-start;
    background: #1A2740;
    border: 1px solid rgba(201,168,76,0.12);
    border-radius: 12px; border-bottom-left-radius: 3px;
    padding: 12px 16px;
    display: flex; gap: 5px; align-items: center;
    animation: bl-fadein 0.2s ease;
}
.bl-typing span {
    width: 7px; height: 7px;
    background: #C9A84C; border-radius: 50%;
    animation: bl-bounce 1.3s infinite;
}
.bl-typing span:nth-child(2) { animation-delay: 0.18s; }
.bl-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bl-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick replies ── */
#bl-quick-replies {
    padding: 8px 10px;
    display: flex; flex-wrap: wrap; gap: 6px;
    border-top: 1px solid rgba(201,168,76,0.08);
    flex-shrink: 0;
    background: rgba(13,22,40,0.5);
}
.bl-quick {
    background: transparent;
    border: 1px solid rgba(201,168,76,0.35);
    color: #C9A84C;
    border-radius: 16px;
    padding: 5px 13px;
    font-size: 0.71rem;
    cursor: pointer;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    transition: all 0.2s;
    white-space: nowrap;
}
.bl-quick:hover {
    background: rgba(201,168,76,0.14);
    border-color: #C9A84C;
    transform: translateY(-1px);
}

/* ── Footer ── */
#bl-chat-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(201,168,76,0.12);
    background: #0a1120;
    flex-shrink: 0;
}
#bl-chat-input {
    flex: 1;
    background: #1A2740;
    border: 1px solid rgba(201,168,76,0.18);
    border-radius: 24px;
    color: #F7F0E0;
    font-size: 0.9rem;
    padding: 10px 16px;
    resize: none;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.4;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    overflow-y: hidden;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
#bl-chat-input:focus { border-color: rgba(201,168,76,0.5); outline: none; }
#bl-chat-input::placeholder { color: #4a5c75; }

#bl-chat-send {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, #E8C96A, #C9A84C, #8B6A1F);
    border: none; border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}
#bl-chat-send:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(201,168,76,0.4); }

/* ── Powered by ── */
#bl-chat-powered {
    text-align: center;
    font-size: 0.6rem;
    color: #2a3d55;
    padding: 4px 0 6px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    background: #0a1120;
}

/* ============================================================
   MOBILE — Fixed height, keyboard does NOT affect layout
   ============================================================ */
@media (max-width: 480px) {

    #bl-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        /* Use dvh so browser chrome is accounted for */
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        transform: none !important;
        transition: opacity 0.2s ease !important;
        z-index: 100000 !important;
        overflow: hidden !important;
        /* Flex column so footer always sticks to bottom */
        display: flex !important;
        flex-direction: column !important;
    }

    #bl-chat-window.open {
        transform: none !important;
    }

    /* Header never shrinks */
    #bl-chat-header {
        flex-shrink: 0 !important;
        padding: 12px 16px !important;
    }

    /* Messages take all remaining space */
    #bl-chat-messages {
        flex: 1 1 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    /* Quick replies never shrink */
    #bl-quick-replies {
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    #bl-quick-replies::-webkit-scrollbar { display: none; }
    .bl-quick { white-space: nowrap; flex-shrink: 0; }

    /* Footer never shrinks — always visible */
    #bl-chat-footer {
        flex-shrink: 0 !important;
        padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    }

    /* Powered bar never shrinks */
    #bl-chat-powered {
        flex-shrink: 0 !important;
    }

    /* Prevent iOS zoom on input */
    #bl-chat-input {
        font-size: 16px !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        border-radius: 24px !important;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
    }

    #bl-chat-bubble {
        width: 52px;
        height: 52px;
        bottom: 24px;
        left: 20px;
        right: auto;
        z-index: 100001 !important;
    }

    .bl-chat-avatar { width: 34px; height: 34px; }
}

@media (max-width: 380px) {
    #bl-chat-input {
        font-size: 16px !important;
        padding: 8px 12px !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
    }
    #bl-chat-send { width: 40px; height: 40px; }
    .bl-quick { font-size: 0.65rem; padding: 4px 10px; }
}