/**
 * Article AI - Styles
 * The info-center search ([article_ai_chat]): a search card with a title,
 * the button inside the field, example questions, a loading state and the
 * results. Interactive parts are prefixed with .article-ai-container so the
 * theme's input/button styles don't win over them.
 */

.article-ai-container {
    --article-ai-purple: var(--e-global-color-primary, #6F4165);
    --article-ai-orange: #ce7929;
    --article-ai-orange-dark: #b56820;
    --article-ai-tint: #f6f1f5;
    --article-ai-line: #e6e0e8;
    --article-ai-text: #2b2433;
    --article-ai-muted: #6b6474;
    --article-ai-skeleton: #ece8ef;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 0 20px;
    direction: rtl;
    text-align: right;
}

.article-ai-container * {
    box-sizing: border-box;
}

.article-ai-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Search card */
.article-ai-search-card {
    background: var(--article-ai-tint);
    border-radius: 18px;
    padding: 24px 24px 20px;
    display: grid;
    gap: 12px;
}

.article-ai-container .article-ai-title {
    margin: 0;
    font-family: 'Heebo', inherit;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--article-ai-purple);
    text-align: center;
}

.article-ai-container .article-ai-subtitle {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--article-ai-muted);
    text-align: center;
}

.article-ai-form {
    margin: 4px 0 0;
}

/* The field, with the button inside it */
.article-ai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 2px solid #d9d2dd;
    border-radius: 14px;
    padding: 5px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.article-ai-input-wrapper:focus-within {
    border-color: var(--article-ai-orange);
    box-shadow: 0 0 0 4px rgba(206, 121, 41, 0.15);
}

.article-ai-input-icon {
    display: flex;
    flex: none;
    color: var(--article-ai-purple);
    margin-inline-start: 8px;
}

.article-ai-container .article-ai-input {
    flex: 1;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 10px 4px;
    border: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    background: transparent;
    font-size: 16px; /* 16px keeps iOS from zooming in */
    font-family: inherit;
    color: var(--article-ai-text);
    direction: rtl;
}

.article-ai-container .article-ai-input::placeholder {
    color: #8c8594;
    opacity: 1;
}

.article-ai-container .article-ai-button {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 11px 22px;
    background: var(--article-ai-orange);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease;
}

.article-ai-container .article-ai-button:hover,
.article-ai-container .article-ai-button:focus {
    background: var(--article-ai-orange-dark);
    color: #ffffff;
}

.article-ai-container .article-ai-button:focus-visible {
    outline: 3px solid rgba(206, 121, 41, 0.45);
    outline-offset: 2px;
}

.article-ai-container .article-ai-button:disabled {
    opacity: 0.7;
    cursor: default;
}

.article-ai-button-icon {
    display: none;
}

/* Example questions */
.article-ai-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.article-ai-examples-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--article-ai-muted);
}

.article-ai-container .article-ai-example {
    margin: 0;
    padding: 5px 12px;
    background: #ffffff;
    border: 1px solid var(--article-ai-line);
    border-radius: 999px;
    color: var(--article-ai-text);
    font-size: 13.5px;
    font-weight: 400;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.article-ai-container .article-ai-example:hover,
.article-ai-container .article-ai-example:focus {
    background: #ffffff;
    border-color: var(--article-ai-orange);
    color: var(--article-ai-orange-dark);
}

.article-ai-container .article-ai-example:focus-visible {
    outline: 2px solid var(--article-ai-orange);
    outline-offset: 1px;
}

.article-ai-container .article-ai-example:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Error */
.article-ai-error {
    margin-top: 10px;
    padding: 10px 16px;
    background: #fff0f0;
    border: 1px solid #ffcccc;
    border-radius: 8px;
    color: #c62828;
    font-size: 14px;
}

/* Loading: the question stays in the field, cards blink where results will be */
.article-ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--article-ai-muted);
    font-size: 14px;
}

.article-ai-spinner {
    width: 18px;
    height: 18px;
    flex: none;
    border: 3px solid rgba(206, 121, 41, 0.2);
    border-top-color: var(--article-ai-orange);
    border-radius: 50%;
    animation: articleAiSpin 0.8s linear infinite;
}

@keyframes articleAiSpin {
    to { transform: rotate(360deg); }
}

.article-ai-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.article-ai-skeleton-card {
    display: grid;
    gap: 10px;
    padding-bottom: 16px;
    background: #ffffff;
    border: 1px solid var(--article-ai-line);
    border-radius: 12px;
    overflow: hidden;
}

.article-ai-skeleton-image {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--article-ai-skeleton);
}

.article-ai-skeleton-line {
    display: block;
    height: 11px;
    margin: 0 16px;
    border-radius: 6px;
    background: var(--article-ai-skeleton);
}

.article-ai-skeleton-short {
    width: 55%;
}

@media (prefers-reduced-motion: no-preference) {
    .article-ai-skeleton-image,
    .article-ai-skeleton-line {
        animation: articleAiPulse 1.4s ease-in-out infinite;
    }
}

@keyframes articleAiPulse {
    50% { opacity: 0.5; }
}

/* Results */
.article-ai-results {
    margin-top: 24px;
}

.article-ai-results-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 14px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--article-ai-line);
}

.article-ai-container .article-ai-results-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--article-ai-text);
}

.article-ai-results-title q {
    color: var(--article-ai-purple);
}

.article-ai-container .article-ai-new-search {
    margin: 0;
    padding: 2px 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--article-ai-orange-dark);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.article-ai-container .article-ai-new-search:hover,
.article-ai-container .article-ai-new-search:focus {
    background: none;
    color: var(--article-ai-orange-dark);
    text-decoration: underline;
}

.article-ai-container .article-ai-group-title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
    color: var(--article-ai-text);
}

/* AI Answer */
.article-ai-answer {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f4ff 0%, #f0f7ff 100%);
    border: 1px solid #e0d8f0;
    border-radius: 12px;
    margin-bottom: 16px;
}

.article-ai-answer-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
}

/* Article cards */
.article-ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.article-ai-container .article-ai-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--article-ai-line);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.article-ai-container .article-ai-card:hover,
.article-ai-container .article-ai-card:focus {
    border-color: var(--article-ai-orange);
    box-shadow: 0 4px 16px rgba(206, 121, 41, 0.15);
    transform: translateY(-2px);
}

.article-ai-card-image {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--article-ai-tint);
    overflow: hidden;
}

.article-ai-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-ai-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    padding: 14px 16px 16px;
}

.article-ai-card-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--article-ai-text);
}

.article-ai-card-excerpt {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--article-ai-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-ai-card-link {
    margin-top: auto;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--article-ai-orange-dark);
}

/* Professionals' content (external-content-results.js), under the articles */
.article-ai-container .nvm-ec-results {
    margin-top: 28px;
}

.article-ai-container .nvm-ec-results-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--article-ai-text);
}

/* No results */
.article-ai-no-results {
    display: grid;
    gap: 8px;
    justify-items: start;
    padding: 18px 20px;
    background: #ffffff;
    border: 1px solid var(--article-ai-line);
    border-radius: 12px;
}

.article-ai-container .article-ai-no-results p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--article-ai-muted);
}

.article-ai-container .article-ai-no-results .article-ai-no-results-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--article-ai-text);
}

.article-ai-container .article-ai-no-results-link {
    font-weight: 700;
    color: var(--article-ai-orange-dark);
    text-decoration: none;
}

/* ===================== */
/* Smart Search Integration - Article Section */
/* These styles are used when articles appear inside the smart search results */
/* ===================== */

.smart-search-article-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.smart-search-article-section.priority-first {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.smart-search-article-header {
    font-size: 15px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

.smart-search-article-answer {
    padding: 14px 18px;
    background: linear-gradient(135deg, #f8f4ff 0%, #f0f7ff 100%);
    border: 1px solid #e0d8f0;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.7;
    color: #333;
}

.smart-search-article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.smart-search-article-card {
    display: flex;
    flex-direction: column;
    padding: 14px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.smart-search-article-card:hover {
    border-color: #ce7929;
    background: #fff;
    box-shadow: 0 2px 10px rgba(206, 121, 41, 0.12);
}

.smart-search-article-card-title {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.smart-search-article-card-excerpt {
    margin: 0;
    font-size: 12px;
    color: #777;
    line-height: 1.5;
}

.smart-search-article-card-link {
    font-size: 12px;
    font-weight: 600;
    color: #ce7929;
    margin-top: 8px;
}

/* Mobile: the button stays in the field (an icon), the examples scroll
   sideways, and results are a list with a small picture on the side. */
@media (max-width: 768px) {
    .article-ai-container {
        padding: 4px 0 16px;
    }

    .article-ai-search-card {
        padding: 18px 14px 14px;
        border-radius: 14px;
        gap: 10px;
    }

    .article-ai-container .article-ai-title {
        font-size: 20px;
    }

    .article-ai-container .article-ai-subtitle {
        font-size: 14px;
    }

    .article-ai-examples {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        margin-inline: -14px;
        padding-inline: 14px;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .article-ai-examples::-webkit-scrollbar {
        display: none;
    }

    .article-ai-examples-label {
        flex: none;
    }

    .article-ai-grid,
    .article-ai-skeleton,
    .smart-search-article-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .article-ai-container .article-ai-card.article-ai-card-has-image {
        flex-direction: row;
        align-items: flex-start;
    }

    .article-ai-card-has-image .article-ai-card-image {
        flex: none;
        width: 96px;
        aspect-ratio: 4 / 3;
        margin: 8px;
        border-radius: 8px;
    }

    .article-ai-card-has-image .article-ai-card-body {
        padding: 10px 4px 10px 12px;
    }

    .article-ai-card-title {
        font-size: 15px;
    }

    .article-ai-card-excerpt {
        -webkit-line-clamp: 2;
    }

    .article-ai-skeleton-card {
        grid-template-columns: 96px 1fr;
        grid-template-rows: auto auto;
        align-items: start;
        gap: 8px 10px;
        padding: 8px;
    }

    .article-ai-skeleton-image {
        grid-row: span 2;
        aspect-ratio: 4 / 3;
        border-radius: 8px;
    }

    .article-ai-skeleton-line {
        margin: 6px 0 0;
    }
}

@media (max-width: 600px) {
    .article-ai-container .article-ai-button {
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .article-ai-button-text {
        display: none;
    }

    .article-ai-button-icon {
        display: flex;
    }
}

/* Wide screens: the results (articles + professionals' content) spread to
   1000px while the search box keeps its 500px. Negative side margins on
   both sides center it in either direction (RTL/LTR). */
@media (min-width: 1024px) {
    .article-ai-container .article-ai-results {
        --article-ai-results-width: min(1000px, calc(100vw - 48px));
        width: var(--article-ai-results-width);
        max-width: none;
        margin-left: calc((100% - var(--article-ai-results-width)) / 2);
        margin-right: calc((100% - var(--article-ai-results-width)) / 2);
    }
}
