/* AI Info App - Frontend Styles */

.ai-info-search-container {
    max-width: 980px;
    margin: 40px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Initial Search State (Hero) */
.ai-search-initial.ai-hero {
    text-align: center;
    padding: 60px 20px 24px;
    
    border-radius: 16px;
}

.ai-search-header h2 {
    font-size: 34px;
    font-weight: 600;
    margin: 0 0 24px 0;
    color: #202124;
}

.ai-search-input-wrapper {
    position: relative;
    max-width: 584px;
    margin: 0 auto;
}

/* Inline error messages */
.ai-input-error {
    color: #b91c1c;
    font-size: 13px;
}
.ai-search-initial .ai-input-error {
    max-width: 584px;
    margin: 8px auto 0;
    text-align: left;
}
.ai-modal-footer .ai-input-error {
    max-width: 980px;
    margin: 8px auto 10px;
}

.ai-search-input {
    width: 100%;
    padding: 15px 60px 15px 20px;
    font-size: 16px;
    border: 1px solid #dfe1e5;
    border-radius: 24px;
    outline: none;
    box-shadow: 0 1px 6px rgba(32,33,36,.28);
    transition: box-shadow 0.2s;
}

.ai-search-input:hover,
.ai-search-input:focus {
    box-shadow: 0 1px 6px rgba(32,33,36,.4);
}

.ai-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color, #0073aa);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-search-btn:hover {
    background: var(--primary-color-dark, #005a87);
}

.ai-search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Suggestions */
.ai-suggestions { 
    margin-top: 28px; 
}
.ai-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}
.ai-suggestion-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    cursor: pointer;
    transition: box-shadow .2s, transform .1s, border-color .2s;
}
.ai-suggestion-card:hover {
    box-shadow: 0 4px 12px rgba(32,33,36,.08);
    transform: translateY(-1px);
    border-color: #dfe1e5;
}
.ai-suggestion-card:disabled { opacity: .6; cursor: not-allowed; }
.ai-suggestion-arrow { color: var(--primary-color, #0073aa); font-weight: 600; }

/* Answer View */
.ai-answer-view {
    display: flex;
    flex-direction: column;
    border: 1px solid #dfe1e5;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(32,33,36,.1);
    background: white;
}

/* Fullscreen modal variant: ensures answers are not limited by WP containers */
body.ai-modal-open { overflow: hidden; }
.ai-answer-view.ai-modal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: var(--ai-modal-top, 0); /* keep site header visible */
    width: 100vw;
    height: calc(100vh - var(--ai-modal-top, 0));
    max-width: none;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #fff;
    z-index: 999999; /* above WP admin and theme elements */
    will-change: transform, opacity;
}

.ai-answer-body {
    /* Slightly larger padding for better breathing room around answers */
    padding: 26px 28px;
    max-height: 600px;
    overflow-y: auto;
}
.ai-answer-view.ai-modal .ai-answer-body {
    flex: 1;
    max-height: none;
    height: calc(100vh - var(--ai-modal-top, 0));
    overflow-y: auto;
    padding-bottom: 92px; /* space for bottom question bar */
}

/* Optional: center the reading column inside fullscreen modal for better readability */
.ai-answer-view.ai-modal .ai-article,
.ai-answer-view.ai-modal .ai-references {
    max-width: 980px;
    margin: 0 auto;
}

/* Open/Close animations for fullscreen modal */
.ai-answer-view.ai-modal {
    transform-origin: center center;
}
.ai-answer-view.ai-modal.ai-modal-enter {
    animation: aiModalEnter 240ms ease-out both;
}
.ai-answer-view.ai-modal.ai-modal-leave {
    animation: aiModalLeave 180ms ease-in both;
}

@keyframes aiModalEnter {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes aiModalLeave {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.98); }
}

/* Follow-up Question Bar (bottom) */
.ai-modal-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 6px rgba(32,33,36,.06);
    padding: 10px 12px;
    z-index: 1000000; /* on top of modal body */
}
.ai-answer-view.ai-modal .ai-modal-footer .ai-question-row { 
    max-width: 980px; 
    margin: 0 auto; 
    display: grid; 
    grid-template-columns: 1fr auto auto; 
    gap: 10px; 
    align-items: center; 
}
.ai-followup-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #dfe1e5;
    border-radius: 10px;
    outline: none;
    box-shadow: 0 1px 4px rgba(32,33,36,.16);
}
.ai-followup-input:focus { box-shadow: 0 1px 6px rgba(32,33,36,.24); }
.ai-followup-submit, .ai-stop-stream {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}
.ai-followup-submit {
    background: var(--primary-color, #0073aa);
    color: #fff;
}
.ai-followup-submit:hover { filter: brightness(1.05); }
.ai-followup-submit:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}
.ai-stop-stream {
    background: #f3f4f6;
    color: #374151;
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ai-stop-stream svg { width: 18px; height: 18px; }
.ai-stop-stream:hover { filter: brightness(0.98); }
.ai-stop-stream:disabled { opacity: .6; cursor: not-allowed; }
/* Top-right close button (overlay within modal, under site header) */
.ai-close-top {
    position: fixed;
    top: calc(var(--ai-modal-top, 0) + 12px);
    right: var(--ai-close-right, 16px);
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    z-index: 1000001; /* above modal content */
}
.ai-close-top:hover { filter: brightness(0.98); }

@media (max-width: 640px) {
    .ai-answer-view.ai-modal .ai-modal-footer .ai-question-row { 
        grid-template-columns: 1fr; 
    }
    .ai-followup-submit, .ai-stop-stream { width: 100%; }
}

.ai-answer-loader { display: none; text-align: center; margin: 40px 0; }
.ai-orb {
    width: 56px; height: 56px; border-radius: 50%;
    /* Layered gradients for stronger 3D look: top-left specular, bottom-right inner shade, base color gradient */
    background:
        radial-gradient(circle at 28% 22%, rgba(255,255,255,.35), rgba(255,255,255,0) 38%),
        radial-gradient(circle at 68% 78%, rgba(0,0,0,.18), rgba(0,0,0,0) 55%),
        radial-gradient(
            circle at 30% 20%,
            var(--orb-c1, #b9a6ff) 0%,
            var(--orb-c2, #6b50ff) 42%,
            var(--orb-c3, #4d34d6) 70%,
            var(--orb-c4, #2a1f83) 100%
        );
    box-shadow: 0 0 44px var(--orb-shadow, rgba(107,80,255,.45)), inset 0 -6px 12px rgba(0,0,0,.12);
    animation: pulse 2.2s infinite ease-in-out;
    margin: 0 auto 12px;
}
.ai-loader-text { color: #5f6368; font-size: 14px; }

@keyframes pulse {
    0%, 100% { transform: scale(1); filter: saturate(1); }
    50% { transform: scale(1.06); filter: saturate(1.1); }
}

.ai-article {
    line-height: 1.65;
    color: #202124;
    /* Add inner padding so text doesn’t hug the container edges */
    padding: 8px 12px;
}
.ai-article .ai-turn { margin: 18px 0 24px; }
/* Divider line between turns to visually separate Q/A blocks */
.ai-article .ai-turn + .ai-turn {
    border-top: 1px solid #e5e7eb;
    padding-top: 18px;
}
/* Question header: larger and with a subtle greyish tint */
.ai-article .ai-turn-question {
    font-size: 20px;
    line-height: 1.4;
    font-weight: 700;
    color: #111827;
    margin: 12px 0 10px;
    background: #f9fafb; /* greyish tinge to distinguish the question */
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
}
.ai-article .ai-turn-answer { color: #202124; }
.ai-article .ai-turn-answer .ai-turn-stream { min-height: 0; }
.ai-article h1, .ai-article h2, .ai-article h3 { margin: 20px 0 10px; }
.ai-article h4 { margin: 16px 0 8px; font-size: 16px; font-weight: 600; }
.ai-article ul { padding-left: 20px; margin: 10px 0 16px; }
.ai-article hr { border: none; border-top: 1px solid #e5e7eb; margin: 24px 0; }
.ai-article a { color: var(--primary-color, #0073aa); text-decoration: none; }
.ai-article a:hover { text-decoration: underline; }

/* Prominent inline links inside article content */
.ai-article a.ai-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--primary-color, #0073aa);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(32,33,36,.06);
    font-weight: 600;
    transition: transform .1s ease, box-shadow .2s ease, border-color .2s ease;
}
.ai-article a.ai-link:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(32,33,36,.10);
    border-color: var(--primary-color-dark, #005a8c);
}
.ai-article a.ai-link::after {
    content: '🔗';
    font-size: 14px;
    line-height: 1;
    color: var(--primary-color-dark, #005a8c);
}

/* Do not apply inline link chrome inside references cards or the bottom references list */
.ai-text-refs a.ai-link,
.ai-references-list a.ai-link {
    padding: 0;
    border: none;
    box-shadow: none;
}

/* Textual References (rendered inside the article at the end of the answer) */
.ai-text-refs-title { margin-top: 20px; }
.ai-text-refs {
    list-style: none;
    padding-left: 0;
    margin: 8px 0 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Cards style (default) */
.ai-text-refs.ai-text-refs--cards li {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: box-shadow .2s, transform .1s, border-color .2s;
}
.ai-text-refs.ai-text-refs--cards li:hover {
    box-shadow: 0 4px 12px rgba(32,33,36,.08);
    transform: translateY(-1px);
    border-color: #dfe1e5;
}
.ai-text-refs.ai-text-refs--cards a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--primary-color, #0073aa);
    text-decoration: none;
}
.ai-text-refs.ai-text-refs--cards a:hover { text-decoration: none; }
.ai-text-refs.ai-text-refs--cards a::after {
    content: '↗';
    font-size: 14px;
    color: var(--primary-color-dark, #005a8c);
}

/* Cards accent variant: use brand color background with white text */
.ai-text-refs.ai-text-refs--cards.ai-text-refs--accent li {
    background: var(--primary-color, #0073aa);
    border-color: var(--primary-color-dark, #005a8c);
}
.ai-text-refs.ai-text-refs--cards.ai-text-refs--accent li:hover {
    filter: brightness(1.04);
}
.ai-text-refs.ai-text-refs--cards.ai-text-refs--accent a {
    color: #fff;
}
.ai-text-refs.ai-text-refs--cards.ai-text-refs--accent a::after {
    color: rgba(255,255,255,.92);
}

/* Buttons style (alternative) */
.ai-text-refs.ai-text-refs--buttons li {
    border-radius: 12px;
    background: var(--primary-color, #0073aa);
    box-shadow: 0 6px 16px rgba(0,0,0,.10);
    transition: transform .1s ease, box-shadow .2s ease, filter .2s ease;
}
.ai-text-refs.ai-text-refs--buttons li:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}
.ai-text-refs.ai-text-refs--buttons a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
}
.ai-text-refs.ai-text-refs--buttons a::after {
    content: '↗';
    font-size: 14px;
    color: rgba(255,255,255,.9);
}

/* References */
.ai-references {
    margin-top: 24px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
}
.ai-references-header h4 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
    color: #202124;
}
.ai-references-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}
.ai-ref-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    transition: box-shadow .2s, transform .1s, border-color .2s;
}
.ai-ref-item:hover {
    box-shadow: 0 4px 12px rgba(32,33,36,.08);
    transform: translateY(-1px);
    border-color: #dfe1e5;
}
.ai-ref-favicon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #f3f4f6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 12px;
}
.ai-ref-content {
    flex: 1;
    min-width: 0;
}
.ai-ref-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-ref-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
}
.ai-ref-link {
    color: var(--primary-color, #0073aa);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ai-ref-link svg {
    width: 14px;
    height: 14px;
}

/* Legacy chat styles removed in favor of article-style UI */

/* (chat input/button styles omitted) */

/* Scrollbar Styling */
.ai-answer-body::-webkit-scrollbar {
    width: 8px;
}
.ai-answer-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.ai-answer-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}
.ai-answer-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-info-search-container {
        margin: 20px 10px;
    }
    
    .ai-search-header h2 { font-size: 28px; }
    .ai-answer-body { max-height: 520px; }
}
