/**
 * AI Search Modal Styles
 * Pre-login AI-powered search experience
 */

/* Modal Container */
.ai-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;
}

.ai-search-modal.active {
    display: flex;
}

.ai-search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.ai-search-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-search-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    line-height: 32px;
    text-align: center;
    color: #666;
    transition: background 0.2s;
}

.ai-search-close:hover {
    background: #e5e7eb;
}

/* Header */
.ai-search-header {
    padding: 24px 24px 16px;
    text-align: center;
}

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

.ai-search-header p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

/* Search Input */
.ai-search-input-wrapper {
    display: flex;
    padding: 0 24px 16px;
    gap: 8px;
}

#ai-search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
}

#ai-search-input:focus {
    border-color: #3b82f6;
}

#ai-search-btn {
    padding: 14px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

#ai-search-btn:hover {
    background: #2563eb;
}

#ai-search-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Typo Notice */
.typo-notice {
    padding: 8px 24px;
    background: #fef3c7;
    color: #92400e;
    font-size: 14px;
    display: none;
}

.typo-notice.show {
    display: block;
}

/* Results */
.ai-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
}

.results-section {
    margin-bottom: 32px;
}

.results-section h3 {
    font-size: 18px;
    margin: 0 0 4px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-subhead {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 16px;
    font-style: italic;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

/* Book Card */
.book-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    color: inherit;
}

.book-card-cover {
    position: relative;
    aspect-ratio: 2/3;
    background: #f3f4f6;
    overflow: hidden;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-free {
    background: #10b981;
    color: white;
}

.badge-amazon {
    background: #f59e0b;
    color: white;
}

.book-card-info {
    padding: 12px;
}

.book-card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #111827;
}

.book-card-author {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

.book-card-reason {
    font-size: 11px;
    color: #9ca3af;
    margin: 8px 0 0;
    font-style: italic;
}

/* Suggestions */
.search-suggestions {
    text-align: center;
    padding: 40px 0;
}

.search-suggestions p {
    color: #6b7280;
    margin-bottom: 16px;
}

.suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.suggestion-tags span {
    padding: 8px 16px;
    background: #f3f4f6;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.suggestion-tags span:hover {
    background: #e5e7eb;
}

/* Results Summary */
.results-summary {
    padding: 12px 0 16px;
    color: #6b7280;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.results-summary strong {
    color: #111827;
}

.summary-free {
    color: #10b981;
    font-weight: 500;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 0;
    color: #6b7280;
}

.no-results p {
    margin: 8px 0;
}

/* Signup Prompt Modal */
.signup-prompt-modal {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(255,255,255,1) 80%, rgba(255,255,255,0));
    padding: 40px 24px 24px;
    display: none;
}

.signup-prompt-modal.show {
    display: block;
}

.signup-prompt-content {
    background: #3b82f6;
    color: white;
    padding: 24px;
    border-radius: 16px;
    text-align: center;
}

.signup-prompt-content h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: white;
}

.signup-prompt-content > p {
    margin: 0 0 20px;
    opacity: 0.9;
}

.signup-prompt-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.signup-prompt-buttons .btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    display: block;
}

.signup-prompt-buttons .btn-primary {
    background: white;
    color: #3b82f6;
}

.signup-prompt-buttons .btn-primary:hover {
    background: #f3f4f6;
}

.signup-prompt-buttons .btn-secondary {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.signup-prompt-buttons .btn-secondary:hover {
    background: rgba(255,255,255,0.1);
}

.signup-prompt-dismiss {
    margin-top: 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 14px;
}

.signup-prompt-dismiss:hover {
    color: white;
}

/* Loading state */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* AI Search Trigger Button (for homepage) */
.ai-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-search-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.ai-search-trigger .icon {
    font-size: 18px;
}

/* Mobile */
@media (max-width: 640px) {
    .ai-search-modal {
        padding-top: 0;
    }

    .ai-search-container {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

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

    .ai-search-header h2 {
        font-size: 20px;
    }

    #ai-search-input {
        font-size: 14px;
    }
}
