/**
 * BCN Live Search Styles
 */

/* Container */
.bcn-live-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Input Wrapper */
.bcn-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.bcn-search-input {
    width: 100%;
    padding: 14px 45px 14px 45px!important;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    color: white!important;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #434549!important;
}

.bcn-search-input:focus {
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

.bcn-search-input::placeholder {
    color: #f7f7f7!important;
}

/* Search Icon */
.bcn-search-icon,
.bcn-search-spinner {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #f7f7f7!important;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bcn-search-spinner{
    color: #434549!important;
}

/* Spinner Animation */
.bcn-search-spinner svg {
    animation: bcn-spin 1s linear infinite;
}

@keyframes bcn-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Clear Button */
.bcn-search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: #434549!important;
    color: #f7f7f7!important;
    font-size: 18px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bcn-search-clear:hover {
    background: #d0d0d0;
    color: #333;
}

/* Results Container */
.bcn-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    max-height: 450px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Results List */
.bcn-search-results-list {
    overflow-y: auto;
    max-height: 380px;
}

/* Result Item */
.bcn-search-result-item {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
}

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

.bcn-search-result-item:hover,
.bcn-search-result-item.bcn-selected {
    background-color: #f7f9fc;
}

.bcn-result-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    gap: 14px;
}

/* Result Image */
.bcn-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}

.bcn-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Result Info */
.bcn-result-info {
    flex: 1;
    min-width: 0;
}

.bcn-result-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bcn-result-title mark {
    background-color: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.bcn-result-sku {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.bcn-result-sku mark {
    background-color: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.bcn-matched-in {
    font-size: 11px;
    color: #2271b1;
    display: block;
    margin-bottom: 4px;
}

.bcn-result-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bcn-result-price {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
}

.bcn-result-price del {
    color: #999;
    font-weight: 400;
    font-size: 12px;
}

.bcn-result-price ins {
    text-decoration: none;
    color: #c00;
}

.bcn-result-stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.bcn-result-stock.in-stock {
    background-color: #d4edda;
    color: #155724;
}

.bcn-result-stock.out-of-stock {
    background-color: #f8d7da;
    color: #721c24;
}

/* View All Link */
.bcn-search-view-all {
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.bcn-search-view-all a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    color: #2271b1;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.15s ease;
}

.bcn-search-view-all a:hover {
    background-color: #f0f0f0;
}

/* No Results */
.bcn-search-no-results,
.bcn-search-error {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.bcn-no-results-icon,
.bcn-error-icon {
    display: block;
    font-size: 32px;
    margin-bottom: 10px;
}

/* Loading State */
.bcn-live-search-container.bcn-loading .bcn-search-input {
    background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: bcn-shimmer 1.5s infinite;
    color: #434549!important;
}

@keyframes bcn-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .bcn-live-search-container {
        max-width: 100%;
    }
    
    .bcn-search-input {
        padding: 12px 40px 12px 40px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .bcn-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
    }
    
    .bcn-result-image {
        width: 50px;
        height: 50px;
    }
    
    .bcn-result-link {
        padding: 10px 14px;
        gap: 12px;
    }
    
    .bcn-result-title {
        font-size: 13px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .bcn-search-input {
        background-color: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .bcn-search-input:focus {
        box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.2);
    }
    
    .bcn-search-input::placeholder {
        color: #888;
    }
    
    .bcn-search-results {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .bcn-search-result-item {
        border-color: #3d3d3d;
    }
    
    .bcn-search-result-item:hover,
    .bcn-search-result-item.bcn-selected {
        background-color: #3d3d3d;
    }
    
    .bcn-result-title {
        color: #e0e0e0;
    }
    
    .bcn-result-title mark,
    .bcn-result-sku mark {
        background-color: #5c4a00;
    }
    
    .bcn-result-sku {
        color: #aaa;
    }
    
    .bcn-result-price {
        color: #e0e0e0;
    }
    
    .bcn-search-view-all {
        background: #252525;
        border-color: #444;
    }
    
    .bcn-search-view-all a:hover {
        background-color: #3d3d3d;
    }
    
    .bcn-search-no-results,
    .bcn-search-error {
        color: #aaa;
    }
}

/* Accessibility */
.bcn-search-input:focus-visible {
    outline-offset: 2px;
}

.bcn-search-result-item:focus-within {
    outline-offset: -2px;
}

/* Print */
@media print {
    .bcn-live-search-container {
        display: none;
    }
}
