/* Belle's Chatbox – frontend styles
 * Modern & clean: rounded corners, soft shadows, neutral palette with accent.
 * Fully responsive: mobile full-screen, desktop floating panel.
 */

.belles-chatbox *,
.belles-chatbox *::before,
.belles-chatbox *::after {
    box-sizing: border-box;
}

.belles-chatbox {
    --belles-accent: #6C5CE7;
    --belles-accent-contrast: #ffffff;
    --belles-bg: #ffffff;
    --belles-surface: #f6f7fb;
    --belles-text: #1d2327;
    --belles-text-muted: #6c6f7a;
    --belles-border: #e5e7ef;
    --belles-shadow: 0 12px 40px rgba(17, 24, 39, 0.18);
    --belles-radius: 16px;
    --belles-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-family: var(--belles-font);
    color: var(--belles-text);
    line-height: 1.5;
}

/* -------- Bubble launcher -------- */
.belles-chatbox--bubble {
    position: fixed;
    bottom: 24px;
    z-index: 2147483000;
}

.belles-chatbox--bubble.belles-chatbox--right { right: 24px; }
.belles-chatbox--bubble.belles-chatbox--left  { left: 24px;  }

.belles-chatbox__launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--belles-accent);
    color: var(--belles-accent-contrast);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--belles-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.belles-chatbox__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 48px rgba(17, 24, 39, 0.22);
}

.belles-chatbox__launcher:focus-visible {
    outline: 3px solid rgba(108, 92, 231, 0.35);
    outline-offset: 3px;
}

.belles-chatbox__launcher svg {
    width: 26px;
    height: 26px;
}

/* -------- Panel -------- */
.belles-chatbox__panel {
    background: var(--belles-bg);
    border-radius: var(--belles-radius);
    box-shadow: var(--belles-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--belles-border);
}

.belles-chatbox--bubble .belles-chatbox__panel {
    position: absolute;
    bottom: 76px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 120px);
}

.belles-chatbox--bubble.belles-chatbox--right .belles-chatbox__panel { right: 0; }
.belles-chatbox--bubble.belles-chatbox--left  .belles-chatbox__panel { left: 0;  }

.belles-chatbox--embed {
    width: 100%;
}

.belles-chatbox--embed .belles-chatbox__panel {
    width: 100%;
    height: 100%;
}

.belles-chatbox--bubble .belles-chatbox__panel[hidden] {
    display: none;
}

/* -------- Header -------- */
.belles-chatbox__header {
    background: var(--belles-accent);
    color: var(--belles-accent-contrast);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.belles-chatbox__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.belles-chatbox__title {
    flex: 1;
    min-width: 0;
}

.belles-chatbox__name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.belles-chatbox__status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.belles-chatbox__status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
}

.belles-chatbox__close {
    background: transparent;
    color: inherit;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.belles-chatbox__close:hover { background: rgba(255, 255, 255, 0.15); }
.belles-chatbox__close svg { width: 18px; height: 18px; }

.belles-chatbox--embed .belles-chatbox__close { display: none; }

/* -------- Messages -------- */
.belles-chatbox__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--belles-surface);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.belles-chatbox__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: belles-pop-in 0.18s ease-out;
}

@keyframes belles-pop-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.belles-chatbox__msg--user {
    align-self: flex-end;
    background: var(--belles-accent);
    color: var(--belles-accent-contrast);
    border-bottom-right-radius: 4px;
}

.belles-chatbox__msg--assistant {
    align-self: flex-start;
    background: #ffffff;
    color: var(--belles-text);
    border: 1px solid var(--belles-border);
    border-bottom-left-radius: 4px;
}

.belles-chatbox__msg--error {
    align-self: flex-start;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.belles-chatbox__typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.belles-chatbox__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--belles-text-muted);
    animation: belles-bounce 1.1s infinite ease-in-out;
}
.belles-chatbox__typing span:nth-child(2) { animation-delay: 0.15s; }
.belles-chatbox__typing span:nth-child(3) { animation-delay: 0.3s;  }

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

/* -------- Composer -------- */
.belles-chatbox__composer {
    border-top: 1px solid var(--belles-border);
    background: var(--belles-bg);
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.belles-chatbox__input {
    flex: 1;
    border: 1px solid var(--belles-border);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    outline: none;
    color: var(--belles-text);
    background: var(--belles-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.belles-chatbox__input:focus {
    border-color: var(--belles-accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.belles-chatbox__send {
    background: var(--belles-accent);
    color: var(--belles-accent-contrast);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.belles-chatbox__send:hover:not(:disabled) {
    transform: scale(1.05);
}

.belles-chatbox__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.belles-chatbox__send svg {
    width: 18px;
    height: 18px;
}

.belles-chatbox__footer {
    text-align: center;
    padding: 6px 12px 10px;
    font-size: 11px;
    color: var(--belles-text-muted);
    background: var(--belles-bg);
}

/* -------- Scrollbar -------- */
.belles-chatbox__messages::-webkit-scrollbar {
    width: 6px;
}
.belles-chatbox__messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}
.belles-chatbox__messages::-webkit-scrollbar-track { background: transparent; }

/* -------- Responsive -------- */
@media (max-width: 600px) {
    .belles-chatbox--bubble .belles-chatbox__panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: 0;
    }
    .belles-chatbox--bubble.belles-chatbox--right,
    .belles-chatbox--bubble.belles-chatbox--left {
        right: 16px;
        left: auto;
    }
    .belles-chatbox--bubble.belles-chatbox--left { left: 16px; right: auto; }
}

/* -------- Dark mode (prefers-color-scheme) -------- */
@media (prefers-color-scheme: dark) {
    .belles-chatbox {
        --belles-bg: #1a1b21;
        --belles-surface: #14151a;
        --belles-text: #e6e7eb;
        --belles-text-muted: #9aa0ac;
        --belles-border: #2a2c34;
        --belles-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    }
    .belles-chatbox__msg--assistant {
        background: #22232b;
    }
}
