/**
 * MS Smart Search - Frontend Styles
 * 
 * @package MS_Smart_Search
 */

/* Variables */
:root {
    --msss-primary-color: #2271b1;
    --msss-primary-hover: #135e96;
    --msss-border-color: #dcdcde;
    --msss-border-radius: 8px;
    --msss-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --msss-background: #fff;
    --msss-text-color: #1d2327;
    --msss-text-secondary: #646970;
    --msss-success-color: #00a32a;
    --msss-error-color: #d63638;
    --msss-font-size: 14px;
}

/* Search Wrapper */
.msss-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.msss-search-wrapper * {
    box-sizing: border-box;
}

/* Search Form */
.msss-search-form {
    position: relative;
    width: 100%;
}

/* Input Wrapper */
.msss-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--msss-background);
    border: 2px solid var(--msss-border-color);
    border-radius: var(--msss-border-radius);
    transition: all 0.2s ease;
    overflow: hidden;
}

.msss-search-input-wrapper:focus-within {
    border-color: var(--msss-primary-color);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

/* Search Icon */
.msss-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--msss-text-secondary);
    pointer-events: none;
}

/* Search Input */
.msss-search-input {
    flex: 1;
    padding: 12px 0;
    border: none !important;
    background: transparent !important;
    font-size: var(--msss-font-size);
    color: var(--msss-text-color);
    outline: none !important;
    box-shadow: none !important;
    min-width: 0;
}

.msss-search-input::placeholder {
    color: var(--msss-text-secondary);
}

/* Loader */
.msss-search-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    color: var(--msss-primary-color);
}

.msss-spin {
    animation: msss-spin 1s linear infinite;
}

@keyframes msss-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Submit Button */
.msss-search-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--msss-primary-color);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.msss-search-submit:hover {
    background: var(--msss-primary-hover);
}

/* Dropdown */
.msss-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: var(--msss-background);
    border: 1px solid var(--msss-border-color);
    border-radius: var(--msss-border-radius);
    box-shadow: var(--msss-shadow);
    max-height: 500px;
    overflow-y: auto;
    z-index: 99999;
}

/* Results */
.msss-results {
    padding: 10px 0;
}

/* Section Header */
.msss-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    border-bottom: 1px solid var(--msss-border-color);
    margin-bottom: 5px;
}

.msss-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--msss-text-secondary);
    letter-spacing: 0.5px;
}

/* Clear History Button */
.msss-clear-history {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: var(--msss-error-color);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.msss-clear-history:hover {
    opacity: 0.7;
}

/* History Section */
.msss-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msss-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.msss-history-item:hover {
    background: #f6f7f7;
}

.msss-history-item svg {
    color: var(--msss-text-secondary);
    flex-shrink: 0;
}

.msss-history-item span {
    font-size: var(--msss-font-size);
    color: var(--msss-text-color);
}

/* Categories Section */
.msss-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msss-category-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.msss-category-item a:hover {
    background: #f6f7f7;
}

.msss-category-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.msss-category-name {
    flex: 1;
    font-size: var(--msss-font-size);
    font-weight: 500;
    color: var(--msss-text-color);
}

.msss-category-count {
    font-size: 12px;
    color: var(--msss-text-secondary);
}

/* Products Section */
.msss-products-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msss-product-item {
    border-bottom: 1px solid #f0f0f1;
}

.msss-product-item:last-child {
    border-bottom: none;
}

.msss-product-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.msss-product-link:hover {
    background: #f6f7f7;
}

.msss-product-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f6f7f7;
}

.msss-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msss-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.msss-product-name {
    font-size: var(--msss-font-size);
    font-weight: 600;
    color: var(--msss-text-color);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.msss-product-sku {
    font-size: 11px;
    color: var(--msss-text-secondary);
}

.msss-product-categories {
    font-size: 12px;
    color: var(--msss-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msss-product-price-stock {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.msss-product-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--msss-primary-color);
}

.msss-product-price del {
    color: var(--msss-text-secondary);
    font-weight: 400;
    margin-right: 5px;
}

.msss-product-price ins {
    text-decoration: none;
    color: var(--msss-error-color);
}

.msss-product-stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.msss-product-stock.in-stock {
    background: rgba(0, 163, 42, 0.1);
    color: var(--msss-success-color);
}

.msss-product-stock.out-of-stock {
    background: rgba(214, 54, 56, 0.1);
    color: var(--msss-error-color);
}

/* View All */
.msss-view-all {
    padding: 15px;
    text-align: center;
    border-top: 1px solid var(--msss-border-color);
}

.msss-view-all-link {
    display: inline-block;
    padding: 10px 25px;
    background: var(--msss-primary-color);
    color: #fff !important;
    text-decoration: none;
    border-radius: var(--msss-border-radius);
    font-size: var(--msss-font-size);
    font-weight: 500;
    transition: background 0.2s ease;
}

.msss-view-all-link:hover {
    background: var(--msss-primary-hover);
}

/* No Results */
.msss-no-results {
    padding: 30px 15px;
    text-align: center;
}

.msss-no-results p {
    margin: 0 0 15px 0;
    color: var(--msss-text-secondary);
    font-size: var(--msss-font-size);
}

/* Suggestions Section (No Results) */
.msss-suggestions-section {
    margin-top: 15px;
    text-align: left;
}

.msss-suggestions-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--msss-text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 0 5px;
}

.msss-suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msss-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-radius: 6px;
    margin: 0 5px 5px 5px;
    background: #f6f7f7;
}

.msss-suggestion-item:hover {
    background: #e9ecef;
}

.msss-suggestion-item svg {
    color: var(--msss-primary-color);
    flex-shrink: 0;
}

.msss-suggestion-item span {
    font-size: var(--msss-font-size);
    color: var(--msss-text-color);
    font-weight: 500;
}

/* Correction Notice */
.msss-correction-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(34, 113, 177, 0.08);
    color: var(--msss-primary-color);
    font-size: 13px;
    margin: 0 10px 10px 10px;
    border-radius: 6px;
}

.msss-correction-notice svg {
    flex-shrink: 0;
}

.msss-correction-notice strong {
    font-weight: 600;
}

/* Highlighted Text */
.msss-highlight {
    background: rgba(34, 113, 177, 0.15);
    padding: 0 2px;
    border-radius: 2px;
}

/* Style Variations */
/* Dark Style */
.msss-search-wrapper[data-style="dark"] {
    --msss-background: #1d2327;
    --msss-text-color: #fff;
    --msss-text-secondary: #a7aaad;
    --msss-border-color: #3c434a;
}

.msss-search-wrapper[data-style="dark"] .msss-history-item:hover,
.msss-search-wrapper[data-style="dark"] .msss-category-item a:hover,
.msss-search-wrapper[data-style="dark"] .msss-product-link:hover {
    background: #2c3338;
}

/* Rounded Style */
.msss-search-wrapper[data-style="rounded"] .msss-search-input-wrapper {
    border-radius: 50px;
}

.msss-search-wrapper[data-style="rounded"] .msss-search-submit {
    border-radius: 0 50px 50px 0;
}

/* Minimal Style */
.msss-search-wrapper[data-style="minimal"] .msss-search-input-wrapper {
    border: none;
    border-bottom: 2px solid var(--msss-border-color);
    border-radius: 0;
}

.msss-search-wrapper[data-style="minimal"] .msss-search-submit {
    background: transparent;
    color: var(--msss-primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .msss-search-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        max-height: 70vh;
        border-radius: var(--msss-border-radius) var(--msss-border-radius) 0 0;
    }

    .msss-product-image {
        width: 50px;
        height: 50px;
    }

    .msss-product-name {
        font-size: 13px;
    }
}

/* Scrollbar Styling */
.msss-search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.msss-search-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.msss-search-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.msss-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Active/Focus States */
.msss-history-item.active,
.msss-category-item.active a,
.msss-product-item.active .msss-product-link {
    background: #f0f0f1 !important;
}

/* Loading State */
.msss-search-wrapper.is-loading .msss-search-icon {
    display: none;
}

.msss-search-wrapper.is-loading .msss-search-loader {
    display: flex !important;
}

/* Animation for dropdown */
.msss-search-dropdown {
    animation: msss-slideDown 0.2s ease;
}

@keyframes msss-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
