/**
 * PBM Smart Search - Frontend Styles
 * Matches the existing theme styling with Archivo font and slate/primary colors
 */

/* Search Results Container */
.pbm-search-results {
    padding: 0;
}

.pbm-search-results:empty {
    display: none;
}

/* Result Item */
.pbm-result-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none !important;
    color: #334155; /* slate-700 */
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f1f5f9; /* slate-100 */
}

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

.pbm-result-item:hover {
    background-color: #f8fafc; /* slate-50 */
}

/* Result Image */
.pbm-result-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: #f1f5f9; /* slate-100 */
}

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

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

.pbm-result-name {
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25;
    color: #0f172a; /* slate-900 */
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pbm-result-name mark {
    background-color: #fef9c3; /* yellow-100 */
    color: inherit;
    padding: 0 0.125rem;
    border-radius: 0.125rem;
}

/* Result Meta (SKU & Stock) */
.pbm-result-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.pbm-result-sku {
    color: #64748b; /* slate-500 */
}

.pbm-result-stock {
    font-weight: 500;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.pbm-result-stock.in-stock {
    background-color: #dcfce7; /* green-100 */
    color: #166534; /* green-800 */
}

.pbm-result-stock.out-of-stock {
    background-color: #fee2e2; /* red-100 */
    color: #991b1b; /* red-800 */
}

.pbm-result-stock.on-backorder {
    background-color: #fef3c7; /* amber-100 */
    color: #92400e; /* amber-800 */
}

/* Result Price */
.pbm-result-price {
    font-weight: 700;
    font-size: 0.875rem;
    color: #dc2626; /* primary-600 */
    font-variation-settings: 'wdth' 125;
}

.pbm-result-price del {
    color: #94a3b8; /* slate-400 */
    font-weight: 400;
    margin-right: 0.375rem;
}

.pbm-result-price ins {
    text-decoration: none;
}

/* Loading State */
.pbm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    color: #64748b; /* slate-500 */
    font-size: 0.875rem;
}

.pbm-spinner {
    width: 1.25rem;
    height: 1.25rem;
    animation: pbm-spin 1s linear infinite;
}

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

/* No Results */
.pbm-no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #64748b; /* slate-500 */
    font-size: 0.875rem;
}

/* Popular Section - Styling for dynamically generated content */
.pbm-popular-section {
    border-top: 1px solid #f1f5f9; /* slate-100 */
}

.pbm-search-results:empty + .pbm-popular-section {
    border-top: none;
}

.pbm-popular-header {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8; /* slate-400 */
}

.pbm-popular-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: #334155; /* slate-700 */
    text-decoration: none !important;
    font-size: 0.875rem;
    transition: background-color 0.15s ease;
}

.pbm-popular-item:hover {
    background-color: #f8fafc; /* slate-50 */
}

.pbm-popular-icon {
    width: 0.875rem;
    height: 0.875rem;
    color: #94a3b8; /* slate-400 */
    flex-shrink: 0;
}

/* Standalone Dropdown (fallback when no Alpine dropdown exists) */
.pbm-smart-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9; /* slate-100 */
    z-index: 50;
    padding: 0.75rem 0;
    max-height: 400px;
    overflow-y: auto;
}

/* Scrollbar styling */
.pbm-smart-search-dropdown::-webkit-scrollbar {
    width: 0.375rem;
}

.pbm-smart-search-dropdown::-webkit-scrollbar-track {
    background-color: #f1f5f9; /* slate-100 */
}

.pbm-smart-search-dropdown::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* slate-300 */
    border-radius: 9999px;
}

.pbm-smart-search-dropdown::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8; /* slate-400 */
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .pbm-result-item {
        padding: 0.625rem 0.75rem;
    }

    .pbm-result-image {
        width: 40px;
        height: 40px;
    }

    .pbm-result-name {
        font-size: 0.8125rem;
    }

    .pbm-result-meta {
        flex-wrap: wrap;
        gap: 0.375rem;
    }

    .pbm-result-price {
        font-size: 0.8125rem;
    }
}
