/*
|--------------------------------------------------------------------------
| Black Arabian chat widget
|--------------------------------------------------------------------------
|
| Self-contained and namespaced under .ba-chat so it cannot collide with
| Bootstrap 5 or the site's own stylesheets. Served directly from /public,
| matching the hand-written assets/js/custom.js convention.
|
*/

.ba-chat {
    --ba-accent: #b8860b;
    --ba-accent-dark: #8a6508;
    --ba-accent-light: #fef9ed;
    --ba-surface: #ffffff;
    --ba-bg: #f8f5ee;
    --ba-border: #e6ded0;
    --ba-text: #2b2621;
    --ba-muted: #7d736a;
    --ba-radius: 16px;
    --ba-shadow: 0 16px 40px rgba(0, 0, 0, .22);
    --ba-z: 9999;

    position: fixed;
    z-index: var(--ba-z);
    font-family: inherit;
    line-height: 1.45;
    color: var(--ba-text);
}

.ba-chat--launcher {
    right: 24px;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--ba-accent), #9a7008);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--ba-shadow);
    transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}

.ba-chat--launcher:hover {
    background: linear-gradient(135deg, var(--ba-accent-dark), #6e5005);
    transform: translateY(-2px);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

.ba-chat--launcher i {
    font-size: 19px;
}

.ba-chat--panel {
    right: 24px;
    bottom: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    display: none;
    flex-direction: column;
    background: var(--ba-surface);
    border-radius: var(--ba-radius);
    box-shadow: var(--ba-shadow);
    overflow: hidden;
    transition: width .25s ease, height .25s ease;
}

.ba-chat--panel.is-open {
    display: flex;
    flex-direction: column;
    animation: ba-fade-scale .2s ease;
}

.ba-chat--panel.is-expanded {
    width: 480px;
    height: 680px;
}

@keyframes ba-fade-scale {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.ba-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #221c15, #14110d);
    color: #fff;
    border-bottom: 1px solid rgba(184, 134, 11, 0.35);
}

.ba-chat__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ba-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ba-accent), #d4af37);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(184, 134, 11, .4);
}

.ba-chat__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .2px;
    color: #f7edd4;
}

.ba-chat__subtitle {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: #cfc2a9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ba-chat__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
}

.ba-chat__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ba-chat__hdr-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #e5dac4;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}

.ba-chat__hdr-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.ba-chat__close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #e5dac4;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}

.ba-chat__close:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

/* Chat Log */
.ba-chat__log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: var(--ba-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.ba-chat__bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: ba-bubble-in .18s ease;
}

@keyframes ba-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ba-chat__bubble--in {
    align-self: flex-start;
    background: var(--ba-surface);
    border: 1px solid var(--ba-border);
    border-bottom-left-radius: 4px;
    color: var(--ba-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.ba-chat__bubble--out {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ba-accent), #9a7008);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(184, 134, 11, .25);
}

.ba-chat__bubble--notice {
    align-self: center;
    max-width: 90%;
    background: #fff8e1;
    border: 1px solid #f0d999;
    color: #6b551a;
    font-size: 12.5px;
    text-align: center;
    border-radius: 10px;
    padding: 8px 12px;
}

/* Markdown styling inside bubbles */
.ba-chat__bubble strong {
    font-weight: 700;
    color: inherit;
}

.ba-chat__bubble em {
    font-style: italic;
}

.ba-chat__bubble ul,
.ba-chat__bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.ba-chat__bubble li {
    margin-bottom: 4px;
}

.ba-chat__link {
    color: #9c6e00;
    text-decoration: underline;
    font-weight: 500;
}

.ba-chat__bubble--out .ba-chat__link {
    color: #fff;
    text-decoration: underline;
}

/* Checkout CTA Button inside bubble */
.ba-chat__action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 9px 16px;
    background: linear-gradient(135deg, #b8860b, #d4af37);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(184, 134, 11, .35);
    transition: transform .15s ease, box-shadow .15s ease;
}

.ba-chat__action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(184, 134, 11, .45);
    color: #fff !important;
}

/* Quick Action Pills in Assistant Bubbles */
.ba-chat__bubble-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 0, 0, .08);
}

.ba-chat__pill-btn {
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(184, 134, 11, .1);
    color: var(--ba-accent-dark);
    border: 1px solid rgba(184, 134, 11, .25);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all .15s ease;
}

.ba-chat__pill-btn:hover {
    background: var(--ba-accent);
    color: #fff;
    border-color: var(--ba-accent);
    transform: translateY(-1px);
}

/* Luxury Product Cards */
.ba-chat__card {
    background: #ffffff;
    border: 1px solid #e8dec8;
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    box-sizing: border-box;
    width: 100%;
}

.ba-chat__card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.ba-chat__card-img-wrap {
    width: 68px;
    height: 68px;
    border-radius: 8px;
    background: #f7f2ea;
    border: 1px solid #e2d7c5;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ba-chat__card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.ba-chat__card:hover .ba-chat__card-img {
    transform: scale(1.05);
}

.ba-chat__card-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.ba-chat__card-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    background: #fbf3db;
    color: #8a6508;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ba-chat__card-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ba-text);
    margin: 0 0 2px 0;
    line-height: 1.25;
}

.ba-chat__card-notes {
    font-size: 11.5px;
    color: var(--ba-muted);
    line-height: 1.35;
    margin-top: 2px;
}

.ba-chat__card-notes strong {
    color: var(--ba-text);
}

.ba-chat__card-lasting {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #7d6b56;
    margin-top: 4px;
}

.ba-chat__card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px dashed #ede5d8;
    align-items: center;
}

.ba-chat__card-sizes-label {
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .4px;
    color: var(--ba-muted);
    width: 100%;
    margin-bottom: 2px;
}

.ba-chat__card-size-btn {
    padding: 5px 10px;
    border-radius: 6px;
    background: #faf7f2;
    border: 1px solid #e5dcce;
    color: var(--ba-text);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ba-chat__card-size-btn:hover {
    background: var(--ba-accent);
    color: #fff;
    border-color: var(--ba-accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(184, 134, 11, .25);
}

.ba-chat__card-view-btn {
    margin-left: auto;
    font-size: 11px;
    color: var(--ba-accent-dark);
    text-decoration: none !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background .15s, color .15s;
}

.ba-chat__card-view-btn:hover {
    background: #fbf3db;
    color: var(--ba-accent);
}

/* Suggestion Chips */
.ba-chat__chips-wrap {
    padding: 4px 16px 8px;
    background: var(--ba-bg);
    border-top: 1px solid rgba(0, 0, 0, .04);
}

.ba-chat__chips-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ba-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.ba-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ba-chat__chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--ba-border);
    color: var(--ba-text);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    transition: all .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ba-chat__chip:hover {
    background: var(--ba-accent);
    color: #fff;
    border-color: var(--ba-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(184, 134, 11, .28);
}

/* In-Widget Persistent Cart Banner */
.ba-chat__cart-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    background: linear-gradient(135deg, #fff9e8, #fffdf8);
    border-top: 1px solid #e8d7a7;
    border-bottom: 1px solid #f0e6c8;
    animation: ba-slide-up .2s ease;
}

@keyframes ba-slide-up {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.ba-chat__cart-info {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: #4a3809;
}

.ba-chat__cart-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ba-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ba-chat__cart-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--ba-accent), #9a7008);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(184, 134, 11, .25);
    transition: all .15s ease;
}

.ba-chat__cart-btn:hover {
    background: linear-gradient(135deg, var(--ba-accent-dark), #6e5005);
    transform: translateY(-1px);
}

/* Typing Indicator */
.ba-chat__typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    width: fit-content;
}

.ba-chat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ba-accent);
    animation: ba-bounce 1.2s infinite ease-in-out;
}

.ba-chat__typing span:nth-child(2) { animation-delay: .18s; }
.ba-chat__typing span:nth-child(3) { animation-delay: .36s; }

@keyframes ba-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Form Composer */
.ba-chat__form {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--ba-border);
    background: var(--ba-surface);
}

.ba-chat__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 16px;
    border: 1px solid var(--ba-border);
    border-radius: 999px;
    font-size: 16px;
    font-family: inherit;
    color: var(--ba-text);
    background: #faf8f5;
    transition: border-color .15s, background .15s;
}

.ba-chat__input:focus {
    outline: none;
    border-color: var(--ba-accent);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(184, 134, 11, .15);
}

.ba-chat__send {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ba-accent), #9a7008);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .15s;
}

.ba-chat__send:hover:not(:disabled) {
    transform: scale(1.05);
}

.ba-chat__send:disabled {
    opacity: .5;
    cursor: default;
}

.ba-chat__error {
    margin: 0;
    padding: 8px 12px;
    background: #fdecea;
    color: #a1261d;
    font-size: 12.5px;
}

@media (max-width: 480px) {
    .ba-chat--panel,
    .ba-chat--panel.is-expanded {
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
        height: calc(100vh - 24px);
        height: calc(100dvh - 24px);
        max-height: none;
        border-radius: 12px;
    }

    .ba-chat--launcher {
        right: 16px;
        bottom: 16px;
        padding: 12px 16px;
    }
}