/* AI Chat WAT - Widget Styles */

#acw-wrap {
    position: fixed;
    bottom: 80px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    left: 10px;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --acw-primary: #1565C0;
}

/* ===================== Floating Button ===================== */
#acw-btn {
    position: relative;
    width: 56px;
    height: 56px;
    background: linear-gradient(145deg, var(--acw-primary), color-mix(in srgb, var(--acw-primary) 75%, #000));
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0,0,0,0.28);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: acw-float 3s ease-in-out infinite;
    user-select: none;
}

#acw-btn:hover,
#acw-btn:focus {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.36);
    outline: none;
}

@keyframes acw-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

#acw-btn:hover { animation-play-state: paused; }

.acw-btn-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    transition: opacity 0.3s;
}

.acw-btn-badge.hidden { opacity: 0; pointer-events: none; }

/* ===================== Chat Window ===================== */
#acw-window {
    width: 340px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    max-height: 560px;
    transform-origin: bottom right;
}

#acw-window.acw-open {
    display: flex;
    animation: acw-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes acw-pop-in {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(16px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===================== Header ===================== */
#acw-header {
    background: linear-gradient(135deg, var(--acw-primary) 0%, color-mix(in srgb, var(--acw-primary) 80%, #000) 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.acw-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acw-avatar-wrap {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.acw-bot-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

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

.acw-dot {
    width: 8px;
    height: 8px;
    background: #69f0ae;
    border-radius: 50%;
    flex-shrink: 0;
    animation: acw-pulse 2.2s ease-in-out infinite;
}

.acw-dot-off {
    background: #ffca28;
    animation: none;
}

@keyframes acw-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.55; transform: scale(0.85); }
}

.acw-header-actions {
    display: flex;
    gap: 6px;
}

.acw-icon-btn {
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
    margin: 0;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit;
    font-weight: normal;
}

.acw-icon-btn:hover {
    background: rgba(255,255,255,0.32);
}

/* ===================== Messages ===================== */
#acw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f7fb;
    min-height: 200px;
    max-height: 330px;
    scroll-behavior: smooth;
}

#acw-messages::-webkit-scrollbar { width: 5px; }
#acw-messages::-webkit-scrollbar-track { background: transparent; }
#acw-messages::-webkit-scrollbar-thumb { background: #d0d5e0; border-radius: 3px; }

.acw-timestamp {
    text-align: center;
    font-size: 11px;
    color: #a0a8b8;
    margin: 4px 0 6px;
    flex-shrink: 0;
}

/* Message row */
.acw-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    max-width: 88%;
}

.acw-msg-bot  { align-self: flex-start; }
.acw-msg-user { align-self: flex-end; flex-direction: row-reverse; }

/* Bot avatar in messages */
.acw-msg-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--acw-primary), color-mix(in srgb, var(--acw-primary) 75%, #000));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
}

/* Bubble */
.acw-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    max-width: 100%;
}

.acw-msg-bot .acw-bubble {
    background: #fff;
    color: #1a1d23;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.acw-msg-user .acw-bubble {
    background: var(--acw-primary);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

/* Error state */
.acw-msg-error .acw-bubble {
    background: #fce8e6;
    color: #b71c1c;
}

/* Typing dots */
.acw-typing .acw-bubble {
    padding: 11px 16px;
}

.acw-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 14px;
}

.acw-typing-dots span {
    width: 7px;
    height: 7px;
    background: #b0bbc8;
    border-radius: 50%;
    animation: acw-blink 1.5s ease-in-out infinite;
}

.acw-typing-dots span:nth-child(2) { animation-delay: 0.22s; }
.acw-typing-dots span:nth-child(3) { animation-delay: 0.44s; }

@keyframes acw-blink {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-7px); opacity: 1; }
}

/* ===================== Input Area ===================== */
#acw-input-wrap {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #edf0f5;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}

#acw-input {
    flex: 1;
    border: 1.5px solid #e2e6ee;
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    outline: none;
    background: #f8f9fb;
    transition: border-color 0.2s, background 0.2s;
    color: #1a1d23;
    font-family: inherit;
    min-width: 0;
    resize: none;
    overflow: hidden;
    height: auto;
    min-height: 38px;
    max-height: 120px;
    display: block;
    box-sizing: border-box;
    word-break: break-word;
    margin: 0;
}

#acw-input::placeholder { color: #a0a8b8; }

#acw-input:focus {
    border-color: var(--acw-primary);
    background: #fff;
}

#acw-input.is-overflow {
    overflow-y: auto;
}

#acw-send {
    width: 38px;
    height: 38px;
    background: var(--acw-primary) !important;
    border-radius: 50%;
    color: #fff;
    transition: opacity 0.2s, transform 0.15s;
}

#acw-send:hover  { opacity: 0.88; }
#acw-send:active { transform: scale(0.90); }
#acw-send.acw-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

/* ===================== Footer ===================== */
#acw-footer {
    text-align: center;
    font-size: 10.5px;
    color: #b0bbc8;
    padding: 5px 12px 8px;
    background: #fff;
    border-top: 1px solid #f0f2f7;
    flex-shrink: 0;
    line-height: 1.4;
}

/* ===================== Product cards ===================== */
.acw-msg-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
}

.acw-products {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.acw-products::-webkit-scrollbar { height: 4px; }
.acw-products::-webkit-scrollbar-thumb { background: #d0d5e0; border-radius: 3px; }

.acw-product-card {
    flex: 0 0 138px;
    width: 138px;
    background: #fff;
    border: 1px solid #e8ebf2;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    transition: box-shadow 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.acw-product-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
    transform: translateY(-2px);
}

.acw-product-img {
    width: 100%;
    height: 110px;
    background: #f5f7fb center/contain no-repeat;
    flex-shrink: 0;
}

.acw-product-img-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--acw-primary);
    background: #eef2f8;
}

.acw-product-info {
    padding: 8px 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.acw-product-title {
    font-size: 12px;
    line-height: 1.35;
    color: #1a1d23;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 32px;
}

.acw-product-price {
    font-size: 13px;
    font-weight: 700;
    color: #e53935;
}

.acw-product-btn {
    margin-top: auto;
    text-align: center;
    font-size: 11.5px;
    font-weight: 600;
    color: #fff;
    background: var(--acw-primary);
    border-radius: 14px;
    padding: 5px 0;
}

/* ===================== Admin message ===================== */
.acw-msg-admin .acw-bubble {
    background: linear-gradient(180deg, #fffaf0 0%, #fff5e0 100%);
    color: #1a1d23;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 2px 10px rgba(217,119,6,0.12);
    border: 1px solid #fde6bd;
    padding: 8px 14px 10px;
}

.acw-msg-icon-admin {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    box-shadow: 0 2px 6px rgba(217,119,6,0.35);
}

.acw-admin-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    color: #c2780a;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #f3d79b;
}

.acw-admin-label svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.acw-msg-admin .acw-bubble > span {
    font-size: 13.5px;
    line-height: 1.55;
    color: #5a4a2a;
}

/* ===================== Responsive ===================== */
@media (max-width: 400px) {
    #acw-window {
        width: calc(100vw - 24px);
        border-radius: 14px;
    }
}
