/* ── Sartorom AI Search ── all colours via Astra CSS variables ─────────── */

/* ── Search input ──────────────────────────────────────────────────────── */

.sar-search-wrap {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.sar-search-input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: calc(var(--ast-border-radius, 4px) + 4px);
    font-family: var(--ast-body-font-family, inherit);
    font-size: 1.05rem;
    color: #333 !important;
    background: #fff !important;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.sar-search-input::placeholder {
    color: #999 !important;
    opacity: 1 !important;
}

.sar-search-input:focus {
    border-color: var(--ast-global-color-0, #0073aa);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ast-global-color-0, #0073aa) 15%, transparent);
}

/* ── Autocomplete dropdown ─────────────────────────────────────────────── */

.sar-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: calc(var(--ast-border-radius, 4px) + 4px);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.07),
        0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.03);
    z-index: 9999;
    overflow: hidden;
    animation: sar-dropdown-in 0.2s ease-out;
}

@keyframes sar-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sar-ac-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 60px;
}

.sar-ac-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f5f5f5;
}

.sar-ac-item:last-of-type {
    border-bottom: none;
}

.sar-ac-item:hover,
.sar-ac-item.sar-ac-active {
    background: color-mix(in srgb, var(--ast-global-color-0, #0073aa) 8%, transparent);
}

.sar-ac-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border: 1px solid #f0f0f0;
    border-radius: calc(var(--ast-border-radius, 4px) + 2px);
    flex-shrink: 0;
    background: #fafafa;
    padding: 4px;
}

.sar-ac-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sar-ac-name {
    font-size: 0.925rem;
    font-weight: 500;
    /* color: var(--ast-global-color-4, #333); */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sar-ac-cat {
    font-size: 0.72rem;
    /* color: var(--ast-global-color-5, #888); */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.sar-ac-price {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ast-global-color-0, #0073aa);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.sar-ac-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--ast-global-color-0, #0073aa);
    cursor: pointer;
    text-align: right;
    transition: background 0.15s ease;
}

.sar-ac-footer:hover {
    background: color-mix(in srgb, var(--ast-global-color-0, #0073aa) 8%, transparent);
    text-decoration: underline;
}

/* ── Spinner (used in autocomplete and results page) ───────────────────── */

.sar-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: var(--ast-global-color-0, #0073aa);
    border-radius: 50%;
    animation: sar-spin 0.7s linear infinite;
}

@keyframes sar-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Results page ──────────────────────────────────────────────────────── */

.sar-results-page {
    padding-bottom: 60px;
}

.sar-results-header {
    padding: 40px 0 24px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 40px;
}

.sar-results-form {
    display: flex !important;
    width: 100% !important;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.sar-results-form .sar-search-wrap {
    flex: 1;
    max-width: 680px;
    margin-left: 0;
    margin-right: 0;
}

/* Force results page input to match shortcode input exactly */
.sar-results-form .sar-search-input {
    width: 100% !important;
    padding: 14px 20px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: calc(var(--ast-border-radius, 4px) + 4px) !important;
    font-family: var(--ast-body-font-family, inherit) !important;
    font-size: 1.05rem !important;
    color: #333 !important;
    background: #fff !important;
    box-shadow: none !important;
    outline: none !important;
    height: auto !important;
    margin: 0 !important;
    transition: border-color 0.25s ease, box-shadow 0.25s ease !important;
}

.sar-results-form .sar-search-input:focus {
    border-color: var(--ast-global-color-0, #0073aa) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ast-global-color-0, #0073aa) 15%, transparent) !important;
}

.sar-results-form .sar-search-input::placeholder {
    color: #999 !important;
    opacity: 1 !important;
}

.sar-search-btn {
    padding: 14px 28px;
    background: var(--ast-global-color-0, #0073aa);
    color: #fff;
    border: none;
    border-radius: calc(var(--ast-border-radius, 4px) + 4px);
    font-family: var(--ast-body-font-family, inherit);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

.sar-search-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}


.sar-results-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 0;
    color: var(--ast-global-color-5, #888);
    grid-column: 1 / -1;
}

.sar-results-loading .sar-spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.sar-no-results {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--ast-global-color-5, #888);
    padding: 60px 0;
}

/* ── Product grid ──────────────────────────────────────────────────────── */

.sar-results-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
}

@media (max-width: 1023px) {
    .sar-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sar-search-wrap {
        max-width: 100%;
    }
}

@media (max-width: 599px) {
    .sar-results-grid {
        grid-template-columns: 1fr;
    }

    .sar-search-wrap {
        max-width: 100%;
    }

    .sar-search-input {
        padding: 12px 16px;
        font-size: 1rem;
    }

    .sar-search-btn {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .sar-ac-img {
        width: 44px;
        height: 44px;
        padding: 2px;
    }

    .sar-ac-item {
        gap: 10px;
        padding: 10px 12px;
    }

    .sar-ac-name {
        font-size: 0.85rem;
    }

    .sar-ac-price {
        font-size: 0.85rem;
    }
}

/* ── Product card — mirrors Astra's WooCommerce product card style ──────── */

.sar-product-card {
    border-radius: var(--ast-border-radius, 4px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

/* .sar-product-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
} */

.sar-product-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.sar-product-img {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f0f0f0;
    padding: 16px;
    background: #fff;
}

.sar-product-img img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.sar-product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    background: #f5f7f9;
    gap: 6px;
}

.sar-product-cat {
    font-size: 0.7rem;
    /* color: var(--ast-global-color-5, #888); */
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.sar-product-name {
    font-family: var(--ast-body-font-family, inherit);
    font-size: 0.95rem;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

.sar-product-price {
    font-weight: 700;
    color: var(--ast-global-color-0, #0073aa);
    font-size: 1.05rem;
}

.sar-product-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 16px 7px;
    background: rgb(44, 47, 151);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    transition: opacity 0.2s;
    font-family: 'Lato', sans-serif;
    font-size: 0.875rem;
    line-height: 1em;
    text-transform: uppercase;
}

/* .sar-product-card:hover .sar-product-btn {
    opacity: 0.85;
} */

/* ── Chat widget toggle button ─────────────────────────────────────────── */

#sar-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
}

#sar-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgb(44, 47, 151);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: transform 0.2s, opacity 0.3s;
    z-index: 99999 !important;
}

#sar-chat-toggle svg {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0;
    stroke: #fff;
}

#sar-chat-toggle.sar-chat-visible {
    opacity: 1;
}

#sar-chat-toggle:hover {
    transform: scale(1.05);
}

/* ── Chat panel ────────────────────────────────────────────────────────── */

#sar-chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s, opacity 0.2s;
    transform-origin: bottom right;
}

#sar-chat-panel.sar-chat-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

@media (max-width: 440px) {
    #sar-chat-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 80vh;
        border-radius: 12px 12px 0 0;
    }
}

.sar-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgb(44, 47, 151);
    color: #fff;
    font-weight: 700;
    font-family: var(--ast-body-font-family, inherit);
    flex-shrink: 0;
}

.sar-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    padding: 0 4px;
}

.sar-chat-close:hover {
    opacity: 1;
}

#sar-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Message bubbles ───────────────────────────────────────────────────── */

.sar-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: var(--ast-body-font-family, inherit);
    font-size: 0.9rem;
    line-height: 1.5;
}

.sar-msg-ai {
    align-self: flex-start;
    background: color-mix(in srgb, var(--ast-global-color-0, #0073aa) 10%, white);
    /* color: var(--ast-global-color-4, #333); */
    border-bottom-left-radius: 4px;
}

.sar-msg-user {
    align-self: flex-end;
    background: rgb(44, 47, 151);
    border: 1px solid #e5e5e5;
    color: #fff;
    /* color: var(--ast-global-color-4, #333); */
    border-bottom-right-radius: 4px;
}

.sar-citation {
    color: var(--ast-global-color-0, #0073aa);
    font-weight: 700;
    text-decoration: underline;
}

/* ── Chat product citation cards ───────────────────────────────────────── */

.sar-product-citation {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.sar-product-citation:hover {
    background: rgba(255, 255, 255, 0.75);
}

.sar-citation-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 4px;
    flex-shrink: 0;
}

.sar-citation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sar-citation-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.sar-citation-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sar-citation-price {
    font-size: 0.85rem;
    font-weight: 700;
}

.sar-citation-id {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-left: auto;
}

.sar-citation-sep {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    margin: 6px 0;
}

/* ── Chat input form ───────────────────────────────────────────────────── */

#sar-chat-form {
    display: flex !important;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    align-items: center;
}

#sar-chat-input {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    font-family: var(--ast-body-font-family, inherit);
    font-size: 0.9rem !important;
    color: #333 !important;
    background: #fff !important;
    outline: none;
    transition: border-color 0.2s;
    display: block !important;
}

#sar-chat-input:focus {
    border-color: var(--ast-global-color-0, #0073aa) !important;
}

#sar-chat-form button[type="submit"] {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    border-radius: 8px !important;
    background: rgb(44, 47, 151) !important;
    color: #fff !important;
    border: none !important;
    font-size: 1.2rem;
    cursor: pointer;
    flex: 0 0 40px !important;
    padding: 0 !important;
    transition: opacity 0.2s;
}

#sar-chat-form button[type="submit"]:hover {
    opacity: 0.85;
}