/* ═══════════════════════════════════════════════════════════════
   Smartize AI Suite — Chatbot Widget Styles
   All selectors are scoped to #smartize-chatbot to avoid conflicts.
   ═══════════════════════════════════════════════════════════════ */

#smartize-chatbot {
    --sz-bot-color:    #6366f1;
    --sz-bot-dark:     #4f46e5;
    --sz-bot-light:    #e0e7ff;
    --sz-text:         #111827;
    --sz-muted:        #6b7280;
    --sz-bg:           #ffffff;
    --sz-bubble-user:  var(--sz-bot-color);
    --sz-bubble-bot:   #f3f4f6;
    --sz-user-text:    #ffffff;
    --sz-shadow:       0 20px 60px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.10);
    --sz-radius:       20px;
    --sz-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sz-z:            9999;

    position: fixed;
    z-index: var(--sz-z);
    font-family: var(--sz-font);

    /* Isolate from theme styles */
    all: initial;
    font-family: var(--sz-font);
    position: fixed;
    z-index: var(--sz-z);
}

/* ── Positions ─────────────────────────────────────────────── */
#smartize-chatbot.smartize-chatbot--bottom-right {
    bottom: 24px;
    right: 24px;
}

#smartize-chatbot.smartize-chatbot--bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ── Toggle Button ─────────────────────────────────────────── */
.smartize-toggle {
    all: unset;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sz-bot-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
    position: relative;
    outline-offset: 3px;
}

.smartize-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(0,0,0,.30);
}

.smartize-toggle:active { transform: scale(.96); }

.smartize-toggle:focus-visible {
    outline: 3px solid var(--sz-bot-color);
    outline-offset: 3px;
}

.smartize-toggle-icon { display: flex; align-items: center; justify-content: center; }

.smartize-unread-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}

.smartize-unread-dot.visible { display: block; animation: szPulse 1.5s infinite; }

@keyframes szPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: .7; }
}

/* ── Chat Window ───────────────────────────────────────────── */
.smartize-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 600px;
    background: var(--sz-bg);
    border-radius: var(--sz-radius);
    box-shadow: var(--sz-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity .2s ease, transform .25s cubic-bezier(.34,1.36,.64,1);
    border: 1px solid rgba(0,0,0,.06);
}

.smartize-chatbot--bottom-left .smartize-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.smartize-window[hidden] {
    display: flex !important;
    opacity: 0;
    pointer-events: none;
    transform: scale(.92) translateY(12px);
}

.smartize-window.open {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

/* ── Header ────────────────────────────────────────────────── */
.smartize-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--sz-bot-color), var(--sz-bot-dark));
    color: #fff;
    flex-shrink: 0;
}

.smartize-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.smartize-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid var(--sz-bot-color);
    border-radius: 50%;
}

.smartize-header-info { flex: 1; min-width: 0; }

.smartize-header-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartize-header-status {
    font-size: 11px;
    opacity: .8;
    margin-top: 2px;
}

.smartize-header-close {
    all: unset;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: .75;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}

.smartize-header-close:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ── Messages ──────────────────────────────────────────────── */
.smartize-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #fafafa;
}

.smartize-messages::-webkit-scrollbar { width: 4px; }
.smartize-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }

/* Message groups */
.smartize-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: szFadeUp .25s ease both;
}

@keyframes szFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.smartize-msg--bot  { flex-direction: row; }
.smartize-msg--user { flex-direction: row-reverse; }

.smartize-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--sz-bot-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.smartize-msg--user .smartize-msg-avatar { display: none; }

.smartize-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.smartize-msg--bot .smartize-bubble {
    background: #fff;
    color: var(--sz-text);
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.smartize-msg--user .smartize-bubble {
    background: var(--sz-bot-color);
    color: var(--sz-user-text, #fff);
    -webkit-text-fill-color: var(--sz-user-text, #fff);
    border-bottom-right-radius: 4px;
}

.smartize-msg-time {
    font-size: 10px;
    color: var(--sz-muted);
    margin-top: 4px;
    text-align: right;
    padding: 0 4px;
}

.smartize-msg--bot  .smartize-msg-time { text-align: left; }

/* Typing indicator */
.smartize-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.smartize-typing-dots {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.smartize-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sz-bot-color);
    opacity: .4;
    animation: szDot 1.2s ease-in-out infinite;
}

.smartize-typing-dot:nth-child(2) { animation-delay: .2s; }
.smartize-typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes szDot {
    0%, 80%, 100% { transform: scale(.8); opacity: .3; }
    40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Quick Replies ─────────────────────────────────────────── */
.smartize-quick-replies {
    display: none;
}

.smartize-quick-reply {
    all: unset;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    border: 1.5px solid var(--sz-bot-color);
    color: var(--sz-bot-color);
    font-family: var(--sz-font);
    transition: background .15s, color .15s, transform .1s;
    white-space: nowrap;
}

.smartize-quick-reply:hover {
    background: var(--sz-bot-color);
    color: #fff;
    transform: translateY(-1px);
}

/* ── Input Area ────────────────────────────────────────────── */
.smartize-input-area {
    padding: 12px 16px 10px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.smartize-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f3f4f6;
    border-radius: 14px;
    padding: 6px 6px 6px 14px;
    border: 1.5px solid transparent;
    transition: border-color .15s;
}

.smartize-input-wrap:focus-within {
    border-color: var(--sz-bot-color);
    background: #fff;
}

.smartize-input {
    -webkit-appearance: none;
    appearance: none;
    border: none; outline: none; box-shadow: none;
    background: transparent;
    padding: 0; margin: 0;
    flex: 1; display: block; width: 100%;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px; line-height: 1.5;
    color: #111827;
    -webkit-text-fill-color: #111827;
    opacity: 1;
    caret-color: #6366f1;
    min-height: 22px; max-height: 100px;
    overflow-y: auto; resize: none; word-break: break-word;
}

.smartize-input::placeholder { color: #9ca3af; }

#smartize-send {
    all: unset;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--sz-bot-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, transform .15s, opacity .15s;
}

#smartize-send:hover {
    background: var(--sz-bot-dark);
    transform: scale(1.05);
}



.smartize-footer-brand {
    text-align: center;
    font-size: 10px;
    color: #9ca3af;
    margin-top: 8px;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .smartize-window {
        width: calc(100vw - 16px);
        bottom: 72px;
        right: 0;
        left: 0;
        margin: 0 8px;
        max-height: 70vh;
    }

    .smartize-chatbot--bottom-right .smartize-window { right: -8px; left: auto; margin: 0; }
    .smartize-chatbot--bottom-left  .smartize-window { left: -8px; right: auto; margin: 0; }
    .smartize-input { font-size: 16px !important; color: #111827 !important; -webkit-text-fill-color: #111827 !important; }
    #smartize-send { width: 40px !important; height: 40px !important; }
}
