/**
 * SiteAI Search Widget — Frontend Styles
 * Clean, modern design that integrates well with most WordPress themes.
 */

/* Container */
.sitai-search-container {
    max-width: 720px;
    margin: 2rem auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Search Box */
.sitai-search-box {
    position: relative;
}

.sitai-search-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sitai-search-input-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.sitai-search-icon {
    color: #9ca3af;
    flex-shrink: 0;
    margin-right: 12px;
    transition: color 0.2s ease;
}

.sitai-search-input-wrapper:focus-within .sitai-search-icon {
    color: #3b82f6;
}

.sitai-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    color: #1f2937;
    background: transparent;
    padding: 10px 0;
    line-height: 1.5;
}

.sitai-search-input::placeholder {
    color: #9ca3af;
}

.sitai-search-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.sitai-search-submit:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.sitai-search-submit:active {
    transform: scale(0.95);
}

.sitai-search-submit:disabled {
    background: #93c5fd;
    cursor: not-allowed;
    transform: none;
}

/* Answer Area */
.sitai-answer-area {
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    animation: sitai-fadeIn 0.3s ease;
}

.sitai-answer-content {
    font-size: 14px;
    line-height: 1.75;
    color: #374151;
    word-wrap: break-word;
}

.sitai-answer-content strong {
    color: #111827;
    font-weight: 600;
}

.sitai-answer-content code {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

/* Sources */
.sitai-sources {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.sitai-sources-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.sitai-source-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #3b82f6;
    text-decoration: none;
    padding: 4px 10px;
    background: #eff6ff;
    border-radius: 8px;
    margin-right: 6px;
    margin-bottom: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sitai-source-link:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Loading */
.sitai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
}

.sitai-loading p {
    font-size: 13px;
    color: #6b7280;
    margin: 8px 0 0 0;
}

.sitai-loading-dots {
    display: flex;
    gap: 6px;
}

.sitai-loading-dots span {
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    animation: sitai-bounce 1.4s ease-in-out infinite both;
}

.sitai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.sitai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.sitai-loading-dots span:nth-child(3) { animation-delay: 0s; }

/* Error */
.sitai-error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
}

/* Animations */
@keyframes sitai-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes sitai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .sitai-search-input-wrapper {
        background: #1f2937;
        border-color: #374151;
    }

    .sitai-search-input {
        color: #f3f4f6;
    }

    .sitai-search-input::placeholder {
        color: #6b7280;
    }

    .sitai-answer-area {
        background: #1f2937;
        border-color: #374151;
    }

    .sitai-answer-content {
        color: #d1d5db;
    }

    .sitai-answer-content strong {
        color: #f9fafb;
    }

    .sitai-answer-content code {
        background: #374151;
    }

    .sitai-sources {
        border-top-color: #374151;
    }

    .sitai-source-link {
        background: #1e3a5f;
        color: #93c5fd;
    }

    .sitai-source-link:hover {
        background: #1e3a8f;
        color: #bfdbfe;
    }

    .sitai-loading {
        background: #1f2937;
        border-color: #374151;
    }

    .sitai-error {
        background: #450a0a;
        border-color: #991b1b;
        color: #fca5a5;
    }
}
