/* ═══════════════════════════════════════════════════
   Jigisha ChatBot Pro — Frontend Styles
═══════════════════════════════════════════════════ */
:root {
    --jcb-primary:    #1a73e8;
    --jcb-secondary:  #ffffff;
    --jcb-bg:         #f5f7fa;
    --jcb-text:       #333333;
    --jcb-radius:     18px;
    --jcb-shadow:     0 12px 48px rgba(0,0,0,0.18);
    --jcb-bot-bubble: var(--jcb-primary);
    --jcb-user-bubble:#e3edff;
    --jcb-z:          99999;
}

/* ── Launcher Button ── */
#jcb-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--jcb-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    z-index: var(--jcb-z);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s;
    outline: none;
}
#jcb-launcher:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 10px 32px rgba(0,0,0,0.3);
}
#jcb-launcher.left-pos { right: auto; left: 24px; }

.jcb-launcher-icon { font-size: 26px; line-height: 1; transition: transform 0.3s; }
#jcb-launcher.open .jcb-launcher-open  { display: none; }
#jcb-launcher.open .jcb-launcher-close { display: flex; }
.jcb-launcher-close { display: none; font-size: 22px; }

/* Unread badge */
#jcb-badge {
    position: absolute;
    top: -4px; right: -4px;
    width: 22px; height: 22px;
    background: #e74c3c;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
#jcb-badge.hidden { display: none; }

/* ── Notification bubbles ── */
#jcb-notifications {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: var(--jcb-z);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    max-width: 260px;
}
#jcb-notifications.left-pos { right: auto; left: 24px; align-items: flex-start; }

.jcb-notif-bubble {
    background: #fff;
    border: 1px solid #e0e8f5;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-width: 240px;
    animation: jcbSlideIn 0.4s ease;
    cursor: pointer;
    line-height: 1.4;
}
.jcb-notif-bubble:hover { background: #f0f6ff; }
.jcb-notif-link { color: var(--jcb-primary); font-weight: 600; display: block; margin-top: 4px; font-size: 12px; }

/* ── Chat Window ── */
#jcb-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 370px;
    max-height: 580px;
    background: var(--jcb-secondary);
    border-radius: var(--jcb-radius);
    box-shadow: var(--jcb-shadow);
    z-index: var(--jcb-z);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: jcbOpen 0.35s cubic-bezier(.34,1.4,.64,1);
}
#jcb-window.visible { display: flex; }
#jcb-window.left-pos { right: auto; left: 24px; }

@keyframes jcbOpen {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes jcbSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
#jcb-header {
    background: var(--jcb-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.jcb-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}
.jcb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.jcb-header-info { flex: 1; }
.jcb-bot-name    { font-weight: 700; font-size: 1rem; }
.jcb-bot-status  { font-size: 0.72rem; opacity: 0.85; }
.jcb-status-dot  { display: inline-block; width: 7px; height: 7px; background: #4ade80; border-radius: 50%; margin-right: 4px; animation: jcbPulse 2s infinite; }
@keyframes jcbPulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

.jcb-header-btns { display: flex; gap: 6px; }
.jcb-hbtn {
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.18);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.jcb-hbtn:hover { background: rgba(255,255,255,0.32); }

/* ── Messages Area ── */
#jcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--jcb-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#jcb-messages::-webkit-scrollbar { width: 4px; }
#jcb-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ── Bubbles ── */
.jcb-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 85%;
    animation: jcbMsgIn 0.25s ease;
}
@keyframes jcbMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.jcb-msg.bot  { align-self: flex-start; }
.jcb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.jcb-msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--jcb-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}
.jcb-msg-avatar img { width:100%;height:100%;object-fit:cover; }

.jcb-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
}
.jcb-msg.bot  .jcb-bubble {
    background: #fff;
    color: var(--jcb-text);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.jcb-msg.user .jcb-bubble {
    background: var(--jcb-primary);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}
.jcb-bubble a { color: inherit; text-decoration: underline; }

/* typing indicator */
.jcb-typing .jcb-bubble {
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.jcb-dot {
    width: 7px; height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: jcbDot 1.2s infinite;
}
.jcb-dot:nth-child(2) { animation-delay: 0.2s; }
.jcb-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes jcbDot {
    0%,80%,100% { transform: scale(1); opacity: 0.5; }
    40%         { transform: scale(1.3); opacity: 1; }
}

/* ── Quick Reply Buttons ── */
.jcb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    max-width: 100%;
}
.jcb-qr {
    padding: 6px 12px;
    border: 1.5px solid var(--jcb-primary);
    border-radius: 50px;
    background: #fff;
    color: var(--jcb-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.jcb-qr:hover { background: var(--jcb-primary); color: #fff; }

/* ── Start Menu ── */
.jcb-start-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}
.jcb-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border: 1.5px solid #e0e8f5;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
    text-align: left;
    transition: all 0.2s;
    width: 100%;
}
.jcb-menu-btn:hover { border-color: var(--jcb-primary); background: #f0f6ff; color: var(--jcb-primary); }
.jcb-menu-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ── Forms inside chat ── */
.jcb-form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; width: 100%; }
.jcb-input-field {
    padding: 9px 12px;
    border: 1.5px solid #dde4ee;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    color: #333;
    font-family: inherit;
}
.jcb-input-field:focus { border-color: var(--jcb-primary); }
.jcb-form-submit {
    padding: 9px;
    background: var(--jcb-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.jcb-form-submit:hover { opacity: 0.88; }

/* Stars for feedback */
.jcb-stars { display: flex; gap: 4px; margin: 4px 0; }
.jcb-star { font-size: 1.4rem; cursor: pointer; color: #ddd; transition: color 0.15s; }
.jcb-star.active, .jcb-star:hover, .jcb-star:hover ~ .jcb-star { color: #f59e0b; }

/* Search results */
.jcb-search-results { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.jcb-search-result {
    background: #fff;
    border: 1px solid #e0e8f5;
    border-radius: 8px;
    padding: 8px 12px;
    text-decoration: none;
    color: #333;
    font-size: 0.83rem;
    display: block;
    transition: all 0.2s;
}
.jcb-search-result:hover { border-color: var(--jcb-primary); color: var(--jcb-primary); }
.jcb-search-result strong { display: block; font-weight: 600; }
.jcb-search-result small { color: #888; }

/* ── Input Row ── */
#jcb-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #eee;
    align-items: center;
    flex-shrink: 0;
}
#jcb-user-input {
    flex: 1;
    border: 1.5px solid #dde4ee;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
    color: #333;
}
#jcb-user-input:focus { border-color: var(--jcb-primary); }
#jcb-send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--jcb-primary);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}
#jcb-send-btn:hover { opacity: 0.85; transform: scale(1.08); }

/* ── GDPR Banner ── */
#jcb-gdpr {
    background: #fffbec;
    border-top: 1px solid #fde68a;
    padding: 10px 14px;
    font-size: 0.78rem;
    color: #666;
    flex-shrink: 0;
}
#jcb-gdpr a { color: var(--jcb-primary); }
#jcb-gdpr-ok {
    float: right;
    background: var(--jcb-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 0.78rem;
    margin-left: 8px;
}

/* ── Dark Theme ── */
.jcb-dark #jcb-window { background: #1a1d2e; }
.jcb-dark #jcb-messages { background: #13151f; }
.jcb-dark .jcb-msg.bot .jcb-bubble { background: #252840; color: #e8e8f5; box-shadow: none; }
.jcb-dark .jcb-menu-btn { background: #252840; border-color: #333550; color: #ccc; }
.jcb-dark .jcb-menu-btn:hover { background: #2e3250; color: #fff; }
.jcb-dark #jcb-input-row { background: #1a1d2e; border-top-color: #333; }
.jcb-dark #jcb-user-input { background: #252840; border-color: #333550; color: #eee; }

/* ── RTL ── */
.jcb-rtl #jcb-window, .jcb-rtl #jcb-launcher, .jcb-rtl #jcb-notifications { right: auto; left: 24px; }
.jcb-rtl .jcb-msg.bot { align-self: flex-end; }
.jcb-rtl .jcb-msg.user { align-self: flex-start; }
.jcb-rtl #jcb-messages { direction: rtl; }

/* Mobile */
@media (max-width: 480px) {
    #jcb-window {
        width: 100vw;
        max-height: 100vh;
        bottom: 0; right: 0;
        border-radius: 18px 18px 0 0;
    }
    #jcb-launcher { bottom: 16px; right: 16px; }
}
