/**
 * Module DFLiveSearch - Styles CSS
 *
 * @author    DataFirefly
 * @copyright DataFirefly
 * @license   Commercial
 */

/* Variables */
:root {
    --dfls-primary: #2196F3;
    --dfls-primary-hover: #1976D2;
    --dfls-text: #333;
    --dfls-text-light: #666;
    --dfls-text-muted: #999;
    --dfls-border: #e0e0e0;
    --dfls-bg: #fff;
    --dfls-bg-hover: #f5f5f5;
    --dfls-overlay: rgba(0, 0, 0, 0.5);
    --dfls-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --dfls-radius: 8px;
    --dfls-discount: #e74c3c;
    --dfls-success: #27ae60;
}

/* Trigger button */
.dflivesearch-wrapper {
    position: relative;
    width: 100%;
}

.dflivesearch-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--dfls-bg);
    border: 1px solid var(--dfls-border);
    border-radius: var(--dfls-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.dflivesearch-trigger:hover {
    border-color: var(--dfls-primary);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
}

.dflivesearch-trigger i {
    color: var(--dfls-text-muted);
    font-size: 20px;
}

.dflivesearch-trigger-text {
    color: var(--dfls-text-muted);
    font-size: 14px;
}

/* Overlay */
.dflivesearch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dfls-overlay);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dflivesearch-overlay.active {
    display: flex;
    opacity: 1;
}

/* Modal */
.dflivesearch-modal {
    width: 100%;
    max-width: 900px;
    background: var(--dfls-bg);
    border-radius: var(--dfls-radius);
    box-shadow: var(--dfls-shadow);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    margin: 0 15px;
}

.dflivesearch-overlay.active .dflivesearch-modal {
    transform: translateY(0);
}

/* Header */
.dflivesearch-header {
    padding: 20px;
    border-bottom: 1px solid var(--dfls-border);
    flex-shrink: 0;
}

.dflivesearch-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border-radius: var(--dfls-radius);
    padding: 12px 16px;
}

.dflivesearch-icon {
    color: var(--dfls-text-muted);
    font-size: 24px;
    flex-shrink: 0;
}

.dflivesearch-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--dfls-text);
    outline: none;
}

.dflivesearch-input::placeholder {
    color: var(--dfls-text-muted);
}

.dflivesearch-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--dfls-text-muted);
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.dflivesearch-close:hover {
    color: var(--dfls-text);
}

.dflivesearch-close i {
    font-size: 24px;
}

/* Submit button */
.dflivesearch-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--dfls-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dflivesearch-submit:hover {
    background: var(--dfls-primary-hover);
    transform: scale(1.05);
}

.dflivesearch-submit i {
    font-size: 20px;
}

/* Body */
.dflivesearch-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Sections */
.dflivesearch-section {
    margin-bottom: 24px;
}

.dflivesearch-section:last-child {
    margin-bottom: 0;
}

.dflivesearch-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dflivesearch-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--dfls-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}

.dflivesearch-section-header .dflivesearch-section-title {
    margin: 0;
}

.dflivesearch-clear-all {
    background: none;
    border: none;
    color: var(--dfls-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.dflivesearch-clear-all:hover {
    color: var(--dfls-primary-hover);
    text-decoration: underline;
}

/* Recent searches tags */
.dflivesearch-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dflivesearch-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 13px;
    color: var(--dfls-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dflivesearch-tag:hover {
    background: #e0e0e0;
}

.dflivesearch-tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s ease;
}

.dflivesearch-tag-remove:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Popular searches list */
.dflivesearch-popular-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dflivesearch-popular-item {
    cursor: pointer;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    font-size: 14px;
    color: var(--dfls-text);
    transition: all 0.2s ease;
}

.dflivesearch-popular-item:hover {
    background: var(--dfls-primary);
    color: white;
}

/* Carousel */
.dflivesearch-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dflivesearch-carousel {
    flex: 1;
    overflow: hidden;
}

.dflivesearch-carousel-track {
    display: flex;
    gap: 16px;
    transition: transform 0.3s ease;
}

.dflivesearch-carousel-nav {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--dfls-bg);
    border: 1px solid var(--dfls-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}

.dflivesearch-carousel-nav:hover {
    background: var(--dfls-primary);
    border-color: var(--dfls-primary);
    color: white;
}

.dflivesearch-carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.dflivesearch-carousel-nav:disabled:hover {
    background: var(--dfls-bg);
    border-color: var(--dfls-border);
    color: inherit;
}

.dflivesearch-carousel-nav i {
    font-size: 20px;
}

/* Product card */
.dflivesearch-product {
    flex: 0 0 160px;
    text-decoration: none;
    color: var(--dfls-text);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--dfls-border);
    border-radius: var(--dfls-radius);
    overflow: hidden;
    transition: all 0.2s ease;
}

.dflivesearch-product:hover {
    border-color: var(--dfls-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.dflivesearch-product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #f8f9fa;
    overflow: hidden;
}

.dflivesearch-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.dflivesearch-product-discount {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--dfls-discount);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.35);
    z-index: 2;
}

.dflivesearch-product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dflivesearch-product-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--dfls-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}

.dflivesearch-product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dflivesearch-product-current-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--dfls-text);
}

.dflivesearch-product-regular-price {
    font-size: 12px;
    color: var(--dfls-text-muted);
    text-decoration: line-through;
}

.dflivesearch-product.has-discount .dflivesearch-product-current-price {
    color: var(--dfls-discount);
}

/* Search results - Grid layout */
.dflivesearch-results-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

/* Result item as card (like carousel products) */
.dflivesearch-result-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--dfls-border);
    border-radius: var(--dfls-radius);
    text-decoration: none;
    color: var(--dfls-text);
    overflow: hidden;
    transition: all 0.2s ease;
}

.dflivesearch-result-item:hover {
    border-color: var(--dfls-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.dflivesearch-result-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #f8f9fa;
    overflow: hidden;
}

.dflivesearch-result-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.dflivesearch-result-discount {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--dfls-discount);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.35);
    z-index: 2;
}

.dflivesearch-result-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dflivesearch-result-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}

.dflivesearch-result-reference {
    font-size: 11px;
    color: var(--dfls-text-muted);
}

.dflivesearch-result-price {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.dflivesearch-result-current-price {
    font-size: 14px;
    font-weight: 600;
}

.dflivesearch-result-regular-price {
    font-size: 12px;
    color: var(--dfls-text-muted);
    text-decoration: line-through;
}

.dflivesearch-result-item.has-discount .dflivesearch-result-current-price {
    color: var(--dfls-discount);
}

/* See all results button */
.dflivesearch-see-all-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--dfls-border);
}

.dflivesearch-see-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--dfls-primary);
    color: white;
    border: none;
    border-radius: var(--dfls-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dflivesearch-see-all:hover {
    background: var(--dfls-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.dflivesearch-see-all i {
    font-size: 18px;
}

/* No results */
.dflivesearch-no-results-text {
    text-align: center;
    color: var(--dfls-text-muted);
    font-size: 15px;
    padding: 40px 20px;
}

/* Autocomplete */
.dflivesearch-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--dfls-bg);
    border: 1px solid var(--dfls-border);
    border-top: none;
    border-radius: 0 0 var(--dfls-radius) var(--dfls-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.dflivesearch-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dflivesearch-autocomplete-item:hover {
    background: var(--dfls-bg-hover);
}

.dflivesearch-autocomplete-item i {
    color: var(--dfls-text-muted);
    font-size: 18px;
}

.dflivesearch-autocomplete-item[data-type="popular"] i {
    color: var(--dfls-primary);
}

.dflivesearch-autocomplete-item[data-type="category"] i {
    color: #FF9800;
}

.dflivesearch-autocomplete-item span {
    flex: 1;
    font-size: 14px;
}

/* Keyboard-highlighted suggestion */
.dflivesearch-autocomplete-item.active {
    background: var(--dfls-bg-hover);
}

/* Matched portion of a suggestion */
.dflivesearch-autocomplete-item span strong {
    font-weight: 700;
    color: var(--dfls-primary);
}

/* Typo-correction suggestion */
.dflivesearch-autocomplete-item[data-type="correction"] i {
    color: var(--dfls-success);
}

/* --- Did-you-mean / auto-correction notice --- */
.dflivesearch-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding: 10px 14px;
    background: var(--dfls-bg-hover);
    border: 1px solid var(--dfls-border);
    border-left: 3px solid var(--dfls-primary);
    border-radius: var(--dfls-radius);
    font-size: 14px;
    color: var(--dfls-text-light);
}

.dflivesearch-notice i {
    color: var(--dfls-primary);
    font-size: 18px;
    flex-shrink: 0;
}

.dflivesearch-notice .dflivesearch-notice-corrected {
    color: var(--dfls-text);
    font-weight: 700;
}

.dflivesearch-notice-original {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--dfls-primary);
    cursor: pointer;
    text-decoration: underline;
}

.dflivesearch-notice-original:hover {
    color: var(--dfls-primary-hover);
}

/* Input wrapper relative for autocomplete */
.dflivesearch-input-wrapper {
    position: relative;
}

/* Out of stock badge */
.dflivesearch-product-out-of-stock,
.dflivesearch-result-out-of-stock {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 5px 8px;
    text-align: center;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

.out-of-stock .dflivesearch-product-image img,
.out-of-stock .dflivesearch-result-image img {
    opacity: 0.5;
}

/* Add to cart wrapper */
.dflivesearch-add-cart-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Transient cart message (e.g. not enough stock) */
.dflivesearch-cart-msg {
    width: 100%;
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.3;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
}

.dflivesearch-cart-msg-error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--dfls-discount);
}

.dflivesearch-cart-msg-info {
    background: var(--dfls-bg-hover);
    color: var(--dfls-text-light);
}

/* Quantity selector */
.dflivesearch-qty-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--dfls-border);
    border-radius: 4px;
    overflow: hidden;
}

.dflivesearch-qty-btn {
    width: 28px;
    height: 28px;
    background: var(--dfls-bg-hover);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: var(--dfls-text);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dflivesearch-qty-btn:hover {
    background: #e0e0e0;
}

.dflivesearch-qty-input {
    width: 40px;
    height: 28px;
    border: none;
    border-left: 1px solid var(--dfls-border);
    border-right: 1px solid var(--dfls-border);
    text-align: center;
    font-size: 13px;
    -moz-appearance: textfield;
}

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

/* Add to cart button */
.dflivesearch-add-cart-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--dfls-primary);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.dflivesearch-add-cart-btn.dflivesearch-see-options {
    background: transparent;
    color: var(--dfls-primary);
    border: 1px solid var(--dfls-primary);
}

.dflivesearch-add-cart-btn.dflivesearch-see-options:hover {
    background: var(--dfls-primary);
    color: #fff;
}

.dflivesearch-add-cart-btn:hover {
    background: var(--dfls-primary-hover);
}

.dflivesearch-add-cart-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.dflivesearch-add-cart-btn.added {
    background: var(--dfls-success);
}

.dflivesearch-add-cart-btn i {
    font-size: 16px;
}

/* Spinner animation */
.dflivesearch-spin {
    animation: dfls-spin 1s linear infinite;
}

/* Product card adjustments for add to cart */
.dflivesearch-product,
.dflivesearch-result-item {
    display: flex;
    flex-direction: column;
}

.dflivesearch-product-info,
.dflivesearch-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.dflivesearch-product-price,
.dflivesearch-result-price {
    margin-top: auto;
}

/* Adjust carousel card width for add to cart */
.dflivesearch-product {
    flex: 0 0 180px;
}

/* Loading */
.dflivesearch-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.dflivesearch-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--dfls-border);
    border-top-color: var(--dfls-primary);
    border-radius: 50%;
    animation: dfls-spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .dflivesearch-overlay {
        padding-top: 0;
    }

    .dflivesearch-modal {
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .dflivesearch-product {
        flex: 0 0 140px;
    }

    .dflivesearch-carousel-nav {
        width: 32px;
        height: 32px;
    }

    .dflivesearch-result-item {
        gap: 0;
    }

    .dflivesearch-results-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .dflivesearch-trigger {
        min-width: auto;
        padding: 8px 12px;
    }

    .dflivesearch-trigger-text {
        display: none;
    }

    .dflivesearch-header {
        padding: 15px;
    }

    .dflivesearch-body {
        padding: 15px;
    }

    .dflivesearch-product {
        flex: 0 0 120px;
    }

    .dflivesearch-product-info {
        padding: 8px;
    }

    .dflivesearch-product-name {
        font-size: 12px;
        min-height: 32px;
    }

    .dflivesearch-carousel-wrapper {
        margin: 0 -15px;
        padding: 0 15px;
    }

    .dflivesearch-carousel-nav {
        display: none;
    }

    .dflivesearch-carousel {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .dflivesearch-carousel::-webkit-scrollbar {
        display: none;
    }

    .dflivesearch-product {
        scroll-snap-align: start;
    }
}

/* Print */
@media print {
    .dflivesearch-overlay {
        display: none !important;
    }
}

/* ==========================================================================
   Merchandising badges (dfquantitydeal / hook displayDfQdBadge)
   The image containers are already position: relative, the module ships
   .dfqd-thumb-badges positioning. These rules only handle stacking order
   and the inline variant that would otherwise break the absolute layout.
   ========================================================================== */
.dflivesearch-result-image .dfqd-thumb-badges,
.dflivesearch-product-image .dfqd-thumb-badges {
    z-index: 4;
}

.dflivesearch-result-image .dfqd-badges--inline,
.dflivesearch-product-image .dfqd-badges--inline {
    position: absolute;
    top: 8px;
    right: 8px;
    left: auto;
    margin: 0;
    z-index: 4;
}

.dflivesearch-result-image .dfqd-badge,
.dflivesearch-product-image .dfqd-badge {
    margin: 0 0 4px 0;
}

/* Out of stock dimming must not wash out the badge */
.out-of-stock .dflivesearch-product-image .dfqd-badge,
.out-of-stock .dflivesearch-result-image .dfqd-badge {
    opacity: 1;
}
