/* ONS Chatbot — Frontend Widget Styles */

:root {
    --ons-primary:    #5B4FCF;
    --ons-secondary:  #7C6FD4;
    --ons-white:      #ffffff;
    --ons-gray-50:    #f9fafb;
    --ons-gray-100:   #f3f4f6;
    --ons-gray-200:   #e5e7eb;
    --ons-gray-400:   #9ca3af;
    --ons-gray-600:   #4b5563;
    --ons-gray-800:   #1f2937;
    --ons-radius:     18px;
    --ons-shadow:     0 24px 80px rgba(0,0,0,.20);
    --ons-transition: .18s ease;
    --ons-z:          9999;
}

#ons-chatbot-widget *,
#ons-chatbot-widget *::before,
#ons-chatbot-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Launcher Button ──────────────────────────────────────────────────────── */
#ons-chatbot-widget {
    position: fixed;
    bottom: 24px;
    z-index: var(--ons-z);
}
#ons-chatbot-widget.ons-pos-right { right: 24px; }
#ons-chatbot-widget.ons-pos-left  { left:  24px; }

#ons-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(91,79,207,.50);
    transition: transform var(--ons-transition), box-shadow var(--ons-transition);
    position: relative;
    outline: none;
}
#ons-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 36px rgba(91,79,207,.60);
}
#ons-launcher svg {
    width: 26px;
    height: 26px;
    color: #fff;
}
.ons-unread-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
}

/* ── Chat Window ──────────────────────────────────────────────────────────── */
#ons-chatbox {
    position: absolute;
    bottom: 76px;
    width: 380px;
    max-height: 600px;
    background: var(--ons-white);
    border-radius: var(--ons-radius);
    box-shadow: var(--ons-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ons-slide-up .22s ease;
}
.ons-pos-right #ons-chatbox { right: 0; }
.ons-pos-left  #ons-chatbox { left: 0; }

@keyframes ons-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.ons-header {
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ons-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ons-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.ons-header-name {
    display: block;
    font-size: 15px; font-weight: 700;
    line-height: 1.2;
    color: #fff;
}
.ons-header-status {
    font-size: 11.5px;
    opacity: .88;
    display: flex; align-items: center; gap: 5px;
    color: #fff;
}
.ons-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: ons-pulse 2s infinite;
    flex-shrink: 0;
}
@keyframes ons-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .45; }
}
.ons-header-actions { display: flex; gap: 6px; }
.ons-header-btn {
    background: rgba(255,255,255,.15);
    border: none; cursor: pointer;
    padding: 6px; border-radius: 8px;
    color: rgba(255,255,255,.9);
    transition: background var(--ons-transition);
    display: flex; align-items: center;
}
.ons-header-btn:hover { background: rgba(255,255,255,.28); color: #fff; }
.ons-header-btn svg { width: 17px; height: 17px; }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.ons-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.ons-messages::-webkit-scrollbar { width: 4px; }
.ons-messages::-webkit-scrollbar-thumb { background: var(--ons-gray-200); border-radius: 4px; }

.ons-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
    animation: ons-msg-in .18s ease;
}
@keyframes ons-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ons-msg-user { flex-direction: row-reverse; }

/* Avatar — now renders emoji */
.ons-msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    align-self: flex-end;
}
.ons-msg-avatar--user {
    background: var(--ons-gray-200);
}

.ons-msg-body {
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 44px);
}
.ons-msg-user .ons-msg-body { align-items: flex-end; }

.ons-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px; line-height: 1.5;
    word-break: break-word;
}
.ons-msg-bot  .ons-msg-bubble {
    background: var(--ons-gray-100);
    color: var(--ons-gray-800);
    border-bottom-left-radius: 4px;
}
.ons-msg-user .ons-msg-bubble {
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ons-msg-time {
    font-size: 10.5px;
    color: var(--ons-gray-400);
    margin-top: 4px;
    padding: 0 4px;
    display: flex; align-items: center; gap: 3px;
}
.ons-read-tick { color: #5B4FCF; font-size: 11px; }

/* ── Typing Indicator ─────────────────────────────────────────────────────── */
.ons-typing-indicator {
    display: flex; gap: 4px; align-items: center;
    padding: 12px 16px;
    background: var(--ons-gray-100);
    border-radius: 18px 18px 18px 4px;
}
.ons-typing-indicator span {
    display: block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--ons-gray-400);
    animation: ons-bounce .9s infinite;
}
.ons-typing-indicator span:nth-child(2) { animation-delay: .2s; }
.ons-typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes ons-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Product Cards ────────────────────────────────────────────────────────── */
.ons-products {
    margin-top: 7px;
    display: flex; flex-direction: column; gap: 6px;
    width: 100%;
}
.ons-product-card {
    display: flex; align-items: center; gap: 10px;
    background: #fff;
    border: 1px solid var(--ons-gray-200);
    border-radius: 12px;
    padding: 8px 10px;
    transition: box-shadow var(--ons-transition), border-color var(--ons-transition);
}
.ons-product-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.09);
    border-color: #c4b5fd;
}
.ons-product-img {
    width: 44px; height: 44px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.ons-product-img-placeholder {
    width: 44px; height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ede9fe, #dbeafe);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.ons-product-info { flex: 1; min-width: 0; }
.ons-product-name {
    display: block;
    font-size: 12.5px; font-weight: 700;
    color: var(--ons-gray-800);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ons-product-price {
    display: block;
    font-size: 13px; font-weight: 800;
    color: var(--ons-primary);
    margin-top: 2px;
}
.ons-product-type {
    display: inline-block;
    font-size: 10.5px; font-weight: 700;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 5px;
    padding: 1px 6px;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.ons-product-btn {
    flex-shrink: 0;
    font-size: 11.5px; font-weight: 700;
    color: var(--ons-primary);
    border: 1.5px solid var(--ons-primary);
    border-radius: 8px;
    padding: 5px 10px;
    text-decoration: none;
    transition: background var(--ons-transition), color var(--ons-transition);
    white-space: nowrap;
}
.ons-product-btn:hover { background: var(--ons-primary); color: #fff; }

/* ── Category Chips ───────────────────────────────────────────────────────── */
.ons-categories {
    margin-top: 8px;
    display: flex; flex-wrap: wrap; gap: 6px;
}
.ons-cat-chip {
    font-size: 12px;
    color: var(--ons-primary);
    border: 1px solid var(--ons-primary);
    border-radius: 20px;
    padding: 4px 12px;
    text-decoration: none;
    transition: background var(--ons-transition), color var(--ons-transition);
}
.ons-cat-chip:hover { background: var(--ons-primary); color: #fff; }

/* ── Quick Actions (icon + label buttons) ─────────────────────────────────── */
.ons-quick-actions {
    padding: 6px 12px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    flex-shrink: 0;
    border-top: 1px solid var(--ons-gray-100);
    background: #fff;
}
.ons-quick-btn {
    background: #fff;
    border: 1px solid var(--ons-gray-200);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 11.5px; font-weight: 600;
    color: var(--ons-gray-600);
    cursor: pointer;
    display: flex; align-items: center; gap: 7px;
    transition: border-color var(--ons-transition), background var(--ons-transition), color var(--ons-transition), box-shadow var(--ons-transition);
    text-align: left;
    line-height: 1.3;
}
.ons-quick-btn:hover {
    border-color: var(--ons-primary);
    background: #f5f3ff;
    color: var(--ons-primary);
    box-shadow: 0 2px 10px rgba(91,79,207,.12);
}
.ons-qbtn-icon {
    width: 26px; height: 26px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.ons-qbtn-label { flex: 1; }

/* ── Lead Form ────────────────────────────────────────────────────────────── */
.ons-lead-form {
    padding: 12px 14px;
    background: var(--ons-gray-50);
    border-top: 1px solid var(--ons-gray-200);
    flex-shrink: 0;
}
.ons-lead-inner h4 {
    font-size: 14px; font-weight: 800;
    color: var(--ons-gray-800); margin-bottom: 10px;
}
.ons-field {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--ons-gray-200);
    border-radius: 10px;
    font-size: 13px; margin-bottom: 8px;
    outline: none;
    transition: border-color var(--ons-transition);
    background: #fff; color: var(--ons-gray-800);
}
.ons-field:focus { border-color: var(--ons-primary); box-shadow: 0 0 0 3px rgba(91,79,207,.12); }
.ons-gdpr-label {
    font-size: 12px; color: var(--ons-gray-600);
    display: flex; gap: 6px; align-items: flex-start;
    margin-bottom: 10px; cursor: pointer; line-height: 1.4;
}
.ons-gdpr-label input { margin-top: 2px; flex-shrink: 0; }
.ons-lead-error { color: #ef4444; font-size: 12px; margin-bottom: 8px; }
.ons-submit-lead {
    width: 100%; padding: 10px;
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    color: #fff; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 700; cursor: pointer;
    transition: opacity var(--ons-transition);
}
.ons-submit-lead:hover { opacity: .88; }
.ons-submit-lead:disabled { opacity: .55; cursor: not-allowed; }
.ons-lead-success {
    display: flex; align-items: center; gap: 8px;
    color: #16a34a; font-size: 14px; font-weight: 600;
    padding: 8px 0;
}

/* ── Emoji Picker ─────────────────────────────────────────────────────────── */
.ons-emoji-picker {
    position: absolute; bottom: 100%; left: 0;
    background: #fff;
    border: 1px solid var(--ons-gray-200);
    border-radius: 14px; padding: 10px;
    display: flex; flex-wrap: wrap; gap: 4px;
    width: 210px;
    box-shadow: 0 10px 30px rgba(0,0,0,.14);
    z-index: 10;
}
.ons-emoji-item {
    background: none; border: none; cursor: pointer;
    font-size: 20px; padding: 5px; border-radius: 8px;
    transition: background var(--ons-transition); line-height: 1;
}
.ons-emoji-item:hover { background: var(--ons-gray-100); }

/* ── Footer / Input ───────────────────────────────────────────────────────── */
.ons-footer {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--ons-gray-200);
    background: #fff; flex-shrink: 0;
    position: relative;
}
.ons-emoji-btn {
    background: none; border: none; cursor: pointer;
    color: var(--ons-gray-400); padding: 7px; border-radius: 8px;
    transition: color var(--ons-transition);
    display: flex; align-items: center; flex-shrink: 0;
}
.ons-emoji-btn:hover { color: var(--ons-primary); }
.ons-emoji-btn svg { width: 20px; height: 20px; }

.ons-input {
    flex: 1;
    border: 1px solid var(--ons-gray-200);
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 13.5px;
    resize: none; outline: none;
    line-height: 1.4;
    max-height: 120px; overflow-y: auto;
    transition: border-color var(--ons-transition), box-shadow var(--ons-transition);
    color: var(--ons-gray-800);
    background: var(--ons-gray-50);
}
.ons-input:focus {
    border-color: var(--ons-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(91,79,207,.12);
}
.ons-input::placeholder { color: var(--ons-gray-400); }

.ons-send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ons-primary), var(--ons-secondary));
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity var(--ons-transition), transform var(--ons-transition);
    box-shadow: 0 4px 14px rgba(91,79,207,.38);
}
.ons-send-btn:hover { opacity: .9; transform: scale(1.06); }
.ons-send-btn svg { width: 18px; height: 18px; fill: #fff; }

.ons-powered-by {
    text-align: center;
    font-size: 10.5px; color: var(--ons-gray-400);
    padding: 3px 0 6px;
    background: #fff; flex-shrink: 0;
}
.ons-powered-by strong { color: var(--ons-primary); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #ons-chatbox {
        width: calc(100vw - 32px);
        max-height: 82vh;
        bottom: 74px;
    }
    .ons-pos-right #ons-chatbox { right: 0; }
    .ons-pos-left  #ons-chatbox { left: 0; }
    #ons-chatbot-widget { bottom: 16px; }
    .ons-pos-right #ons-chatbot-widget { right: 16px; }
    .ons-pos-left  #ons-chatbot-widget { left: 16px; }
}
