/**
 * Persian Smart Search - Frontend Styles
 * استایل‌های فرانت‌اند با سازگاری کامل با موبایل و دسکتاپ
 * Combined Modern & Classic UI
 */

/* ========== Backdrop Overlay - Disabled ========== */
.pss-backdrop {
    display: none !important; /* Backdrop disabled - no blur effect */
}

/* ========== Main Container ========== */
.pss-search-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, Tahoma, Arial, sans-serif;
    direction: rtl;
    z-index: 1000; /* Higher than page content */
}

/* ========== Search Form ========== */
.pss-search-form {
    position: relative;
    z-index: 100;
}

.pss-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    padding: 0px 5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-right: 10px;
}

.pss-search-input-wrapper:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.pss-search-input-wrapper:focus-within {
    border-color: #ad0000;
    box-shadow: 0 4px 24px rgba(0, 115, 170, 0.15);
    transform: translateY(-1px);
}

.pss-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 16px;
    font-size: 16px;
    line-height: 1.5;
    background: transparent;
    color: #333;
    font-family: inherit;
    direction: rtl;
}

.pss-search-input::placeholder {
    color: #999;
    font-size: 14px;
}

input.pss-search-input {
    box-shadow: unset !important;
    border: 0px !important;
    margin-bottom: 0px !important;
}

.pss-search-buttons {
    display: flex;
    gap: 4px;
    padding: 0 4px;
}

.pss-search-btn,
.pss-visual-search-btn {
    background: #ad0000;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.pss-visual-search-btn {
    background: #7c3aed;
}

.pss-search-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
}

.pss-visual-search-btn:hover {
    background: #6d28d9;
    transform: translateY(-1px);
}

.pss-loading-indicator {
    position: absolute;
    left: 70px;
    top: 60%;
    transform: translate(-50%, -50%);
}

.pss-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,115,170,0.2);
    border-top-color: #ad0000;
    border-radius: 50%;
    animation: pss-spin 0.8s linear infinite;
}

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

/* ========== Filters ========== */
.pss-filters {
    margin-top: 12px;
}

.pss-category-filter {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pss-category-filter:focus {
    border-color: #ad0000;
    outline: none;
}

/* ========== Results Container ========== */
.pss-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    max-height: 500px;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    animation: pss-slide-down 0.3s ease;
}

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

.pss-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    background: #fafafa;
    z-index: 10;
}

.pss-results-count {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.pss-results-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pss-view-all-btn {
    font-size: 12px;
    font-weight: 600;
    color: #ad0000;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgb(170 0 0 / 8%);
    transition: all 0.2s;
}

.pss-view-all-btn:hover {
    background: rgb(170 0 0 / 10%);
    transform: translateX(-2px);
}

button.pss-close-results {
    margin: 0px;
}

.pss-close-results {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0px;
    color: #999;
    transition: all 0.2s ease;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pss-close-results:hover {
    color: #666;
    background: rgba(0, 0, 0, 0.05);
}

/* ========== Results List ========== */
.pss-results-list {
    padding: 8px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

/* Custom scrollbar */
.pss-results-list::-webkit-scrollbar {
    width: 6px;
}

.pss-results-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pss-results-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.pss-results-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.pss-result-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f5f5f5;
}

.pss-result-item:last-child {
    border-bottom: none;
}

.pss-result-item:hover {
    background: #f8f9fa;
    transform: translateX(-2px);
}

.pss-result-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.pss-result-info {
    flex: 1;
    min-width: 0;
}

.pss-result-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pss-result-title mark {
    background: #fef3c7;
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

.pss-result-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 12px;
}

.pss-result-price {
    font-size: 13px;
    font-weight: normal;
    color: #ad0000;
}

.pss-result-sku {
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    padding: 3px 8px;
    border-radius: 4px;
}

.pss-result-stock {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
}

.pss-result-stock.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.pss-result-stock.out-of-stock {
    background: #fee2e2;
    color: #991b1b;
}

/* ========== Infinite Scroll Loader ========== */
.pss-infinite-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 8px;
}

.pss-infinite-loader span {
    font-size: 12px;
    color: #666;
}

/* ========== Results Footer (Hidden for infinite scroll) ========== */
.pss-results-footer {
    display: none;
}

/* ========== No Results ========== */
.pss-no-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 40px 20px;
    text-align: center;
    color: #666;
    z-index: 9999;
    display: none;
}

.pss-no-results p {
    margin: 0;
    font-size: 14px;
}

/* ========== Skeleton Loading ========== */
.pss-skeleton {
    animation: pss-skeleton-pulse 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

@keyframes pss-skeleton-pulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.pss-skeleton-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f5f5f5;
}

.pss-skeleton-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: #f0f0f0;
}

.pss-skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pss-skeleton-title {
    height: 14px;
    width: 70%;
    border-radius: 4px;
    background: #f0f0f0;
}

.pss-skeleton-meta {
    height: 10px;
    width: 40%;
    border-radius: 4px;
    background: #f0f0f0;
}

/* ========== Search History & Suggestions ========== */
.pss-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 10px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    z-index: 9999;
    animation: pss-slide-down 0.3s ease;
}

.pss-suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.pss-clear-history {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: all 0.2s;
    opacity: 0.6;
}

.pss-clear-history:hover {
    opacity: 1;
    transform: scale(1.1);
}

.pss-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.pss-suggestion-item:last-child {
    border-bottom: none;
}

.pss-suggestion-item:hover {
    background: #f8f9fa;
}

.pss-suggestion-icon {
    color: #ccc;
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.pss-suggestion-text {
    flex: 1;
    font-size: 13px;
    color: #666;
}

.pss-suggestion-count {
    font-size: 11px;
    color: #999;
}

/* ========== Categories Section ========== */
.pss-categories-section {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
}

.pss-categories-title {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.pss-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pss-category-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #fff;
    border-radius: 12px;
    font-size: 11px;
    color: #666;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid #e0e0e0;
}

.pss-category-tag:hover {
    background: #ad0000;
    color: #fff;
    border-color: #ad0000;
}

/* ========== Did You Mean ========== */
.pss-did-you-mean {
    padding: 10px 16px;
    background: #fff9e6;
    border-bottom: 1px solid #f0e6cc;
    font-size: 12px;
}

.pss-did-you-mean-text {
    color: #666;
}

.pss-did-you-mean-suggestion {
    color: #ad0000;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.pss-did-you-mean-suggestion:hover {
    text-decoration: underline;
}

/* ========== Visual Search Modal ========== */
.pss-visual-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: pss-fade-in 0.3s ease;
}

@keyframes pss-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pss-visual-modal-content {
    background: #fff;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    animation: pss-scale-up 0.3s ease;
}

@keyframes pss-scale-up {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.pss-visual-modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    background: transparent;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.pss-visual-modal-close:hover {
    color: #333;
    transform: rotate(90deg);
}

.pss-visual-modal h3 {
    margin: 0 0 24px 0;
    text-align: center;
    color: #333;
}

.pss-visual-drop-zone {
    border: 3px dashed #ad0000;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    background: #f0f8ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pss-visual-drop-zone:hover,
.pss-visual-drop-zone.drag-over {
    background: #e6f4ff;
    border-color: #005a87;
}

.pss-visual-drop-zone svg {
    color: #ad0000;
    margin-bottom: 16px;
}

.pss-visual-drop-zone p {
    margin: 0 0 16px 0;
    color: #666;
}

.pss-visual-preview {
    text-align: center;
}

.pss-visual-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* ========== Flatsome Compatibility ========== */
.pss-flatsome.pss-search-container {
    font-family: inherit;
}

.pss-flatsome .pss-search-input-wrapper {
    border-radius: 99px;
}

.pss-flatsome .pss-search-btn,
.pss-flatsome .pss-visual-search-btn {
    border-radius: 99px;
}

/* ========== Dark Theme ========== */
.pss-theme-dark .pss-search-input-wrapper {
    background: #2d2d2d;
    border-color: #374151;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.pss-theme-dark .pss-search-input {
    color: #fff;
}

.pss-theme-dark .pss-search-input::placeholder {
    color: #9ca3af;
}

.pss-theme-dark .pss-search-results,
.pss-theme-dark .pss-suggestions {
    background: #2d2d2d;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.pss-theme-dark .pss-result-item {
    border-bottom-color: #3d3d3d;
}

.pss-theme-dark .pss-result-item:hover {
    background: #3d3d3d;
}

.pss-theme-dark .pss-result-title {
    color: #fff;
}

.pss-theme-dark .pss-results-header {
    background: #374151;
    border-bottom-color: #4b5563;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
    .pss-search-container {
        max-width: 100%;
    }
    
    .pss-search-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px 16px;
    }
    
    .pss-search-results {
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
    }
    
    .pss-result-item {
        padding: 12px;
    }
    
    .pss-result-image {
        width: 60px;
        height: 60px;
    }
    
    .pss-result-title {
        font-size: 13px;
    }
    
    .pss-result-price {
        font-size: 11px;
    }
    
    .pss-visual-modal-content {
        padding: 24px;
        max-height: 95vh;
    }
    
    .pss-visual-drop-zone {
        padding: 40px 20px;
    }
}

@media (max-width: 480px) {
    .pss-search-input {
        font-size: 16px;
        padding: 10px 12px;
    }
    
    .pss-search-btn,
    .pss-visual-search-btn {
        padding: 8px 12px;
    }
    
    .pss-search-btn svg,
    .pss-visual-search-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .pss-result-item {
        padding: 10px;
        gap: 10px;
    }
    
    .pss-result-image {
        width: 50px;
        height: 50px;
    }
}
