/**
 * AI Search Engine - Frontend Styles
 */

/* Loading */
.ai-search-loading {
    text-align: center;
    padding: 80px 20px;
}

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

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

.ai-search-loading p {
    color: #666;
    font-size: 16px;
}

/* Search Results Container */
.ai-search-results {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Search Header */
.ai-search-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.ai-search-header h2 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #333;
}

.ai-search-info {
    margin: 0;
    font-size: 14px;
    color: #666;
}

/* Note: Product grid and card styles are provided by KKTC Smart Recommendations plugin */
/* AI Score Badge (added to KKTC cards) */
.ai-score-badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Zero Results */
.ai-search-no-results {
    text-align: center;
    padding: 80px 20px;
}

.ai-search-no-results h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 15px;
}

.ai-search-no-results p {
    font-size: 16px;
    color: #666;
}

/* Spell Correction "Did You Mean?" */
.ai-search-correction {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    border-left: 5px solid #ff9800;
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
}

.ai-search-correction .correction-main {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #856404;
}

.ai-search-correction .correction-icon {
    font-size: 18px;
    margin-right: 5px;
}

.ai-search-correction strong {
    color: #ff6b6b;
    font-weight: 700;
    font-size: 17px;
}

.ai-search-correction .correction-original {
    margin: 0;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.ai-search-correction .correction-original em {
    color: #999;
    text-decoration: line-through;
}

/* Search Box Widget (Shortcode) - Minimalist Style */
.ai-search-box-widget {
    margin: 30px auto;
    padding: 0;
    background: transparent;
    max-width: 1400px;
}

.ai-search-box-widget .search-form {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.ai-search-box-widget input[type="search"] {
    min-width: 290px;
    width: 100%;
    height: 48px;
    padding: 0 15px;
    padding-inline-end: calc(44px + 15px); /* Button width + spacing */
    border: 1px solid rgba(129, 129, 129, 0.2);
    border-radius: 10px;
    background-color: #fff;
    box-shadow: none;
    color: #333;
    vertical-align: middle;
    font-size: 14px;
    font-weight: 400;
    transition: border-color .5s ease;
}

.ai-search-box-widget input[type="search"]::placeholder {
    color: #999;
    font-weight: 300;
}

.ai-search-box-widget input[type="search"]:focus {
    outline: none;
    border-color: rgba(129, 129, 129, 0.4);
}

.ai-search-box-widget button[type="submit"] {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-search-box-widget button[type="submit"]:hover {
    background: #f5f5f5;
}

.ai-search-box-widget button[type="submit"]::before {
    transition: opacity .2s ease;
    content: "\f130";
    font-family: "woodmart-font";
    font-size: 20px;
    color: #666;
}

/* Powered by AI Badge */
.ai-powered-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 12px;
    border-radius: 12px;
    font-weight: bold;
}

/* Error Message */
.ai-search-error {
    background: #ffe6e6;
    border-left: 4px solid #e74c3c;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.ai-search-error p {
    margin: 0;
    color: #c0392b;
}

/* Success Message */
.ai-search-success {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.ai-search-success p {
    margin: 0;
    color: #2e7d32;
}

/* Pagination Controls */
.ai-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 40px 0 20px 0;
    padding: 20px 0;
}

.ai-pagination-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-pagination-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-pagination-btn:hover:not(.active):not(:disabled) {
    background: #f5f5f5;
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-pagination-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

.ai-pagination-btn:disabled,
.ai-pagination-btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
}

.ai-pagination-btn-nav {
    min-width: 100px;
    height: 40px;
    padding: 0 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-pagination-btn-nav:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-pagination-ellipsis {
    color: #999;
    font-weight: bold;
    padding: 0 4px;
    user-select: none;
}

/* Responsive Pagination */
@media (max-width: 768px) {
    .ai-pagination {
        gap: 4px;
        padding: 15px 0;
    }

    .ai-pagination-numbers {
        gap: 4px;
    }

    .ai-pagination-btn {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 13px;
    }

    .ai-pagination-btn-nav {
        min-width: 80px;
        height: 36px;
        padding: 0 12px;
        font-size: 13px;
    }

    /* Hide some page numbers on mobile */
    .ai-pagination-btn:not(.active):nth-child(n+6):nth-last-child(n+3) {
        display: none;
    }
}

/* Autocomplete Dropdown */
.ai-autocomplete-dropdown {
    position: absolute;
    z-index: 9999;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 600px;
    overflow-y: auto;
    margin-top: 5px;
}

.ai-autocomplete-section {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.ai-autocomplete-section:last-child {
    border-bottom: none;
}

/* Section Title */
.ai-autocomplete-section-title {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.ai-autocomplete-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-autocomplete-item:hover,
.ai-autocomplete-item.selected {
    background: #f5f7fa;
}

.ai-autocomplete-icon {
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ai-autocomplete-count {
    margin-left: auto;
    font-size: 12px;
    color: #999;
    padding-left: 8px;
}

/* Product items */
.ai-autocomplete-product {
    padding: 12px 16px;
}

.ai-autocomplete-product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ai-autocomplete-product-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-autocomplete-product-meta {
    font-size: 12px;
    color: #999;
}

.ai-autocomplete-score {
    font-size: 11px;
    font-weight: 600;
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 12px;
    flex-shrink: 0;
}

/* Brand/Category items */
.ai-autocomplete-brand,
.ai-autocomplete-category {
    font-weight: 500;
}

/* Footer */
.ai-autocomplete-footer {
    padding: 12px;
    background: #f9fafb;
    border-top: 1px solid #e0e0e0;
}

.ai-autocomplete-view-all {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-autocomplete-view-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Loading state */
.ai-autocomplete-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* No results / Empty state */
.ai-autocomplete-no-results,
.ai-autocomplete-empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* History Items (minimal design with X button) */
.ai-autocomplete-history-item-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
    position: relative;
}

.ai-autocomplete-history-item-wrapper:last-child {
    border-bottom: none;
}

.ai-autocomplete-history-item-wrapper:hover {
    background: #f9f9f9;
}

.ai-autocomplete-history-item {
    flex: 1;
    padding: 12px 16px !important;
    display: flex;
    align-items: center;
}

/* Remove item X button */
.ai-autocomplete-remove-item {
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 8px 12px;
    margin-right: 4px;
    transition: color 0.2s ease;
    opacity: 0;
}

.ai-autocomplete-history-item-wrapper:hover .ai-autocomplete-remove-item {
    opacity: 1;
}

.ai-autocomplete-remove-item:hover {
    color: #e74c3c;
}

/* Popular Search Chips */
.ai-autocomplete-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px 12px 16px;
}

.ai-autocomplete-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-autocomplete-chip:hover {
    background: #f5f7fa;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Trending chips (first 3 with fire icon) */
.ai-autocomplete-chip.trending {
    background: linear-gradient(135deg, #fff5f0 0%, #ffe8e0 100%);
    border-color: #ffb8a0;
}

.ai-autocomplete-chip.trending:hover {
    background: linear-gradient(135deg, #ffede5 0%, #ffd5c8 100%);
    border-color: #ff9980;
}

.ai-autocomplete-chip .fire-icon {
    font-size: 14px;
    margin-right: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    /* Note: Product grid responsive styles are in KKTC plugin */

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

    .ai-search-box-widget {
        margin: 20px 15px;
    }

    .ai-search-box-widget input[type="search"] {
        min-width: 100%;
        height: 44px;
        padding: 0 12px;
        padding-inline-end: calc(40px + 12px);
        font-size: 14px;
    }

    .ai-search-box-widget button[type="submit"] {
        width: 40px;
        height: 40px;
    }

    .ai-search-box-widget button[type="submit"]::before {
        font-size: 18px;
    }

    .ai-autocomplete-dropdown {
        max-height: 400px;
        border-radius: 8px;
    }

    .ai-autocomplete-product-name {
        font-size: 13px;
    }
}
