/* Community AI Search Styles */

.community-ai-search-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 30px;
    border-radius: 8px;
    margin-bottom: 40px;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.15);
}

.community-ai-search-section h3 {
    color:#000;
    margin-bottom: 10px;
    font-size: 24px;
    font-weight: 700;
}

.ai-search-tagline {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 25px;
    font-size: 16px;
}

#community-ai-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.ai-search-input-wrapper {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
}

#community-ai-search-input {
    flex: 1;
    padding: 14px 45px 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    transition: all 0.3s ease;
    width: 100%;
}

#community-ai-search-input:focus {
    outline: none;
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#community-ai-search-input::placeholder {
    color: #999;
}

.ai-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #999;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
}

.ai-clear-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.ai-clear-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

#community-ai-search-btn {
    padding: 14px 32px;
    background: #ffffff;
    color: #667eea;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

#community-ai-search-btn:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

#community-ai-search-btn:active {
    transform: translateY(0);
}

.ai-search-examples {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ai-search-examples strong {
    font-weight: 600;
    margin-right: 5px;
}

.ai-search-examples span {
    display: inline-block;
    margin-right: 15px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.ai-search-examples span:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Refine Toggle in AI Section */
.ai-refine-toggle-wrapper {
    margin-top: 15px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#reset-all-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

#reset-all-search:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.toggle-link-compact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.toggle-link-compact:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.toggle-link-compact .toggle-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.toggle-link-compact .toggle-icon.open {
    transform: rotate(180deg);
}

#toggle-ai-detailed-search {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

#toggle-ai-detailed-search:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.toggle-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #ffffff;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.toggle-link:hover {
    background: #667eea;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.toggle-icon {
    display: inline-block;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.toggle-icon.open {
    transform: rotate(180deg);
}

/* Browse Mode Info */
.community-filters > div:first-child {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Advanced Options Wrapper */
.community-advanced-options-wrapper {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Hide redundant results count in header */
.results-count {
    display: none !important;
}

#ai-detailed-search-section {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    margin-top: 20px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

/* AI Results Container */

#community-ai-search-results {
    margin-top: 30px;
    display: none;
}

/* AI Results Wrapper */

/* Override grid layout on container when AI results wrapper is inside */
/* The .community-grid class (from PHP-generated CSS) handles grid display by default */
/* We only need to override when .ai-results-wrapper is present inside */
#community-grid:has(.ai-results-wrapper) {
    display: block !important;
}

.ai-results-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.ai-explanation-card {
    background: #f8f9fa;
    border-left: 0px solid #667eea;
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 6px;
    width: 100%;
}

.ai-results-title {
    color: #333;
    margin-bottom: 15px;
    font-size: 22px;
    font-weight: 700;
}

.ai-explanation-text {
    color: #555;
    line-height: 1.6;
    font-size: 16px;
    margin: 0 0 25px 0;
}

.ai-more-results {
    color: #888;
    font-size: 14px;
    margin-top: 10px;
    font-style: italic;
}

.ai-no-results {
    color: #666;
    text-align: center;
    padding: 30px;
    background: #f5f5f5;
    border-radius: 6px;
    margin: 20px 0;
}

/* AI Results Grid - Generated by admin styling system */
/* Grid layout, card styling, and responsive behavior configured via admin settings */

.ai-result-image {
    width: 100%;
    height: 100%;
    min-height: 180px;
    max-height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.ai-result-card:hover .ai-result-image {
    transform: scale(1.05);
}

.ai-result-image-placeholder {
    width: 100%;
    height: 100%;
    min-height: 180px;
    max-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.ai-result-header {
    position: relative;
}

.ai-match-score {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    background: rgba(102, 126, 234, 0.95) !important;
    color: white !important;
    padding: 6px 10px !important;
    border-radius: 50% !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    z-index: 10 !important;
    backdrop-filter: blur(4px) !important;
}

.ai-result-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.ai-result-content h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.ai-result-content h4 a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.ai-result-content h4 a:hover {
    color: #667eea;
}

.ai-explanations {
    list-style: none;
    margin: 12px 0 15px 0;
    padding: 0;
    font-size: 14px;
    flex-grow: 1;
}

.ai-explanations li {
    color: #666;
    margin-bottom: 6px;
    padding-left: 20px;
    position: relative;
}

.ai-explanations li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: 700;
}

.ai-view-btn {
    display: inline-block;
    padding: 10px 16px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    align-self: flex-start;
    margin-top: auto;
}

.ai-view-btn:hover {
    background: #764ba2;
    transform: translateX(3px);
}

/* Loading State */

.ai-loading {
    text-align: center;
    padding: 50px 20px;
}

.ai-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes ai-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-loading p {
    color: #667eea;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

/* Error State */

.ai-error-message {
    background: #fee;
    border-left: 4px solid #d63638;
    padding: 20px;
    border-radius: 6px;
    color: #d63638;
    font-weight: 600;
}

.ai-more-results {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Responsive */

@media (max-width: 768px) {
    .community-ai-search-section {
        padding: 25px 20px;
    }

    .community-ai-search-section h3 {
        font-size: 20px;
    }

    #community-ai-search-form {
        flex-direction: column;
    }

    #community-ai-search-input,
    #community-ai-search-btn {
        width: 100%;
    }

    .ai-results-grid {
        grid-template-columns: 1fr;
    }

    .ai-search-examples span {
        display: block;
        margin-bottom: 8px;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .community-ai-search-section {
        padding: 20px 15px;
    }

    .community-ai-search-section h3 {
        font-size: 18px;
    }

    .ai-search-tagline {
        font-size: 14px;
    }

    #community-ai-search-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}
