/* ===========================================
   AKB AI Asistan - Premium Chat UI
   =========================================== */

:root {
    --akb-primary: #0e4a3e;
    --akb-primary-light: #1a6b5a;
    --akb-primary-soft: #e8f5f0;
    --akb-accent: #00c896;
    --akb-accent-glow: rgba(0, 200, 150, 0.3);
    --akb-bg: #ffffff;
    --akb-bg-chat: #f4f7f6;
    --akb-text: #1a1a2e;
    --akb-text-light: #6b7c85;
    --akb-border: #e2e8f0;
    --akb-shadow-lg: 0 25px 65px rgba(0, 0, 0, 0.18);
    --akb-shadow-btn: 0 6px 24px rgba(14, 74, 62, 0.4);
    --akb-radius: 20px;
    --akb-radius-msg: 16px;
    --akb-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --akb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Floating Button ---- */
#akb-ai-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
    cursor: pointer;
    transition: transform var(--akb-transition);
}

#akb-ai-btn:hover {
    transform: scale(1.08);
}

.akb-ai-btn-inner {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, var(--akb-primary), var(--akb-primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--akb-shadow-btn);
    transition: all var(--akb-transition);
}

#akb-ai-btn:hover .akb-ai-btn-inner {
    box-shadow: 0 8px 32px rgba(14, 74, 62, 0.55);
}

.akb-ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: akbBadgePop 0.3s ease;
}

@keyframes akbBadgePop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.akb-ai-icon-chat, .akb-ai-icon-close {
    transition: all 0.25s ease;
}

.akb-ai-btn-inner.is-open .akb-ai-icon-chat {
    display: none;
}

.akb-ai-btn-inner.is-open .akb-ai-icon-close {
    display: block !important;
}

/* ---- Chat Window ---- */
#akb-ai-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 580px;
    max-height: calc(100vh - 140px);
    background: var(--akb-bg);
    border-radius: var(--akb-radius);
    box-shadow: var(--akb-shadow-lg);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: akbSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0,0,0,0.06);
    font-family: var(--akb-font);
}

#akb-ai-chat.akb-ai-hidden {
    display: none;
}

@keyframes akbSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Header ---- */
.akb-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(145deg, var(--akb-primary), var(--akb-primary-light));
    flex-shrink: 0;
}

.akb-ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.akb-ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.akb-ai-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
}

.akb-ai-header-status {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.akb-ai-status-dot {
    width: 7px;
    height: 7px;
    background: var(--akb-accent);
    border-radius: 50%;
    display: inline-block;
    animation: akbPulse 2s ease infinite;
}

@keyframes akbPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#akb-ai-minimize {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--akb-transition);
    padding: 0;
}

#akb-ai-minimize:hover {
    background: rgba(255,255,255,0.25);
}

/* ---- Messages Area ---- */
#akb-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--akb-bg-chat);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#akb-ai-messages::-webkit-scrollbar {
    width: 5px;
}

#akb-ai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Message bubbles */
.akb-ai-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: akbMsgIn 0.3s ease;
}

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

.akb-ai-msg.bot {
    align-self: flex-start;
}

.akb-ai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.akb-ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.akb-ai-msg.bot .akb-ai-msg-avatar {
    background: var(--akb-primary-soft);
}

.akb-ai-msg.user .akb-ai-msg-avatar {
    background: var(--akb-primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.akb-ai-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--akb-radius-msg);
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}

.akb-ai-msg.bot .akb-ai-msg-bubble {
    background: var(--akb-bg);
    color: var(--akb-text);
    border: 1px solid var(--akb-border);
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.akb-ai-msg.user .akb-ai-msg-bubble {
    background: linear-gradient(145deg, var(--akb-primary), var(--akb-primary-light));
    color: #fff;
    border-top-right-radius: 4px;
}

/* Product cards inside messages */
.akb-ai-products-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0 4px;
    scrollbar-width: none;
}

.akb-ai-products-row::-webkit-scrollbar {
    display: none;
}

.akb-ai-product-card {
    min-width: 140px;
    max-width: 140px;
    background: var(--akb-bg);
    border: 1px solid var(--akb-border);
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    transition: all var(--akb-transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.akb-ai-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-color: var(--akb-accent);
}

.akb-ai-product-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.akb-ai-product-card-info {
    padding: 8px 10px;
}

.akb-ai-product-card-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--akb-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin: 0 0 4px 0;
}

.akb-ai-product-card-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--akb-primary);
}

.akb-ai-product-card-stock {
    font-size: 10px;
    color: var(--akb-accent);
    font-weight: 600;
    margin-top: 2px;
}

.akb-ai-product-card-stock.out {
    color: #ef4444;
}

/* Typing indicator */
.akb-ai-typing {
    display: flex;
    gap: 5px;
    padding: 8px 0;
    align-items: center;
}

.akb-ai-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--akb-text-light);
    border-radius: 50%;
    animation: akbTyping 1.4s ease infinite;
}

.akb-ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.akb-ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes akbTyping {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* ---- Quick Actions ---- */
#akb-ai-quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    background: var(--akb-bg);
    border-top: 1px solid var(--akb-border);
    flex-shrink: 0;
    scrollbar-width: none;
}

#akb-ai-quick-actions::-webkit-scrollbar {
    display: none;
}

#akb-ai-quick-actions.akb-ai-hidden {
    display: none;
}

.akb-ai-quick-btn {
    white-space: nowrap;
    padding: 7px 14px;
    background: var(--akb-primary-soft);
    border: 1px solid #d1e7dd;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--akb-primary);
    cursor: pointer;
    transition: all var(--akb-transition);
    flex-shrink: 0;
    font-family: var(--akb-font);
}

.akb-ai-quick-btn:hover {
    background: var(--akb-primary);
    color: #fff;
    border-color: var(--akb-primary);
}

/* ---- Input Area ---- */
.akb-ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: var(--akb-bg);
    border-top: 1px solid var(--akb-border);
    flex-shrink: 0;
}

#akb-ai-input {
    flex: 1;
    border: 1.5px solid var(--akb-border);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--akb-font);
    resize: none;
    outline: none;
    transition: border-color var(--akb-transition);
    max-height: 100px;
    line-height: 1.4;
    color: var(--akb-text);
    background: var(--akb-bg-chat);
}

#akb-ai-input:focus {
    border-color: var(--akb-accent);
    background: var(--akb-bg);
}

#akb-ai-input::placeholder {
    color: var(--akb-text-light);
}

#akb-ai-send {
    width: 42px;
    height: 42px;
    background: linear-gradient(145deg, var(--akb-primary), var(--akb-primary-light));
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--akb-transition);
    flex-shrink: 0;
    padding: 0;
}

#akb-ai-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(14, 74, 62, 0.3);
}

#akb-ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---- Footer ---- */
.akb-ai-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--akb-text-light);
    background: var(--akb-bg);
    border-top: 1px solid var(--akb-border);
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

/* ---- Utility ---- */
.akb-ai-hidden {
    display: none !important;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    #akb-ai-chat {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        animation: akbSlideUpMobile 0.35s ease-out;
    }

    @keyframes akbSlideUpMobile {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }

    #akb-ai-btn {
        bottom: 16px;
        right: 16px;
    }

    .akb-ai-btn-inner {
        width: 54px;
        height: 54px;
    }
}

/* Dark mode */
[data-wp-dark-mode-active="true"] #akb-ai-chat {
    --akb-bg: #1a1a2e;
    --akb-bg-chat: #16162a;
    --akb-text: #e4e4e7;
    --akb-text-light: #8b95a5;
    --akb-border: #2d2d4a;
    --akb-primary-soft: #1a2e28;
    --akb-shadow-lg: 0 25px 65px rgba(0, 0, 0, 0.4);
}

[data-wp-dark-mode-active="true"] .akb-ai-msg.bot .akb-ai-msg-bubble {
    background: #22223a;
    border-color: #2d2d4a;
}

[data-wp-dark-mode-active="true"] .akb-ai-product-card {
    background: #22223a;
    border-color: #2d2d4a;
}

[data-wp-dark-mode-active="true"] #akb-ai-input {
    background: #22223a;
    border-color: #2d2d4a;
    color: #e4e4e7;
}
