/* ============================================================
   Jakuklima AI Chatbot Widget
   Brand: --brand-600: #0284c7  --brand-700: #0369a1
   ============================================================ */

:root {
    --jaku-brand:       #0284c7;
    --jaku-brand-dark:  #0369a1;
    --jaku-brand-light: #e0f2fe;
    --jaku-text:        #0f172a;
    --jaku-muted:       #64748b;
    --jaku-border:      #e2e8f0;
    --jaku-bg:          #f8fafc;
    --jaku-white:       #ffffff;
    --jaku-radius:      16px;
    --jaku-shadow:      0 20px 60px rgba(2, 132, 199, 0.18), 0 4px 16px rgba(0, 0, 0, 0.08);
}

#jaku-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Speech Bubble ─────────────────────────────────────────── */

#jaku-chat-bubble {
    position: absolute;
    bottom: 76px;
    right: 0;
    background: var(--jaku-white);
    color: var(--jaku-text);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border: 1px solid var(--jaku-border);
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    animation: jaku-bubble-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

#jaku-chat-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--jaku-white);
    border-right: 1px solid var(--jaku-border);
    border-bottom: 1px solid var(--jaku-border);
    transform: rotate(45deg);
}

#jaku-chat-bubble.jaku-bubble-hide {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

@keyframes jaku-bubble-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Toggle Button ─────────────────────────────────────────── */

#jaku-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--jaku-brand);
    color: var(--jaku-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(2, 132, 199, 0.45);
    transition: background 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

#jaku-chat-toggle:hover {
    background: var(--jaku-brand-dark);
    box-shadow: 0 6px 28px rgba(2, 132, 199, 0.55);
}

#jaku-chat-toggle svg {
    width: 26px;
    height: 26px;
    pointer-events: none;
}

/* Floating animation */
#jaku-chat-toggle {
    animation: jaku-float 3s ease-in-out infinite;
}

#jaku-chat-toggle.jaku-toggle-open {
    animation: none;
}

@keyframes jaku-float {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

/* Pulse ring */
#jaku-chat-toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(2, 132, 199, 0.35);
    animation: jaku-pulse 2.5s ease-out infinite;
}

#jaku-chat-toggle.jaku-toggle-open::before {
    display: none;
}

@keyframes jaku-pulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    70%  { transform: scale(1.3); opacity: 0; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* ── Chat Window ───────────────────────────────────────────── */

#jaku-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: var(--jaku-white);
    border-radius: var(--jaku-radius);
    box-shadow: var(--jaku-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: jaku-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--jaku-border);
    max-height: 580px;
}

@keyframes jaku-slide-in {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Header ────────────────────────────────────────────────── */

#jaku-chat-header {
    background: linear-gradient(135deg, var(--jaku-brand) 0%, var(--jaku-brand-dark) 100%);
    color: var(--jaku-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#jaku-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#jaku-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#jaku-chat-avatar svg {
    width: 20px;
    height: 20px;
}

#jaku-chat-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

#jaku-chat-status {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 1px;
}

#jaku-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    transition: background 0.15s, color 0.15s;
}

#jaku-chat-close:hover {
    background: rgba(255,255,255,0.15);
    color: var(--jaku-white);
}

/* ── Messages ──────────────────────────────────────────────── */

#jaku-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    scroll-behavior: smooth;
}

#jaku-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#jaku-chat-messages::-webkit-scrollbar-track { background: transparent; }
#jaku-chat-messages::-webkit-scrollbar-thumb {
    background: var(--jaku-border);
    border-radius: 4px;
}

.jaku-msg-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: jaku-fade-up 0.2s ease;
}

@keyframes jaku-fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.jaku-msg-avatar {
    width: 28px;
    height: 28px;
    background: var(--jaku-brand-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--jaku-brand);
}

.jaku-msg-avatar svg {
    width: 14px;
    height: 14px;
}

.jaku-msg-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.jaku-msg-assistant .jaku-msg-bubble {
    background: var(--jaku-bg);
    color: var(--jaku-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--jaku-border);
}

.jaku-msg-user .jaku-msg-bubble {
    background: var(--jaku-brand);
    color: var(--jaku-white);
    border-bottom-right-radius: 4px;
}

.jaku-msg-error .jaku-msg-bubble {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 13px;
}

/* ── Typing indicator ──────────────────────────────────────── */

.jaku-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--jaku-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--jaku-border);
}

.jaku-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--jaku-brand);
    border-radius: 50%;
    animation: jaku-bounce 1.2s infinite;
    opacity: 0.4;
}

.jaku-typing span:nth-child(2) { animation-delay: 0.2s; }
.jaku-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jaku-bounce {
    0%, 80%, 100% { transform: translateY(0);  opacity: 0.4; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Product Cards ─────────────────────────────────────────── */

.jaku-product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: jaku-fade-up 0.25s ease;
}

.jaku-product-card {
    display: flex;
    gap: 12px;
    background: var(--jaku-white);
    border: 1px solid var(--jaku-border);
    border-radius: 12px;
    padding: 10px;
    text-decoration: none;
    color: var(--jaku-text);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
    overflow: hidden;
}

.jaku-product-card:hover {
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.15);
    border-color: var(--jaku-brand);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--jaku-text);
}

.jaku-card-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--jaku-bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jaku-card-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.jaku-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jaku-card-brand {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--jaku-brand);
}

.jaku-card-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--jaku-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.jaku-card-meta {
    display: flex;
    gap: 8px;
    margin-top: 3px;
}

.jaku-card-meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--jaku-muted);
}

.jaku-card-meta-item svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.jaku-card-price {
    font-size: 13px;
    font-weight: 800;
    color: var(--jaku-brand);
    margin-top: 3px;
}

.jaku-card-price .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

/* ── Footer / Input ────────────────────────────────────────── */

#jaku-chat-footer {
    border-top: 1px solid var(--jaku-border);
    padding: 12px 16px;
    background: var(--jaku-white);
    flex-shrink: 0;
}

#jaku-chat-quick-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.jaku-quick-btn {
    background: var(--jaku-brand-light);
    color: var(--jaku-brand-dark);
    border: 1px solid #bae6fd;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
    line-height: 1.4;
}

.jaku-quick-btn:hover {
    background: #bae6fd;
    border-color: #7dd3fc;
}

#jaku-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#jaku-chat-input {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--jaku-border);
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--jaku-text);
    background: var(--jaku-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    line-height: 1.45;
    max-height: 120px;
    overflow-y: auto;
}

#jaku-chat-input:focus {
    border-color: var(--jaku-brand);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
    background: var(--jaku-white);
}

#jaku-chat-input::placeholder {
    color: #94a3b8;
}

#jaku-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--jaku-brand);
    color: var(--jaku-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

#jaku-chat-send:hover:not(:disabled) {
    background: var(--jaku-brand-dark);
    transform: scale(1.05);
}

#jaku-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Mobile ────────────────────────────────────────────────── */

@media (max-width: 440px) {
    #jaku-chat-root {
        bottom: 16px;
        right: 16px;
    }

    #jaku-chat-window {
        width: calc(100vw - 32px);
        bottom: 72px;
        right: 0;
        max-height: 500px;
    }

    #jaku-chat-messages {
        max-height: 260px;
    }
}
