/* Sistema di ricerca prodotti */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto 1rem;
    padding: 0 1rem;
}

/* Search container nel page-title */
.page-title .search-container {
    display: flex;
    flex: 1;
    max-width: 400px;
    margin: 0 1rem;
    padding: 0;
    order: 2;
    align-items: center;
}

.page-title .search-input {
    font-size: 0.9rem;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
}

.page-title .search-icon {
    width: 18px;
    height: 18px;
    right: 0.75rem;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    color: #111827;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    color: #9ca3af;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
}

.search-results-empty {
    padding: 1.5rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.9375rem;
}

.search-result-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.search-result-item:hover,
.search-result-item.highlighted {
    background-color: #f9fafb;
}

.search-result-item:active {
    background-color: #f3f4f6;
}

.search-result-product-name {
    font-weight: 600;
    color: #111827;
    font-size: 0.9375rem;
    flex: 1;
}

.search-result-product-name mark {
    background-color: #fef3c7;
    color: #111827;
    padding: 0;
    font-weight: 700;
}

.search-result-category {
    font-size: 0.8125rem;
    color: #6b7280;
    padding: 0.25rem 0.5rem;
    background-color: #f3f4f6;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.search-result-price {
    font-weight: 600;
    color: #007bff;
    font-size: 0.9375rem;
    white-space: nowrap;
}

/* Scrollbar personalizzata per risultati */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 0 0.75rem 0.75rem 0;
}

.search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Animazione per prodotto evidenziato (blu - quando aggiunto) */
@keyframes highlightProduct {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(0, 123, 255, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

.cassa-prodotto-item.prodotto-highlighted {
    animation: highlightProduct 2s ease-in-out;
}

/* Animazione per prodotto cercato (giallo - solo marcatura) */
@keyframes highlightSearched {
    0% {
        background-color: transparent;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }
    50% {
        background-color: rgba(255, 193, 7, 0.3);
        box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
        border-color: #ffc107;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }
}

.cassa-prodotto-item.prodotto-searched {
    animation: highlightSearched 2s ease-in-out;
    border-color: #ffc107 !important;
}

/* Tema dark - prodotto cercato */
@keyframes highlightSearchedDark {
    0% {
        background-color: transparent;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        background-color: rgba(255, 193, 7, 0.4);
        box-shadow: 0 4px 12px rgba(255, 193, 7, 0.5);
        border-color: #ffc107;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

.theme-dark .cassa-prodotto-item.prodotto-searched {
    animation: highlightSearchedDark 2s ease-in-out;
    border-color: #ffc107 !important;
}

/* Tema dark */
.theme-dark .search-input {
    background: #21252a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.theme-dark .search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.theme-dark .search-input::placeholder {
    color: #898989;
}

.theme-dark .search-icon {
    color: #898989;
}

.theme-dark .search-results {
    background: #1b1d21;
    border-color: rgba(255, 255, 255, 0.1);
}

.theme-dark .search-results-empty {
    color: #898989;
}

.theme-dark .search-result-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.theme-dark .search-result-item:hover,
.theme-dark .search-result-item.highlighted {
    background-color: #21252a;
}

.theme-dark .search-result-item:active {
    background-color: #2a2d35;
}

.theme-dark .search-result-product-name {
    color: #ffffff;
}

.theme-dark .search-result-product-name mark {
    background-color: rgba(0, 123, 255, 0.3);
    color: #ffffff;
}

.theme-dark .search-result-category {
    color: #898989;
    background-color: #21252a;
}

.theme-dark .search-result-price {
    color: #007bff;
}

.theme-dark .search-results::-webkit-scrollbar-track {
    background: #1b1d21;
}

.theme-dark .search-results::-webkit-scrollbar-thumb {
    background-color: #434a54;
}

.theme-dark .search-results::-webkit-scrollbar-thumb:hover {
    background-color: #5a6268;
}

/* Responsive */
@media (max-width: 640px) {
    .search-container {
        margin: 0 auto 1rem;
        padding: 0 0.75rem;
    }
    
    .search-input {
        padding: 0.75rem 2.5rem 0.75rem 0.875rem;
        font-size: 0.9375rem;
    }
    
    .search-results {
        max-height: 300px;
    }
    
    .search-result-item {
        padding: 0.75rem;
        flex-wrap: wrap;
    }
    
    .search-result-product-name {
        width: 100%;
        margin-bottom: 0.25rem;
    }
}

