/* ─── Kodica AI Chat Widget ─────────────────────────────────────────────────── */

#kodica-chat-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#kodica-chat-wrapper.pos-right { right: 24px; }
#kodica-chat-wrapper.pos-left  { left: 24px; }

#kodica-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--kodica-color, #2563eb);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    outline: none;
    margin-left: auto;
}
#kodica-chat-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .28);
}
#kodica-chat-toggle svg { transition: transform .3s; }
#kodica-chat-toggle.open svg.icon-chat { display: none; }
#kodica-chat-toggle.open svg.icon-close { display: block !important; }

#kodica-chat-box {
    width: 370px;
    max-height: 600px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 18px 54px rgba(15, 23, 42, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    transform-origin: bottom right;
    transform: scale(.96) translateY(14px);
    opacity: 0;
    transition: transform .24s cubic-bezier(.34,1.4,.64,1), opacity .2s;
    pointer-events: none;
}
#kodica-chat-box.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}
.pos-left #kodica-chat-box { transform-origin: bottom left; }

#kodica-chat-header {
    background: var(--kodica-color, #2563eb);
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.kodica-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.kodica-header-info { flex: 1; }
.kodica-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.kodica-bot-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.kodica-status {
    font-size: 11px;
    color: rgba(255,255,255,.82);
    display: flex;
    align-items: center;
    gap: 4px;
}
.kodica-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
}
.kodica-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.84);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    line-height: 0;
    transition: background .15s;
}
.kodica-close-btn:hover { background: rgba(255,255,255,.15); }

#kodica-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}
#kodica-chat-messages::-webkit-scrollbar { width: 4px; }
#kodica-chat-messages::-webkit-scrollbar-track { background: transparent; }
#kodica-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.kodica-message {
    max-width: 84%;
    animation: kodica-pop .2s cubic-bezier(.34,1.5,.64,1);
}
@keyframes kodica-pop {
    from { transform: scale(.85) translateY(6px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}
.kodica-message.bot  { align-self: flex-start; }
.kodica-message.user { align-self: flex-end; }

.kodica-bubble {
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.kodica-bubble strong { font-weight: 700; }
.kodica-message.bot .kodica-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}
.kodica-message.bot .kodica-bubble a {
    color: var(--kodica-color, #2563eb);
    text-decoration: underline;
}
.kodica-message.user .kodica-bubble {
    background: var(--kodica-color, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.kodica-typing .kodica-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 13px 16px;
}
.kodica-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: kodica-bounce 1.2s infinite;
}
.kodica-dot:nth-child(2) { animation-delay: .18s; }
.kodica-dot:nth-child(3) { animation-delay: .36s; }
@keyframes kodica-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

#kodica-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}
#kodica-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid #dbe4ee;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    max-height: 112px;
    min-height: 46px;
    transition: border .2s, box-shadow .2s, background .2s;
    background: #f8fafc;
    line-height: 1.4;
}
#kodica-chat-input:focus {
    border-color: var(--kodica-color, #2563eb);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}
#kodica-chat-input::placeholder { color: #94a3b8; }

#kodica-chat-send {
    width: 48px;
    min-width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: var(--kodica-color, #2563eb);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, opacity .15s, box-shadow .15s;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .24);
}
#kodica-chat-send svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    display: block;
    margin-left: 1px;
}
#kodica-chat-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, .28);
}
#kodica-chat-send:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#kodica-chat-actions {
    padding: 0 14px 12px;
    background: #fff;
}
#kodica-whatsapp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(37, 211, 102, .20);
    transition: transform .15s, box-shadow .15s, opacity .15s;
}
#kodica-whatsapp-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 211, 102, .26);
    color: #fff;
}
#kodica-whatsapp-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    color: #fff;
}

.kodica-powered {
    text-align: center;
    padding: 7px 0 11px;
    font-size: 11px;
    color: #94a3b8;
    background: #fff;
}
.kodica-powered a {
    color: var(--kodica-color, #2563eb);
    text-decoration: none;
    font-weight: 600;
}
.kodica-powered a:hover { text-decoration: underline; }

@media (max-width: 420px) {
    #kodica-chat-box {
        width: calc(100vw - 24px);
        max-height: 74vh;
    }
    #kodica-chat-wrapper.pos-right { right: 12px; }
    #kodica-chat-wrapper.pos-left  { left: 12px; }
    #kodica-chat-wrapper { bottom: 14px; }
}

.kodica-product-list {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}
.kodica-product-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .06);
}
.kodica-product-thumb {
    height: 126px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 28px;
}
.kodica-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.kodica-product-content {
    padding: 12px;
}
.kodica-product-name {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
    margin-bottom: 6px;
}
.kodica-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.kodica-product-meta span {
    font-size: 11px;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 999px;
}
.kodica-product-meta .price {
    background: rgba(37, 99, 235, .10);
    color: var(--kodica-color, #2563eb);
}
.kodica-product-meta .stock {
    background: #ecfdf5;
    color: #047857;
}
.kodica-product-desc {
    font-size: 12px;
    line-height: 1.45;
    color: #475569;
    margin-bottom: 10px;
}
.kodica-product-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.kodica-product-btn {
    min-height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 700;
    background: var(--kodica-color, #2563eb);
    color: #fff !important;
}
.kodica-product-btn.wa {
    background: #25D366;
}
