/* Cart Agent — Frontend Styles */

/* ============================================================
   FLOATING BUTTON
   ============================================================ */

.ca-floating-wrap {
    position: fixed;
    bottom: 28px;
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.ca-floating-wrap--left   { left: 28px; align-items: flex-start; }
.ca-floating-wrap--center { left: 50%; transform: translateX(-50%); align-items: center; }
.ca-floating-wrap--right  { right: 28px; align-items: flex-end; }

:root { --ca-accent: #7c3aed; }

.ca-floating-btn {
    pointer-events: auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    min-width: 200px;
    width: auto;
    padding: 0;
    background: linear-gradient(270deg, var(--ca-floating-bg-start, #B98CFF) 0%, var(--ca-floating-bg-end, #803DED) 100%);
    background-size: 200% 200%;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transition: min-width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), max-width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    transform-origin: bottom center;
    outline: none;
    animation: ca-gradient-flow 4s ease infinite;
}

@keyframes ca-gradient-flow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.ca-floating-btn:hover,
.ca-floating-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.ca-floating-btn.is-open {
    min-width: 446px;
    max-width: 600px;
    width: auto;
    background: linear-gradient(270deg, var(--ca-floating-bg-start, #B98CFF) 0%, var(--ca-floating-bg-end, #803DED) 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    cursor: text;
    animation: none;
}

.ca-floating-btn__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 16px;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ca-floating-btn.is-open .ca-floating-btn__trigger {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    position: absolute;
}

.ca-floating-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.ca-floating-btn__svg {
    display: block;
    width: auto;
    height: 100%;
    color: inherit;
}

.ca-floating-btn__svg path {
    fill: currentColor;
}

.ca-floating-btn__text {
    line-height: 1;
}

.ca-floating-btn__form {
    position: absolute;
    inset: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 0 12px;
    background: #fff;
    border-radius: 9px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
    transition: opacity 0.35s ease 0.1s, transform 0.35s ease 0.1s;
}

.ca-floating-btn.is-open .ca-floating-btn__form {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.ca-floating-btn__form-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--ca-floating-bg-end, #803DED);
    flex-shrink: 0;
}

.ca-floating-btn__input {
    flex: 1 1 auto;
    height: 46px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1e293b;
    min-width: 330px;
    font-family: inherit;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
}

.ca-floating-btn__input::placeholder {
    color: #94a3b8;
}

.ca-floating-btn__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #0f172a;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
    padding: 0;
}

.ca-floating-btn__submit svg {
    display: block;
    width: auto;
    height: 16px;
}

.ca-floating-btn__submit:hover,
.ca-floating-btn__submit:focus {
    background: linear-gradient(270deg, var(--ca-floating-bg-start, #B98CFF) 0%, var(--ca-floating-bg-end, #803DED) 100%);
    transform: scale(1.05);
}

.ca-floating-btn__submit:active {
    transform: scale(0.98);
}

@media (max-width: 600px) {
    .ca-floating-wrap--left   { left: 16px; bottom: 16px; }
    .ca-floating-wrap--center { bottom: 16px; }
    .ca-floating-wrap--right  { right: 16px; bottom: 16px; }

    .ca-floating-btn {
        min-width: 180px;
        max-width: 180px;
        width: 180px;
    }

    .ca-floating-btn.is-open {
        min-width: 0;
        max-width: calc(100vw - 32px);
    }

    .ca-floating-btn__input {
        min-width: 0;
    }

    .ca-floating-btn__text {
        font-size: 13px;
    }
}

/* ============================================================
   SEARCH REPLACE INTERCEPTOR (site-wide search override)
   ============================================================ */

.ca-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

.ca-search-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.ca-search-overlay__box {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    width: 560px;
    max-width: calc(100vw - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(-12px);
    transition: transform 0.25s ease;
}

.ca-search-overlay.is-open .ca-search-overlay__box {
    transform: translateY(0);
}

.ca-search-overlay__title {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ca-search-overlay__form {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.15s ease;
}

.ca-search-overlay__form:focus-within {
    border-color: #7c3aed;
}

.ca-search-overlay__icon {
    color: #7c3aed;
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.ca-search-overlay__input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: #1e293b;
    font-family: inherit;
}

.ca-search-overlay__input::placeholder {
    color: #94a3b8;
}

.ca-search-overlay__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ca-search-overlay__submit:hover {
    background: #6d28d9;
}

.ca-search-overlay__close {
    display: block;
    margin-top: 12px;
    font-size: 13px;
    color: #94a3b8;
    text-align: center;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    width: 100%;
    padding: 4px;
}

.ca-search-overlay__close:hover {
    color: #64748b;
}

/* ============================================================
   SHORTCODE SEARCH INPUT
   ============================================================ */

.ca-search-shortcode {
    display: block;
    width: 100%;
}

.ca-search-shortcode__form {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    padding: 8px 8px 8px 16px;
    gap: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ca-search-shortcode__form:focus-within {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.ca-search-shortcode__icon {
    display: flex;
    align-items: center;
    color: #7c3aed;
    margin-right: 10px;
}

.ca-search-shortcode__input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1e293b;
    font-family: inherit;
    min-width: 0;
}

.ca-search-shortcode__input::placeholder {
    color: #94a3b8;
}

.ca-search-shortcode__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.ca-search-shortcode__btn:hover {
    background: #6d28d9;
}

/* ============================================================
   AI SHOPPING ASSISTANT PAGE
   ============================================================ */

.ca-assistant-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    background: #f8fafc;
    padding-top: 100px;
}

/* Conversation area */
.ca-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 28px 20px;
    scroll-behavior: smooth;
}

.ca-chat-area::-webkit-scrollbar { width: 6px; }
.ca-chat-area::-webkit-scrollbar-track { background: transparent; }
.ca-chat-area::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

.ca-chat-inner {
    max-width: 850px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Message rows */
.ca-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: ca-msg-in 0.3s ease;
}

.ca-msg--user {
    flex-direction: row-reverse;
}

@keyframes ca-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ca-msg__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.ca-msg__avatar--ai {
    background: var(--ca-accent);
    color: #fff;
}

.ca-msg__avatar--user {
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.ca-msg__body {
    flex: 1;
    min-width: 0;
}

.ca-msg--user .ca-msg__body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Bubble */
.ca-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
}

.ca-bubble--ai {
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ca-bubble--user {
    background: rgba(0, 0, 0, 0.05); 
    border-radius: 16px 16px 4px 16px;
    max-width: 75%;
    color: black;
}

/* Typing indicator */
.ca-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 16px;
}

.ca-typing__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ca-typing-bounce 1.2s infinite;
}

.ca-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.ca-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ca-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* Suggested follow-ups */
.ca-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ca-suggestion-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    font-size: 13px;
    color: #7c3aed;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.ca-suggestion-chip:hover {
    background: #f5f3ff;
    border-color: #7c3aed;
}

/* Welcome suggestions (initial state) */
.ca-welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.ca-welcome-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    font-size: 13px;
    color: #7c3aed;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.ca-welcome-chip:hover {
    background: #f5f3ff;
    border-color: #7c3aed;
    box-shadow: 0 2px 8px rgba(109,40,217,0.12);
}

/* ============================================================
   PRODUCT CARDS
   ============================================================ */

.ca-product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 14px;
    width: 100%;
}

@media (max-width: 640px) {
    .ca-product-grid { grid-template-columns: 1fr; }
}

@media (min-width: 641px) and (max-width: 860px) {
    .ca-product-grid { grid-template-columns: repeat(2, 1fr); }
}

.ca-product-card {
    background: #fff;
    border: 1.5px solid #f1f5f9;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ca-product-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.ca-product-card__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 100px;
    background: #7c3aed;
    color: #fff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ca-product-card__image-wrap {
    position: relative;
    background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ca-product-card__image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ca-product-card__image-placeholder {
    color: rgba(255,255,255,0.6);
}

.ca-product-card__body {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ca-product-card__brand {
    font-size: 10px;
    font-weight: 700;
    color: #7c3aed;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ca-product-card__name {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin: 0;
}

.ca-product-card__desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    margin: 0;
}

.ca-product-card__rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.ca-product-card__stars {
    color: #f59e0b;
    letter-spacing: 1px;
    font-size: 11px;
}

.ca-product-card__rating-count {
    color: #94a3b8;
}

.ca-product-card__features {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ca-product-card__features li {
    font-size: 12px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ca-product-card__features li::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid #22c55e;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2322c55e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 9px;
    flex-shrink: 0;
}

.ca-product-card__footer {
    padding: 12px 14px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ca-product-card__price {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.ca-product-card__stock {
    font-size: 11px;
    font-weight: 600;
    color: #22c55e;
}

.ca-product-card__actions {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ca-btn-add-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
    text-decoration: none;
}

.ca-btn-add-cart:hover {
    background: #6d28d9;
    color: #fff;
}

.ca-btn-view {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px;
    background: transparent;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    text-decoration: none;
}

.ca-btn-view:hover {
    border-color: #7c3aed;
    color: #7c3aed;
}

/* ============================================================
   CHAT INPUT BAR
   ============================================================ */

.ca-chat-input-bar {
    flex-shrink: 0;
    padding: 14px 20px 18px;
}

.ca-chat-input-wrap {
    max-width: 760px;
    margin: 0 auto;
}

.ca-chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #ffffff;
    border: 1.5px solid #c5cdd7;
    border-radius: 16px;
    padding: 10px 10px 10px 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ca-chat-input-form:focus-within {
    border-color: var(--ca-accent);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
    background: #fff;
}

.ca-chat-input-form__icon {
    display: flex;
    align-items: center;
    color: var(--ca-accent);
    flex-shrink: 0;
    margin-bottom: 8px;
}

.ca-chat-input-form__icon svg {
    display: block;
    width: auto;
    height: 18px;
}

.ca-chat-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1e293b;
    line-height: 1.5;
    resize: none;
    min-height: 28px;
    max-height: 160px;
    overflow-y: auto;
    font-family: inherit;
    padding: 0;
}

.ca-chat-textarea::placeholder {
    color: #94a3b8;
}

.ca-chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #0f172a;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s ease, transform 0.15s ease, opacity 0.15s ease;
}

.ca-chat-send-btn svg {
    display: block;
    width: auto;
    height: 16px;
}

.ca-chat-send-btn:hover:not(:disabled),
.ca-chat-send-btn:focus:not(:disabled) {
    background: linear-gradient(270deg, var(--ca-floating-bg-start, #B98CFF) 0%, var(--ca-floating-bg-end, #803DED) 100%);
    transform: scale(1.05);
}

.ca-chat-send-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.ca-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #0f172a;
    transform: none;
}

.ca-chat-hint {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin: 8px 0 0;
}

/* ============================================================
   LOCKED / UPGRADE STATE
   ============================================================ */

.ca-locked-state {
    max-width: 480px;
    margin: 60px auto;
    text-align: center;
    padding: 40px 32px;
    background: #fff;
    border-radius: 20px;
    border: 1.5px solid #f1f5f9;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.ca-locked-state__icon {
    width: 64px;
    height: 64px;
    background: var(--ca-accent, #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: #fff;
}

.ca-locked-state__title {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 10px;
}

.ca-locked-state__desc {
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 24px;
}

.ca-locked-state__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(270deg, var(--ca-floating-bg-start, #B98CFF) 0%, var(--ca-floating-bg-end, #803DED) 100%);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease;
}

.ca-locked-state__btn:hover {
    filter: brightness(0.95);
    color: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .ca-floating-wrap--left   { left: 16px; bottom: 16px; }
    .ca-floating-wrap--center { bottom: 16px; }
    .ca-floating-wrap--right  { right: 16px; bottom: 16px; }

    .ca-floating-btn {
        height: 40px;
        padding: 0 16px 0 12px;
        font-size: 13px;
    }

    .ca-chat-area { padding: 16px 12px; }
    .ca-chat-input-bar { padding: 10px 12px 14px; }
    .ca-bubble { max-width: 92%; }
}

/* Legacy compat — keep old class in case anything references it */
.cartagent-floating-search { display: none !important; }
