/**
 * Bruo Product Search Styles
 */

/* Search Container */
.bps-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Search Wrapper */
.bps-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Search Input */
.bps-search-input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    background-color: #fff;
}

.bps-search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Search Icon */
.bps-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.bps-search-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Loading Spinner */
.bps-loading {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

.bps-spinner {
    animation: bps-spin 1s linear infinite;
}

.bps-spinner circle {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    animation: bps-dash 1.5s ease-in-out infinite;
}

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

@keyframes bps-dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Results Container */
.bps-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
    z-index: 9999;
    animation: bps-fadeIn 0.3s ease;
}

@keyframes bps-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results Header */
.bps-results-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Product Item */
.bps-product-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.bps-product-item:last-child {
    border-bottom: none;
}

.bps-product-item:hover {
    background-color: #f8f9fa;
}

/* Product Image */
.bps-product-image {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f5f5f5;
}

.bps-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.bps-product-title {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin: 0 0 5px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bps-product-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bps-product-price {
    font-size: 14px;
    font-weight: 600;
    color: #e74c3c;
}

.bps-product-price del {
    color: #999;
    font-weight: 400;
    margin-right: 5px;
}

.bps-product-stock {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: #e8f5e9;
    color: #2e7d32;
}

.bps-product-stock.out-of-stock {
    background-color: #ffebee;
    color: #c62828;
}

/* No Results */
.bps-no-results {
    padding: 30px 15px;
    text-align: center;
    color: #999;
}

.bps-no-results-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.3;
}

.bps-no-results-text {
    font-size: 14px;
}

/* View All Link */
.bps-view-all {
    display: block;
    padding: 12px 15px;
    text-align: center;
    color: #3498db;
    font-weight: 500;
    border-top: 1px solid #eee;
    transition: background-color 0.2s ease;
    text-decoration: none;
}

.bps-view-all:hover {
    background-color: #f8f9fa;
}

/* Scrollbar */
.bps-results::-webkit-scrollbar {
    width: 6px;
}

.bps-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.bps-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

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

/* ========================================
   Mobile Icon Mode
======================================== */

/* Mobile Icon Button */
.bps-mobile-icon {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.bps-mobile-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.bps-mobile-icon:active {
    transform: scale(0.95);
}

.bps-mobile-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

/* Desktop - always show normal search, hide mobile icon */
.bps-desktop-search {
    display: block;
}

.bps-mobile-icon {
    display: none;
}

/* Mobile/Tablet - when mobile icon mode is enabled */
@media screen and (max-width: 1024px) {
    .bps-mobile-icon-mode .bps-desktop-search {
        display: none;
    }

    .bps-mobile-icon-mode .bps-desktop-results {
        display: none !important;
    }

    .bps-mobile-icon-mode .bps-mobile-icon {
        display: flex;
    }
}

/* Mobile Overlay */
.bps-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bps-mobile-overlay.active {
    display: block;
    opacity: 1;
}

.bps-mobile-overlay-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 20px;
    max-height: 100vh;
    overflow-y: auto;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bps-mobile-overlay.active .bps-mobile-overlay-content {
    transform: translateY(0);
}

/* Mobile Header */
.bps-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 15px;
}

.bps-mobile-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex: 1;
}

.bps-mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
    transition: all 0.2s ease;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 15px;
}

.bps-mobile-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.bps-mobile-close:active {
    transform: scale(0.95);
}

/* Mobile Overlay Search */
.bps-mobile-overlay .bps-search-wrapper {
    margin-bottom: 20px;
}

.bps-mobile-overlay .bps-search-input {
    font-size: 16px;
    padding: 14px 50px 14px 15px;
}

.bps-mobile-overlay .bps-results {
    position: relative;
    top: 0;
    box-shadow: none;
    border: 1px solid #e0e0e0;
    max-height: calc(100vh - 180px);
}

/* Prevent body scroll when overlay is open */
body.bps-overlay-open {
    overflow: hidden;
}

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

    .bps-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 10px 40px 10px 12px;
    }

    .bps-product-image {
        width: 50px;
        height: 50px;
        margin-right: 12px;
    }

    .bps-product-title {
        font-size: 14px;
    }

    .bps-product-price {
        font-size: 13px;
    }

    .bps-results {
        max-height: 400px;
    }
}

@media screen and (max-width: 480px) {
    .bps-product-item {
        padding: 10px 12px;
    }

    .bps-product-image {
        width: 45px;
        height: 45px;
        margin-right: 10px;
    }

    .bps-product-title {
        font-size: 13px;
    }

    .bps-product-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .bps-search-input {
        background-color: #2c2c2c;
        border-color: #444;
        color: #fff;
    }

    .bps-results {
        background-color: #2c2c2c;
        border-color: #444;
    }

    .bps-product-item:hover {
        background-color: #363636;
    }

    .bps-product-title {
        color: #fff;
    }

    .bps-results-header {
        border-bottom-color: #444;
        color: #aaa;
    }

    .bps-view-all {
        border-top-color: #444;
    }
}
