/* ==========================================================
   Jamii AI Widget — Optional External Stylesheet  v1.0.0
   Only needed if you disable the built-in CSS injection.
   The widget auto-injects styles by default; this file is
   provided for customers who prefer to host CSS separately.
   ========================================================== */

/* ---- FAB (Floating Action Button) ---- */
.jcb-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #7c3aed;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124,58,237,.35), 0 2px 8px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.jcb-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(124,58,237,.45), 0 4px 12px rgba(0,0,0,.4);
}
.jcb-fab-icon {
    width: 24px; height: 24px;
    position: absolute;
    transition: opacity .25s, transform .3s;
}
.jcb-fab-icon--chat  { opacity: 1; transform: rotate(0deg); }
.jcb-fab-icon--close { opacity: 0; transform: rotate(-90deg); }
.jcb-fab--open .jcb-fab-icon--chat  { opacity: 0; transform: rotate(90deg); }
.jcb-fab--open .jcb-fab-icon--close { opacity: 1; transform: rotate(0deg); }

/* ---- Panel ---- */
.jcb-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-height: 560px;
    border-radius: 16px;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(124,58,237,.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .3s cubic-bezier(.4,0,.2,1),
                transform .3s cubic-bezier(.4,0,.2,1),
                visibility .3s;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #e2e8f0;
}
.jcb-panel.jcb-open {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}

/* ---- Header ---- */
.jcb-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(124,58,237,.15), rgba(34,211,238,.08));
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.jcb-header-info { display: flex; align-items: center; gap: 10px; }
.jcb-header-avatar { width: 32px; height: 32px; flex-shrink: 0; }
.jcb-header-avatar svg { width: 100%; height: 100%; }
.jcb-header-title {
    font-size: .88rem; font-weight: 700; color: #f1f5f9; line-height: 1.2;
}
.jcb-header-subtitle {
    font-size: .72rem; color: #94a3b8; line-height: 1.3;
}
.jcb-header-actions { display: flex; gap: 4px; }
.jcb-icon-btn {
    width: 30px; height: 30px; border: none; border-radius: 8px;
    background: transparent; color: #94a3b8; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, color .2s;
}
.jcb-icon-btn:hover { background: rgba(255,255,255,.08); color: #f1f5f9; }
.jcb-icon-btn svg { width: 16px; height: 16px; }

/* ---- Login view ---- */
.jcb-login { display: none; flex: 1; overflow-y: auto; }
.jcb-login.jcb-active { display: flex; }
.jcb-login-form {
    display: flex; flex-direction: column; gap: 14px; padding: 24px 20px;
}
.jcb-login-header { text-align: center; margin-bottom: 4px; }
.jcb-login-avatar { width: 48px; height: 48px; margin: 0 auto 12px; }
.jcb-login-avatar svg { width: 100%; height: 100%; }
.jcb-login-header h3 {
    font-size: .95rem; font-weight: 700; color: #f1f5f9; margin: 0 0 4px;
}
.jcb-login-header p { font-size: .78rem; color: #94a3b8; margin: 0; }
.jcb-login-error {
    display: none; font-size: .78rem; color: #fb7185;
    background: rgba(251,113,133,.08); border: 1px solid rgba(251,113,133,.2);
    border-radius: 8px; padding: 8px 12px; text-align: center;
}
.jcb-login-error.jcb-active { display: block; }
.jcb-field { display: flex; flex-direction: column; gap: 4px; }
.jcb-field span { font-size: .78rem; font-weight: 600; color: #94a3b8; }
.jcb-field input {
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
    color: #f1f5f9; font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: .85rem; outline: none; transition: border-color .2s;
}
.jcb-field input:focus { border-color: rgba(124,58,237,.67); }
.jcb-login-btn {
    padding: 10px; border: none; border-radius: 10px;
    background: #7c3aed; color: #fff;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: .85rem; font-weight: 600;
    cursor: pointer; transition: background .2s; margin-top: 4px;
}
.jcb-login-btn:hover { filter: brightness(0.85); }
.jcb-login-btn:disabled { opacity: .6; cursor: wait; }

/* ---- Chat view ---- */
.jcb-chat { display: none; flex-direction: column; flex: 1; min-height: 0; }
.jcb-chat.jcb-active { display: flex; }
.jcb-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    min-height: 280px; max-height: 380px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent;
}
.jcb-messages::-webkit-scrollbar { width: 5px; }
.jcb-messages::-webkit-scrollbar-track { background: transparent; }
.jcb-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12); border-radius: 10px;
}
.jcb-msg {
    display: flex; gap: 8px; align-items: flex-end;
    animation: jcb-fadeIn .3s ease;
}
.jcb-msg--user { flex-direction: row-reverse; }
.jcb-msg-avatar { width: 24px; height: 24px; flex-shrink: 0; }
.jcb-msg-avatar svg { width: 100%; height: 100%; }
.jcb-msg-content {
    max-width: 78%; padding: 10px 14px; border-radius: 16px;
    font-size: .84rem; line-height: 1.5; word-break: break-word; white-space: pre-wrap;
}
.jcb-msg--user .jcb-msg-content {
    background: #7c3aed; color: #fff; border-bottom-right-radius: 4px;
}
.jcb-msg--assistant .jcb-msg-content {
    background: rgba(255,255,255,.04); color: #e2e8f0;
    border: 1px solid rgba(255,255,255,.08); border-bottom-left-radius: 4px;
}

/* ---- Thinking animation ---- */
.jcb-dots { display: inline-flex; gap: 4px; padding: 2px 0; }
.jcb-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #94a3b8; animation: jcb-bounce .6s ease-in-out infinite;
}
.jcb-dots span:nth-child(2) { animation-delay: .15s; }
.jcb-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes jcb-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}
@keyframes jcb-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Input bar ---- */
.jcb-input-form {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08);
    background: #1a1a2e; flex-shrink: 0;
}
.jcb-input {
    flex: 1; padding: 10px 14px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
    color: #f1f5f9; font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: .84rem; outline: none; transition: border-color .2s;
}
.jcb-input:focus { border-color: rgba(124,58,237,.67); }
.jcb-input::placeholder { color: #475569; }
.jcb-send-btn {
    width: 38px; height: 38px; border: none; border-radius: 10px;
    background: #7c3aed; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background .2s, transform .15s;
}
.jcb-send-btn:hover { filter: brightness(0.85); transform: scale(1.05); }
.jcb-send-btn:disabled { opacity: .5; cursor: wait; }
.jcb-send-btn svg { width: 16px; height: 16px; }

/* ---- Powered-by footer ---- */
.jcb-powered {
    text-align: center; padding: 6px 14px 8px;
    font-size: .68rem; color: #475569;
    border-top: 1px solid rgba(255,255,255,.05);
}
.jcb-powered a {
    color: #7c3aed; text-decoration: none; font-weight: 600;
}
.jcb-powered a:hover { text-decoration: underline; }

/* ---- Mobile responsive ---- */
@media (max-width: 480px) {
    .jcb-panel {
        width: calc(100vw - 16px);
        right: 8px; left: 8px;
        bottom: 88px;
        max-height: calc(100vh - 120px);
        border-radius: 16px;
    }
    .jcb-fab { bottom: 16px; right: 16px; left: auto; }
}
