/* Bartleby Product Search - Frontend Styles */

.bartleby-product-search-wrapper {
    margin: 20px 0;
    padding: 15px;
    background: #fff;
    border-radius: 0;
    width: 100%;
    box-sizing: border-box;
}

.bartleby-product-search-wrapper *,
.bartleby-product-search-wrapper *::before,
.bartleby-product-search-wrapper *::after {
    box-sizing: border-box;
}

.bartleby-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.bartleby-product-search-wrapper .bartleby-search-input,
.bartleby-product-search-wrapper input[type="search"].bartleby-search-input {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    background: #fff !important;
    color: #333 !important;
    padding: 12px 45px 12px 15px !important;
    font-size: 16px !important;
    line-height: 1.4;
    border: 2px solid #ddd !important;
    border-radius: 0 !important;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-shadow: none;
    transition: border-color 0.3s ease;
}

.bartleby-search-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.bartleby-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bartleby-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    padding-right: 5px; /* Spazio per scrollbar */
}

.bartleby-search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.bartleby-search-result-item:hover {
    background: #f8f9fa;
}

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

.bartleby-search-result-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0;
    margin-right: 12px;
    flex-shrink: 0;
}

.bartleby-search-result-content {
    flex: 1;
}

.bartleby-search-result-content {
    min-width: 0;
}

.bartleby-search-result-title {
    overflow-wrap: anywhere;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.bartleby-search-result-price {
    color: #2271b1;
    font-weight: 600;
    font-size: 14px;
}

.bartleby-search-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
}

.bartleby-search-all {
    justify-content: center;
    font-weight: 600;
    color: #2271b1;
    background: #fafafa;
}

.bartleby-search-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* Responsive */
@media (max-width: 768px) {
    .bartleby-product-search-wrapper {
        padding: 10px;
        margin: 12px 0;
    }
    .bartleby-search-container {
        max-width: 100%;
    }
    .bartleby-search-input {
        font-size: 16px; /* 16px stops iOS zoom on focus */
        padding: 10px 40px 10px 12px;
    }
    .bartleby-search-results {
        max-height: 60vh;
    }
    .bartleby-search-result-item {
        padding: 10px;
    }
    .bartleby-search-result-image {
        width: 48px;
        height: 48px;
        margin-right: 10px;
    }
    .bartleby-search-result-title {
        font-size: 14px;
    }
    .bartleby-search-result-price {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .bartleby-product-search-wrapper {
        padding: 8px;
    }
    .bartleby-search-result-image {
        width: 40px;
        height: 40px;
    }
}

/* Hide the old core Search block left in the front-page content (replaced by this box). */
body.home form.wp-block-search[action] {
    display: none !important;
}
