/**
 * Nivo AJAX Search for WooCommerce - Styles
 * 
 * Professional CSS with scalable architecture and customization support
 * 
 * @package NivoSearch
 * @since 1.0.0
 */

/* CSS Custom Properties for easy customization */
:root {
    --nivo-search-primary-color: #0073aa;
    --nivo-search-border-color: #ddd;
    --nivo-search-border-radius: 4px;
    --nivo-search-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --nivo-search-transition: all 0.3s ease;
    --nivo-search-font-size-base: 15px;
    --nivo-search-spacing-xs: 5px;
    --nivo-search-spacing-sm: 10px;
    --nivo-search-spacing-md: 15px;
    --nivo-search-spacing-lg: 20px;
    --nivo-search-z-index-dropdown: 1000;

    /* Theme inheritance - can be overridden by settings */
    --nivo-search-font-family: inherit;
    --nivo-search-text-color: inherit;
    --nivo-search-hover-color: inherit;
    --nivo-search-hover-bg: rgba(0, 0, 0, 0.05);
}

/* Main Container */
.nivo-ajax-search-container {
    position: relative;
}

.nivo-search-form-wrapper,
.nivo-search-results {
    max-width: 600px;
    margin: 0 auto;
}

.nivo-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.nivo-search-form {
    margin: 0;
    width: 100%;
}

.nivo-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
    z-index: 5;
}

.nivo-search-clear-search {
    position: absolute;
    right: 15px;
    top: 47%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 22px;
    color: #999;
    line-height: 1;
    padding: 5px;
    z-index: 10;
    background: none;
    border: none;
    transition: color 0.2s;
}

.nivo-search-clear-search:hover {
    color: #333;
}

button.nivosearch-search-submit {
    overflow: visible;
    position: absolute;
    border: 0;
    padding: 0 15px;
    margin: 0;
    cursor: pointer;
    height: 40px;
    min-width: 50px;
    width: auto;
    line-height: 100%;
    min-height: 100%;
    right: 0;
    left: auto;
    top: 0;
    bottom: auto;
    -webkit-transition: 250ms ease-in-out;
    -moz-transition: 251ms ease-in-out;
    -ms-transition: 250ms ease-in-out;
    -o-transition: 250ms ease-in-out;
    transition: 250ms ease-in-out;
    text-transform: uppercase;
    background-color: transparent;
    -webkit-appearance: none;
}

.nivo-search-loader-icons {
    position: absolute;
    right: 50px;
    top: auto;
    width: 30px;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    height: 100%;
}

.nivo-search-loader-icons.nivo-search-close {
    display: flex;
}








/* Search layout */
.nivo-search-search-icon-wrap {
    width: 50px;
    text-align: center;
    position: absolute;
    height: 100%;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    left: auto;
    right: 0;
}

/* Search Input */
.nivo-search-wrapper input[type=search].nivo-search-product-search {
    height: 50px;
    width: 100%;
    padding: 0 50px 0 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 15px;
    transition: var(--nivo-search-transition);
    box-sizing: border-box;
    outline: none;
}

.nivo-search-form .nivo-search-wrapper input[type=search].nivo-search-product-search:focus {
    outline: 0;
    box-shadow: 0 0 9px 1px rgba(0, 0, 0, .06);
    transition: var(--nivo-search-transition);
}

.nivo-search-wrapper .nivo-search-product-search::placeholder {
    color: #999;
}

/* Hide the browser's native clear (×) button on type="search" inputs.
   The plugin renders its own close icon via .nivo-search-close-icon. */
.nivo-search-product-search::-webkit-search-cancel-button,
.nivo-search-product-search::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.nivo-search-form .nivo-search-wrapper {
    margin: 0;
    padding: 0;
}

input.nivo-search-product-search.form-control {
    margin-bottom: 0;
}

/* Loading State */
.nivo-ajax-search-container.nivo-search-loading .nivo-search-wrapper::after {
    content: '';
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--nivo-search-primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Results Container — flex column so view-all sticks to bottom */
.nivo-search-results {
    padding: 0;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 450px;
    overflow: hidden;
    z-index: var(--nivo-search-z-index-dropdown);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
}

.nivo-ajax-search-container.nivo-search-has-results .nivo-search-results,
.nivo-ajax-search-container.nivo-search-no-results .nivo-search-results {
    display: flex;
}

/* Scrollable results area — grows to fill panel, scrolls when results overflow */
.nivo-search-scrollable {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 5px;
}

/* Results List */
ul.nivo-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nivo-search-result-item {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

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

.nivo-search-result-item:hover {
    background-color: var(--nivo-search-hover-bg);
}

/* Product Link */
.nivo-search-result-item a.nivo-search-product-link {
    display: flex;
    align-items: center;
    text-decoration: none !important;
    color: var(--nivo-search-text-color);
    transition: all 0.2s ease;
    gap: 10px;
    padding: 5px;
    border-radius: 4px;
}

.nivo-search-product-link .amount {
    color: var(--nivo-search-text-color);
}

/* Product Image */
.nivo-search-product-image {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
    background: #f0f0f0;
    display: block;
}

/* Product Info */
.nivo-search-product-info {
    flex: 1;
    min-width: 0;
}


.nivo-search-product-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
    flex-shrink: 1;
    min-width: 0;
}

.nivo-search-product-title strong {
    color: #999;
    font-size: 13px;
    font-weight: 600;
    margin-left: 4px;
}

.nivo-search-product-description {
    display: block;
    color: inherit;
    opacity: 0.65;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nivo-search-product-categories,
.nivo-search-product-tags {
    display: inline-block;
    color: inherit;
    opacity: 0.6;
    font-size: 12px;
    margin-top: 4px;
}

/* Keyword Highlighting */
.nivo-search-highlight {
    background-color: #fff3cd;
    color: #856404;
    font-weight: 600;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Category Results */
.nivo-search-categories-section,
.nivo-search-tags-section,
.nivo-search-products-section {
    margin-bottom: 10px;
}

.nivo-search-categories-section:last-child,
.nivo-search-tags-section:last-child,
.nivo-search-products-section:last-child {
    margin-bottom: 0;
}

.nivo-search-section-title {
    margin: 0 0 8px 0;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

ul.nivo-search-categories-list,
ul.nivo-search-tags-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nivo-search-category-item,
.nivo-search-tag-item {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.nivo-search-category-item:last-child,
.nivo-search-tag-item:last-child {
    border-bottom: none;
}

.nivo-search-category-item:hover,
.nivo-search-tag-item:hover {
    background-color: var(--nivo-search-hover-bg);
}

.nivo-search-category-link,
.nivo-search-tag-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none !important;
    color: var(--nivo-search-text-color);
    transition: all 0.2s ease;
    padding: 5px;
    border-radius: 4px;
}

.nivo-search-category-title,
.nivo-search-tag-title {
    font-size: 14px;
    line-height: 1.4;
    color: inherit;
    flex: 1;
}

.nivo-search-category-count,
.nivo-search-tag-count {
    color: #999;
    font-size: 12px;
    font-weight: 500;
}

/* Messages */
.nivo-search-no-results-message,
.nivo-search-error-message {
    padding: 20px;
    margin: 0;
    text-align: center;
    color: #646970;
    font-size: 15px;
}

.nivo-search-no-results-message {
    background: #f8f9fa;
    border-radius: 4px;
}

.nivo-search-error-message {
    color: #d63638;
    background-color: #fef7f7;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nivo-ajax-search-container {
        max-width: 100%;
    }

    .nivo-search-results {
        max-height: 300px;
    }

    .nivo-search-product-image {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .nivo-search-product-link {
        padding: var(--nivo-search-spacing-xs);
    }

    .nivo-search-product-image {
        width: 35px;
        height: 35px;
    }

    .nivo-search-product-title {
        font-size: 0.9em;
    }

    .nivo-search-product-price {
        font-size: 0.8em;
    }
}

/* =============================================================
   Phase 2 — Display Layer (Compact)
   ============================================================= */

/* Product item: thumbnail | info column | actions column */
.nivo-search-result-item {
    display: flex;
    align-items: flex-start;
    padding: 8px 10px;
    gap: 9px;
    border-bottom: 1px solid #f0f0f0;
}

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

.nivo-search-result-item a.nivo-search-product-link {
    flex-shrink: 0;
    display: block;
    padding: 0;
    line-height: 0;
}

/* Left info column: title → desc → badges stacked tightly */
.nivo-search-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Title link — flex row so SKU sits immediately after title text */
.nivo-search-product-title-link {
    text-decoration: none !important;
    color: inherit;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 5px;
    overflow: hidden;
}
.nivo-search-product-title-link:hover .nivo-search-product-title {
    color: var(--nivo-search-primary-color);
}

/* SKU — inline immediately after title text, never truncates */
.nivo-search-product-sku {
    font-size: 12px;
    color: #bbb;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.2px;
    font-weight: 400;
}

/* Right-side group: price on top, qty + cart below — two stacked rows */
.nivo-search-product-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Price inside actions group */
.nivo-search-product-price {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    color: inherit;
    flex-shrink: 0;
}

.nivo-search-product-price .amount {
    color: inherit;
}

/* ---- Stock Status Badge ---- */
.nivo-stock-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.6;
}

.nivo-stock-instock {
    background: #d4edda;
    color: #155724;
}

.nivo-stock-outofstock {
    background: #f8d7da;
    color: #721c24;
}

.nivo-stock-onbackorder {
    background: #fff3cd;
    color: #856404;
}

/* ---- Category Badges ---- */
.nivo-search-category-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nivo-cat-badge {
    display: inline-block;
    padding: 1px 6px;
    background: #f0f0f0;
    color: #666 !important;
    border-radius: 2px;
    font-size: 12px;
    text-decoration: none !important;
    transition: background 0.15s;
}

.nivo-cat-badge:hover {
    background: #e0e0e0;
    color: #333 !important;
}

/* Chips row: stock · category · ratings on one line */
.nivo-search-meta-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

/* ---- Add to Cart ---- */
.nivo-add-to-cart-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Icon-only cart button */
.nivo-add-to-cart-btn.nivo-atc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--nivo-search-primary-color, #0073aa);
    color: #fff !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.18s, transform 0.12s;
    flex-shrink: 0;
    line-height: 1;
}

.nivo-add-to-cart-btn.nivo-atc-icon svg {
    display: block;
    pointer-events: none;
}

.nivo-add-to-cart-btn.nivo-atc-icon:hover {
    background: #005d8f;
    transform: scale(1.08);
}

.nivo-add-to-cart-btn.nivo-atc-loading {
    opacity: 0.7;
    cursor: wait;
    transform: none !important;
}

.nivo-add-to-cart-btn.nivo-atc-loading svg {
    animation: nivo-spin 0.7s linear infinite;
}

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

.nivo-add-to-cart-btn.nivo-atc-added {
    background: #4caf50 !important;
    transform: none !important;
}

.nivo-add-to-cart-btn.nivo-atc-variable {
    background: #888;
}

.nivo-add-to-cart-btn.nivo-atc-variable:hover {
    background: #555;
}

.nivo-out-of-stock-label {
    font-size: 10px;
    color: #bbb;
    flex-shrink: 0;
}

/* ---- Quantity Selector (compact) ---- */
.nivo-qty-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    overflow: hidden;
    height: 22px;
}

.nivo-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 22px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
    color: #555;
    transition: background 0.15s;
    flex-shrink: 0;
}

.nivo-qty-btn:hover {
    background: #e5e5e5;
}

.nivo-qty-input {
    width: 28px;
    height: 22px;
    text-align: center;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    font-size: 11px;
    padding: 0;
    -moz-appearance: textfield;
    background: #fff;
}

.nivo-qty-input::-webkit-inner-spin-button,
.nivo-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---- View All Results — sticky footer of the results panel ---- */
.nivo-search-view-all {
    flex-shrink: 0;
    border-top: 1px solid #eee;
    padding: 5px 12px;
    text-align: center;
    background: #fafafa;
    line-height: 1.4;
}

.nivo-search-view-all-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--nivo-search-primary-color, #0073aa) !important;
    text-decoration: none !important;
    transition: color 0.2s;
    display: block;
    padding: 4px 8px;
}

.nivo-search-view-all-link:hover {
    text-decoration: underline !important;
}

/* ---- Phase 2 responsive ---- */
@media (max-width: 480px) {
    .nivo-add-to-cart-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    .nivo-search-product-meta {
        gap: 4px;
    }
    .nivo-qty-wrapper {
        display: none; /* hide qty on very small screens */
    }
}