/* ============================================================
   BeautyLash Chatbot — Standalone & Embeddable Styles
   ============================================================
   All styles scoped under .bl-chatbot so they don't leak.
   Standalone page reset lives in chat_view.php.
   ============================================================ */

/* -- Scope-proof resets against host page globals -- */
.bl-chatbot-wrapper,
.bl-chatbot-wrapper * {
    box-sizing: border-box;
}

.bl-chatbot-wrapper button {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: inherit;
    font-weight: normal;
    font-family: inherit;
    line-height: normal;
    display: inline-flex;
    cursor: pointer;
    color: inherit;
}

.bl-chatbot-wrapper input,
.bl-chatbot-wrapper textarea {
    margin: 0;
    font-family: inherit;
    box-sizing: border-box;
}

/* -- Wrapper -- */
.bl-chatbot-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1a1a1a;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 24px;
    box-sizing: border-box;
}

@media (max-width: 520px) {
    .bl-chatbot-wrapper {
        max-width: 100%;
        padding: 12px;
    }
}

/* ============================================================
   TEASER / CLOSED STATE
   ============================================================ */
.bl-chatbot-teaser {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 100%;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bl-chatbot-teaser__bubble,
.bl-chatbot-teaser__avatar {
    cursor: pointer;
}

.bl-chatbot-teaser--hidden {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    pointer-events: none;
    position: absolute;
}

/* Speech bubble */
.bl-chatbot-teaser__bubble {
    background: #ffffff;
    color: #1a1a1a;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 260px;
    min-width: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    animation: bl-teaser-bubble-in 0.5s ease-out 0.3s both;
}

@media (max-width: 360px) {
    .bl-chatbot-teaser__bubble {
        max-width: 200px;
        font-size: 13px;
        padding: 10px 14px;
    }
}

@keyframes bl-teaser-bubble-in {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Avatar circle */
.bl-chatbot-teaser__avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: bl-teaser-avatar-in 0.4s ease-out both;
}

@media (max-width: 520px) {
    .bl-chatbot-teaser__avatar {
        width: 52px;
        height: 52px;
    }
}

@keyframes bl-teaser-avatar-in {
    from {
        opacity: 0;
        transform: scale(0.7);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.bl-chatbot-teaser:hover .bl-chatbot-teaser__avatar {
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

.bl-chatbot-teaser__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================================
   CHAT WIDGET / OPEN STATE
   ============================================================ */
.bl-chatbot {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 80vh;
    height: 80dvh;
    max-height: 600px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    position: relative;
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.bl-chatbot--hidden {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    position: absolute;
    bottom: 0;
    right: 0;
}

/* Mobile: full-screen overlay */
@media (max-width: 768px) {
    .bl-chatbot:not(.bl-chatbot--hidden) {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        z-index: 10000; /* above menu (.topNavigation = 9999); cookie bumped to 10001 to stay on top */
    }
    /* When chat is open on mobile, wrapper must not constrain the fixed child
       and must drop its own stacking context so the chatbot's z-index applies
       relative to the root (cookie 1000 > chatbot 999 > bella 998). */
    .bl-chatbot-wrapper.bl-chatbot--floating.bl-chatbot--open {
        position: static;
        padding: 0;
        z-index: auto;
    }
    /* Tighter input area on mobile so the textarea uses more of the screen width */
    .bl-chatbot__input-area {
        padding: 8px 8px;
        gap: 6px;
    }
    .bl-chatbot__input {
        min-width: 0;
        width: 100%;
    }
}

/* -- Header -- */
.bl-chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1a1a1a;
    color: #ffffff;
    flex-shrink: 0;
}

.bl-chatbot__header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.bl-chatbot__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.bl-chatbot__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bl-chatbot__header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bl-chatbot__title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bl-chatbot__status {
    font-size: 11px;
    color: #8bc78b;
    letter-spacing: 0.2px;
}

.bl-chatbot__header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.bl-chatbot__lang-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 0.5px;
}

.bl-chatbot__lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.bl-chatbot__reset,
.bl-chatbot__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bl-chatbot__reset:hover,
.bl-chatbot__close:hover {
    color: #ffffff;
}

/* -- Messages area -- */
.bl-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* Scrollbar styling */
.bl-chatbot__messages::-webkit-scrollbar {
    width: 5px;
}

.bl-chatbot__messages::-webkit-scrollbar-track {
    background: transparent;
}

.bl-chatbot__messages::-webkit-scrollbar-thumb {
    background: #d4c5b3;
    border-radius: 3px;
}

/* -- Message bubbles -- */
.bl-chatbot__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: bl-msg-in 0.25s ease-out;
}

@media (max-width: 520px) {
    .bl-chatbot__msg {
        max-width: 90%;
        font-size: 15px;
    }
}

@keyframes bl-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bl-chatbot__msg--user {
    align-self: flex-end;
    background: #1a1a1a;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bl-chatbot__msg--assistant {
    align-self: flex-start;
    background: #f5f0eb;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

/* Markdown inside assistant messages */
.bl-chatbot__msg--assistant p {
    margin: 0 0 8px 0;
}

.bl-chatbot__msg--assistant p:last-child {
    margin-bottom: 0;
}

.bl-chatbot__msg--assistant strong {
    font-weight: 600;
}

.bl-chatbot__msg--assistant a {
    color: #8b6914;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.bl-chatbot__msg--assistant a:hover {
    color: #c8a87c;
}

.bl-chatbot__msg--assistant ul,
.bl-chatbot__msg--assistant ol {
    margin: 6px 0;
    padding-left: 20px;
}

.bl-chatbot__msg--assistant li {
    margin-bottom: 4px;
}

.bl-chatbot__msg--assistant code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
}

/* -- Typing indicator -- */
.bl-chatbot__typing {
    padding: 0 14px 6px;
    flex-shrink: 0;
}

.bl-chatbot__typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f5f0eb;
    padding: 10px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.bl-chatbot__typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b0a090;
    animation: bl-typing-bounce 1.4s infinite ease-in-out;
}

.bl-chatbot__typing-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.bl-chatbot__typing-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes bl-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-5px);
    }
}

/* -- Input area -- */
.bl-chatbot__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ebe5dd;
    background: #ffffff;
    flex-shrink: 0;
}

.bl-chatbot__input {
    flex: 1;
    border: 1px solid #ddd5ca;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    max-height: 80px;
    outline: none;
    transition: border-color 0.2s;
    background: #faf8f5;
    color: #1a1a1a;
    -webkit-appearance: none;
    appearance: none;
}

.bl-chatbot__input::placeholder {
    color: #b0a090;
}

.bl-chatbot__input:focus {
    border-color: #c8a87c;
}

.bl-chatbot__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: #1a1a1a;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bl-chatbot__send:hover:not(:disabled) {
    background: #333333;
}

.bl-chatbot__send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* -- Footer -- */
.bl-chatbot__footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: #b0a090;
    border-top: 1px solid #f0ebe5;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

/* ============================================================
   Floating bubble mode (for embedding on other pages)
   ============================================================ */
.bl-chatbot-wrapper.bl-chatbot--floating {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 900; /* below cookie banner (1000) */
    height: auto;
    max-width: 480px;
    margin: 0;
}

.bl-chatbot--floating .bl-chatbot {
    height: 560px;
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

/* Left-side variant (for embedding on bottom-left) */
.bl-chatbot-wrapper.bl-chatbot--left {
    right: auto;
    left: 0;
    align-items: flex-start;
}

.bl-chatbot--left .bl-chatbot-teaser {
    flex-direction: row-reverse;
}

.bl-chatbot--left .bl-chatbot-teaser__bubble {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

.bl-chatbot--left .bl-chatbot {
    transform-origin: bottom left;
}

.bl-chatbot--left .bl-chatbot--hidden {
    right: auto;
    left: 0;
}
