/* AI Search — ChatGPT-Style UI */

.ai-search-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: inherit;
}

/* ===== Sticky Search Bar (JS-driven for Divi compatibility) ===== */
.ai-search-form.is-stuck {
    position: fixed !important;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    z-index: 999999 !important;
    background: #fff;
    padding: 15px 20px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    margin-top: 0px;
}

/* Placeholder to prevent content jump when form becomes fixed */
.ai-search-form-placeholder {
    display: none;
}

/* ===== Search Form ===== */
.ai-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.ai-search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.ai-search-icon {
    position: absolute;
    right: 14px;
    width: 20px;
    height: 20px;
    color: #999;
    pointer-events: none;
    z-index: 1;
}

.ai-search-input {
    width: 100%;
    padding: 14px 40px 14px 44px !important;
    font-size: 16px;
    border: 2px solid #e1e1e1;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #333;
}

.ai-search-input:focus {
    border-color: #7EBEC5;
    box-shadow: 0 0 0 3px rgba(126, 190, 197, 0.15);
}

.ai-search-input::placeholder {
    color: #999;
}

.ai-search-clear {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    padding: 5px 8px;
    line-height: 1;
    z-index: 1;
}

.ai-search-clear:hover {
    color: #333;
}

.ai-search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    background: #262634;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.ai-search-btn:hover {
    background: #3a3a4a;
}

.ai-search-btn:active {
    transform: scale(0.97);
}

.ai-search-btn svg {
    flex-shrink: 0;
}

/* Clear Search Button */
.ai-search-clear-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.ai-search-clear-all:hover {
    background: #e4e4e4;
    color: #333;
}

.ai-search-clear-all:active {
    transform: scale(0.97);
}

.ai-search-clear-all svg {
    flex-shrink: 0;
}

/* ===== Autocomplete Dropdown ===== */
.ai-search-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 320px;
    overflow-y: auto;
}

.ai-search-ac-item {
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f5f5f5;
}

.ai-search-ac-item:last-child {
    border-bottom: none;
}

.ai-search-ac-item:hover,
.ai-search-ac-item.active {
    background: #f0f9fa;
    color: #262634;
}

.ai-search-ac-item mark {
    background: transparent;
    color: #7EBEC5;
    font-weight: 700;
}

/* ===== Chat Area ===== */
.ai-search-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* User Message */
.ai-search-msg-user {
    display: flex;
    justify-content: flex-end;
    animation: ai-msg-in 0.3s ease-out;
}

.ai-search-user-bubble {
    background: #262634;
    color: #fff;
    padding: 12px 20px;
    border-radius: 18px 18px 4px 18px;
    font-size: 15px;
    max-width: 70%;
    word-wrap: break-word;
}

/* AI Response */
.ai-search-msg-ai {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: ai-msg-in 0.3s ease-out;
}

.ai-search-ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7EBEC5, #5fa8b0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.ai-search-ai-content {
    flex: 1;
    min-width: 0;
}

/* Typing Indicator */
.ai-search-typing {
    display: flex;
    gap: 4px;
    padding: 16px 0 8px 0;
}

.ai-search-typing span {
    width: 8px;
    height: 8px;
    background: #7EBEC5;
    border-radius: 50%;
    animation: ai-typing-bounce 1.4s infinite ease-in-out both;
}

.ai-search-typing span:nth-child(1) { animation-delay: 0s; }
.ai-search-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-search-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Did You Mean */
.ai-search-correction {
    padding: 10px 16px;
    background: #fff8e1;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    animation: ai-fade-in 0.4s ease-out;
}

.ai-search-correction a {
    color: #7EBEC5;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.ai-search-correction strong {
    color: #333;
}

/* ===== Result Sections ===== */
.ai-search-section {
    margin-bottom: 24px;
    background: #f6f6f6;
    border-radius: 12px;
    padding: 24px;
    opacity: 0;
    transform: translateY(12px);
    animation: ai-section-in 0.5s ease-out forwards;
}

.ai-search-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 3px solid #7EBEC5;
}

.ai-search-section-header h3 {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    color: #262634;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* AI Summary with typing cursor */
.ai-search-summary {
    padding: 14px 18px;
    background: #fff;
    border-left: 4px solid #7EBEC5;
    border-radius: 0 8px 8px 0;
    margin-bottom: 18px;
    font-size: 15px;
    line-height: 1.6;
    color: #444;
    min-height: 24px;
}

.ai-search-summary.typing::after {
    content: "\2588";
    color: #7EBEC5;
    animation: ai-cursor-blink 0.7s infinite;
    margin-left: 2px;
}

@keyframes ai-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== Product & Post Grid ===== */
.ai-search-items-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Card */
.ai-search-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s, transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(16px);
}

.ai-search-card.revealed {
    animation: ai-card-in 0.4s ease-out forwards;
}

.ai-search-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-3px);
    text-decoration: none;
    color: inherit;
}

.ai-search-card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #eee;
}

.ai-search-card-image-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #e1e1e1 0%, #f2f2f2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 14px;
}

.ai-search-card-body {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ai-search-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #262634;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-search-card-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-search-card-price {
    font-size: 16px;
    font-weight: 700;
    color: #32373c;
}

.ai-search-card-categories {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.ai-search-card-date {
    font-size: 12px;
    color: #888;
}

/* ===== Pages/Languages List ===== */
.ai-search-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-search-page-item {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: #fff;
    border-radius: 8px;
    text-decoration: none;
    color: #262634;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s, padding-left 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transform: translateX(-8px);
}

.ai-search-page-item.revealed {
    animation: ai-list-in 0.3s ease-out forwards;
}

.ai-search-page-item:hover {
    background: #e8f6f7;
    padding-left: 24px;
    text-decoration: none;
    color: #262634;
}

.ai-search-page-item::before {
    content: "\2192";
    margin-right: 10px;
    color: #7EBEC5;
    font-size: 18px;
    flex-shrink: 0;
}

.ai-search-page-excerpt {
    font-size: 13px;
    color: #888;
    margin-left: 8px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Query Highlighting ===== */
.ai-search-card-title mark,
.ai-search-page-item mark,
.ai-search-page-excerpt mark {
    background: rgba(126, 190, 197, 0.25);
    color: inherit;
    padding: 1px 2px;
    border-radius: 2px;
}

/* ===== No Results ===== */
.ai-search-no-results {
    text-align: center;
    padding: 30px 20px;
    color: #666;
    font-size: 15px;
}

.ai-search-no-results p {
    margin-bottom: 16px;
}

.ai-search-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.ai-search-suggestion-chip {
    display: inline-block;
    padding: 8px 16px;
    background: #f0f9fa;
    border: 1px solid #d4eaed;
    border-radius: 20px;
    color: #5fa8b0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
}

.ai-search-suggestion-chip:hover {
    background: #d4eaed;
    transform: scale(1.03);
    text-decoration: none;
    color: #3a8a93;
}

/* ===== Error ===== */
.ai-search-error {
    padding: 15px 20px;
    background: #fff3f3;
    border: 1px solid #e8c4c4;
    border-radius: 10px;
    color: #c44;
    margin-bottom: 20px;
}

/* ===== Animations ===== */
@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-section-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-card-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-list-in {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes ai-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .ai-search-items-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .ai-search-form {
        flex-direction: column;
    }

    .ai-search-btn,
    .ai-search-clear-all {
        width: 100%;
        justify-content: center;
    }

    .ai-search-items-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ai-search-section {
        padding: 16px;
    }

    .ai-search-user-bubble {
        max-width: 85%;
    }

    .ai-search-page-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .ai-search-page-excerpt {
        margin-left: 0;
        margin-top: 4px;
        white-space: normal;
    }
}

@media (max-width: 480px) {
    .ai-search-items-grid {
        grid-template-columns: 1fr;
    }

    .ai-search-wrapper {
        padding: 10px;
    }

    .ai-search-ai-avatar {
        display: none;
    }
}
