/* ShopBot Widget CSS */
:root {
    --sb-primary: #6C63FF;
    --sb-primary-dark: #5a52e0;
    --sb-bubble-bot: #F3F4F6;
    --sb-bubble-user: var(--sb-primary);
    --sb-text-bot: #1F2937;
    --sb-text-user: #ffffff;
    --sb-bg: #ffffff;
    --sb-header-bg: var(--sb-primary);
    --sb-header-text: #ffffff;
    --sb-radius: 20px;
    --sb-shadow: 0 20px 60px rgba(0,0,0,.15), 0 4px 16px rgba(0,0,0,.08);
    --sb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#shopbot-root * { box-sizing: border-box; }
#shopbot-root {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--sb-font);
}
#shopbot-root[data-position="right"] { right: 24px; }
#shopbot-root[data-position="left"]  { left: 24px; }

/* Launcher Button */
#shopbot-launcher {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--sb-primary);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(108,99,255,.4);
    transition: all .25s cubic-bezier(.34,1.56,.64,1);
    position: relative;
    outline: none;
}
#shopbot-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(108,99,255,.5);
}
#shopbot-launcher:active { transform: scale(0.96); }
#shopbot-launcher .sb-icon-chat,
#shopbot-launcher .sb-icon-close {
    position: absolute;
    transition: all .25s ease;
}
#shopbot-launcher .sb-icon-close {
    opacity: 0; transform: rotate(-90deg) scale(0.6);
}
#shopbot-root.is-open #shopbot-launcher .sb-icon-chat {
    opacity: 0; transform: rotate(90deg) scale(0.6);
}
#shopbot-root.is-open #shopbot-launcher .sb-icon-close {
    opacity: 1; transform: rotate(0) scale(1);
}

/* Notification badge */
#shopbot-badge {
    position: absolute; top: -4px; right: -4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #EF4444; color: #fff;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    animation: sb-pulse 2s infinite;
}
@keyframes sb-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Chat Window */
#shopbot-window {
    position: absolute;
    bottom: 76px;
    width: 380px;
    height: 560px;
    background: var(--sb-bg);
    border-radius: var(--sb-radius);
    box-shadow: var(--sb-shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    transform-origin: bottom center;
    opacity: 0; pointer-events: none;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
}
#shopbot-root[data-position="right"] #shopbot-window { right: 0; }
#shopbot-root[data-position="left"]  #shopbot-window { left: 0; }
#shopbot-root.is-open #shopbot-window {
    transform: scale(1) translateY(0);
    opacity: 1; pointer-events: all;
}

/* Header */
#shopbot-header {
    background: var(--sb-primary);
    padding: 18px 20px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
#shopbot-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; overflow: hidden; flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.3);
}
#shopbot-avatar img { width: 100%; height: 100%; object-fit: cover; }
#shopbot-header-info { flex: 1; min-width: 0; }
#shopbot-header-name { font-size: 16px; font-weight: 700; color: #fff; }
#shopbot-header-status {
    font-size: 12px; color: rgba(255,255,255,.8);
    display: flex; align-items: center; gap: 5px; margin-top: 1px;
}
#shopbot-header-status::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: #4ADE80; display: inline-block;
    box-shadow: 0 0 6px #4ADE80;
}
#shopbot-header-close {
    background: rgba(255,255,255,.15); border: none;
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; transition: background .15s;
}
#shopbot-header-close:hover { background: rgba(255,255,255,.25); }

/* Messages */
#shopbot-messages {
    flex: 1; overflow-y: auto; padding: 20px 16px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
}
#shopbot-messages::-webkit-scrollbar { width: 4px; }
#shopbot-messages::-webkit-scrollbar-track { background: transparent; }
#shopbot-messages::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 99px; }

/* Message Bubbles */
.sb-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.sb-msg--bot  { flex-direction: row; }
.sb-msg--user { flex-direction: row-reverse; }

.sb-msg__avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--sb-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0; overflow: hidden;
}
.sb-msg__avatar img { width: 100%; height: 100%; object-fit: cover; }

.sb-msg__bubble {
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px; line-height: 1.5;
    word-break: break-word;
    animation: sb-appear .25s ease;
}
@keyframes sb-appear {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sb-msg--bot  .sb-msg__bubble { background: var(--sb-bubble-bot); color: var(--sb-text-bot); border-bottom-left-radius: 4px; }
.sb-msg--user .sb-msg__bubble { background: var(--sb-bubble-user); color: var(--sb-text-user); border-bottom-right-radius: 4px; }

/* Typing indicator */
.sb-typing .sb-msg__bubble {
    padding: 14px 18px;
    display: flex; align-items: center; gap: 5px;
}
.sb-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9CA3AF; animation: sb-bounce .9s infinite;
}
.sb-dot:nth-child(2) { animation-delay: .15s; }
.sb-dot:nth-child(3) { animation-delay: .3s; }
@keyframes sb-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Quick Replies */
.sb-quick-replies {
    display: flex; flex-wrap: wrap; gap: 7px;
    margin-top: 8px; padding-left: 36px;
    animation: sb-appear .3s ease;
}
.sb-quick-reply {
    padding: 7px 14px;
    background: #fff; border: 1.5px solid var(--sb-primary);
    border-radius: 99px; color: var(--sb-primary);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all .15s; white-space: nowrap;
    font-family: var(--sb-font);
}
.sb-quick-reply:hover { background: var(--sb-primary); color: #fff; }

/* Product Cards */
.sb-products {
    padding-left: 36px; margin-top: 8px;
    display: flex; flex-direction: column; gap: 10px;
    animation: sb-appear .3s ease;
}
.sb-product-card {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1.5px solid #E5E7EB;
    border-radius: 12px; padding: 10px 12px;
    text-decoration: none; color: inherit;
    transition: all .15s; overflow: hidden;
}
.sb-product-card:hover { border-color: var(--sb-primary); box-shadow: 0 2px 12px rgba(108,99,255,.15); }
.sb-product-card__img {
    width: 48px; height: 48px; object-fit: cover;
    border-radius: 8px; background: #F3F4F6; flex-shrink: 0;
}
.sb-product-card__body { flex: 1; min-width: 0; }
.sb-product-card__name { font-size: 13px; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-product-card__price { font-size: 12px; color: var(--sb-primary); font-weight: 500; margin-top: 2px; }
.sb-product-card__badge { font-size: 10px; background: #FEF3C7; color: #92400E; padding: 2px 7px; border-radius: 99px; font-weight: 600; }
.sb-product-card__arrow { color: #9CA3AF; font-size: 14px; }

/* Order Status Card */
.sb-order-card {
    background: #fff; border: 1.5px solid #E5E7EB;
    border-radius: 12px; overflow: hidden;
    margin-top: 4px; padding-left: 0;
    animation: sb-appear .3s ease;
}
.sb-order-card__header {
    background: #F9FAFB; padding: 12px 16px;
    border-bottom: 1px solid #E5E7EB;
    font-size: 13px; font-weight: 600; color: #111827;
    display: flex; align-items: center; justify-content: space-between;
}
.sb-order-card__body { padding: 12px 16px; font-size: 13px; }
.sb-order-card__row { display: flex; justify-content: space-between; padding: 4px 0; color: #6B7280; }
.sb-order-card__row strong { color: #111827; }
.sb-order-card__status { display: flex; align-items: center; gap: 6px; font-weight: 600; color: #059669; }
.sb-order-card__link {
    display: block; text-align: center; margin-top: 10px; padding: 9px;
    background: var(--sb-primary); color: #fff; border-radius: 8px;
    font-size: 13px; font-weight: 500; text-decoration: none;
    transition: background .15s;
}
.sb-order-card__link:hover { background: var(--sb-primary-dark); }

/* Order form */
.sb-order-form {
    background: #F9FAFB; border: 1.5px solid #E5E7EB;
    border-radius: 12px; padding: 14px;
    margin-top: 4px; animation: sb-appear .3s ease;
}
.sb-order-form input {
    width: 100%; padding: 9px 12px; margin-bottom: 8px;
    border: 1.5px solid #E5E7EB; border-radius: 8px;
    font-size: 13px; outline: none; font-family: var(--sb-font);
    transition: border-color .15s;
}
.sb-order-form input:focus { border-color: var(--sb-primary); }
.sb-order-form button {
    width: 100%; padding: 10px;
    background: var(--sb-primary); color: #fff;
    border: none; border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: var(--sb-font);
    transition: background .15s;
}
.sb-order-form button:hover { background: var(--sb-primary-dark); }

/* Footer / Input */
#shopbot-footer {
    border-top: 1px solid #F3F4F6;
    padding: 12px 14px;
    background: #fff; flex-shrink: 0;
}
#shopbot-input-row {
    display: flex; align-items: flex-end; gap: 8px;
}
#shopbot-input {
    flex: 1; padding: 10px 14px;
    border: 1.5px solid #E5E7EB; border-radius: 99px;
    font-size: 14px; outline: none; resize: none;
    font-family: var(--sb-font); color: #111827;
    max-height: 100px; overflow-y: auto;
    transition: border-color .15s; line-height: 1.4;
    background: #F9FAFB;
}
#shopbot-input:focus { border-color: var(--sb-primary); background: #fff; }
#shopbot-input::placeholder { color: #9CA3AF; }
#shopbot-send {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--sb-primary); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; flex-shrink: 0;
}
#shopbot-send:hover { background: var(--sb-primary-dark); transform: scale(1.05); }
#shopbot-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
#shopbot-powered {
    text-align: center; font-size: 11px; color: #D1D5DB; margin-top: 8px;
}
#shopbot-powered a { color: #9CA3AF; text-decoration: none; }

/* Home screen */
#shopbot-home {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px; text-align: center; gap: 6px;
}
#shopbot-home .sb-home-avatar { font-size: 52px; margin-bottom: 8px; }
#shopbot-home h3 { font-size: 18px; font-weight: 700; color: #111827; margin: 0; }
#shopbot-home p  { font-size: 14px; color: #6B7280; margin: 0 0 16px; }
.sb-home-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.sb-home-action {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: #F9FAFB;
    border: 1.5px solid #E5E7EB; border-radius: 12px;
    cursor: pointer; text-align: left; font-family: var(--sb-font);
    transition: all .15s; text-decoration: none; color: inherit;
}
.sb-home-action:hover { border-color: var(--sb-primary); background: #EEF0FF; }
.sb-home-action__icon { font-size: 22px; }
.sb-home-action__body strong { display: block; font-size: 14px; font-weight: 600; color: #111827; }
.sb-home-action__body span  { font-size: 12px; color: #6B7280; }
.sb-home-action__arrow { margin-left: auto; color: #9CA3AF; }

/* Responsive */
@media (max-width: 480px) {
    #shopbot-window { width: calc(100vw - 32px); height: 70vh; }
    #shopbot-root[data-position="right"] { right: 16px; }
    #shopbot-root[data-position="left"]  { left: 16px; }
}
