/* ==========================================================================
   ai.css — Ask AI page
   Page-specific styles only. Header/footer/nav are styled by your real
   style.css (linked before this file) — this file no longer duplicates
   them. Everything below reads variables straight from style.css's :root /
   .dark-mode blocks (--bg-main, --bg-card, --text-main, --color-green,
   --color-blue, --border-color, --card-shadow, --bg-secondary,
   --text-muted) so it follows your real light/dark mode automatically.
   ========================================================================== */

/* style.css does not define a .hidden utility class — this page's JS
   depends on one to toggle the loading spinner / error banner / results
   section, so it has to live here. Without this rule every state renders
   at once, which is exactly what broke last time. */
.hidden { display: none !important; }

.ai-page {
    min-height: calc(100vh - 200px);
    background-color: var(--bg-main);
    display: flex;
    justify-content: center;
    padding: 3rem 1.25rem 4rem;
}
.ai-container {
    width: 100%;
    max-width: 720px;
}

.ai-state h1 {
    text-align: center;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-blue);
    margin-bottom: 0.6rem;
    letter-spacing: -0.02em;
}
.ai-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Search / chat input — grows downward as the user types instead of
   overflowing; the Ask button stays pinned to the bottom of the box via
   align-items: flex-end, so long input visually pushes the button down
   rather than squeezing it. */
.ai-search-form { margin-bottom: 1.5rem; }
.ai-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.5rem 0.6rem 0.5rem 1.25rem;
    box-shadow: var(--card-shadow);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-input-wrap:focus-within {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
#ai-query {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.98rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.6rem 0;
}
#ai-query::placeholder { color: var(--text-muted); }

/* .btn-ai is already defined in style.css (green pill button used in the
   hero search) — reused as-is here. Only the loading-spinner bits are new. */
.btn-ai:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: ai-spin 0.7s linear infinite;
}

/* Example query links */
.ai-example-queries {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}
.ai-example-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}
.example-query-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.55rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    max-width: 100%;
    width: fit-content;
    text-align: center;
    line-height: 1.4;
    transition: border-color 0.2s, color 0.2s;
}
.example-query-btn:hover {
    border-color: var(--color-green);
    color: var(--color-green);
}

/* Loading state */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-green);
    animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* Error / quota banner */
.ai-error-banner {
    background-color: rgba(225, 29, 72, 0.08);
    color: #be123c;
    border: 1px solid rgba(225, 29, 72, 0.25);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.dark-mode .ai-error-banner {
    background-color: rgba(225, 29, 72, 0.15);
    color: #fda4af;
    border-color: rgba(225, 29, 72, 0.3);
}
.ai-error-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.9rem;
    flex-wrap: wrap;
}
.ai-error-actions .btn-primary { padding: 0.55rem 1.4rem; }
.ai-error-actions .btn-text-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0;
}

/* Results state */
.btn-text-link {
    background: none;
    border: none;
    color: var(--color-blue);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.ai-answer-block {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.75rem;
    line-height: 1.7;
    font-size: 0.98rem;
    box-shadow: var(--card-shadow);
    color: var(--text-main);
}
.ai-answer-block p { margin-bottom: 0.85rem; }
.ai-answer-block p:last-child { margin-bottom: 0; }
.ai-answer-block ul { margin: 0.5rem 0 0.85rem 1.25rem; }
.ai-answer-block li { margin-bottom: 0.35rem; }
.ai-answer-block strong { color: var(--color-blue); }

.ai-products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
/* Deliberately named .ai-product-card, NOT .product-card — style.css
   already defines .product-card as a horizontal flex row (logo + name +
   description) for the homepage's product list. Reusing that class here
   would force this vertical card (title/button/details) into a squashed
   horizontal row. This card is visually distinct on purpose. */
.ai-product-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
}
.product-card-link h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-blue);
    margin-bottom: 0.9rem;
}
.product-card-link:hover h3 { text-decoration: underline; }

.btn-more-info {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-more-info:hover { background-color: var(--hover-bg); }
.btn-more-info:disabled { opacity: 0.6; cursor: not-allowed; }

.product-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-main);
}
.product-details p { margin-bottom: 0.6rem; }
.product-details p:last-child { margin-bottom: 0; }

.similar-products {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.similar-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 0.2rem;
}
.similar-chip {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-blue);
}
.similar-chip:hover { text-decoration: underline; }

.ai-inline-error { color: #be123c; font-size: 0.85rem; }
.dark-mode .ai-inline-error { color: #fda4af; }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .ai-page { padding: 2.5rem 1rem 3rem; }
}

@media (max-width: 640px) {
    .ai-products-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .ai-page { padding: 1.75rem 0.9rem 2.5rem; }
    .ai-state h1 { font-size: 1.5rem; }
    .ai-subtitle { font-size: 0.9rem; margin-bottom: 1.5rem; }

    /* Stack the Ask button below the input entirely on small phones so
       long typed text never competes for width with the button. */
    .ai-input-wrap {
        flex-direction: column;
        align-items: stretch;
        border-radius: 16px;
        padding: 0.75rem;
    }
    .btn-ai {
        justify-content: center;
        width: 100%;
    }

    .ai-answer-block { padding: 1.1rem 1.2rem; }
    .ai-product-card { padding: 1rem; }
}

@media (max-width: 360px) {
    .example-query-btn { padding: 0.5rem 0.9rem; font-size: 0.76rem; white-space: normal; }
}