/*! @algolia/autocomplete-theme-classic 1.9.3 | MIT License | © Algolia, Inc.
and contributors | https://github.com/algolia/autocomplete
*/

/* Algolia Autocomplete CSS Variables */
:root {
    --aa-search-input-height: 44px;
    --aa-input-icon-size: 20px;
    --aa-base-unit: 16;
    --aa-spacing-factor: 1;
    --aa-spacing: calc(var(--aa-base-unit) * var(--aa-spacing-factor) * 1px);
    --aa-spacing-half: calc(var(--aa-spacing) / 2);
    --aa-panel-max-height: 650px;
    --aa-base-z-index: 9999;
    --aa-font-size: calc(var(--aa-base-unit) * 1px);
    --aa-font-family: inherit;
    --aa-font-weight-medium: 500;
    --aa-font-weight-semibold: 600;
    --aa-font-weight-bold: 700;
    --aa-icon-size: 20px;
    --aa-icon-stroke-width: 1.6;
    --aa-icon-color-rgb: 119, 119, 163;
    --aa-icon-color-alpha: 1;
    --aa-action-icon-size: 20px;
    --aa-text-color-rgb: 38, 38, 39;
    --aa-text-color-alpha: 1;
    --aa-primary-color-rgb: 62, 52, 211;
    --aa-primary-color-alpha: 1;
    --aa-muted-color-rgb: 128, 126, 163;
    --aa-muted-color-alpha: 0.6;
    --aa-panel-border-color-rgb: 128, 126, 163;
    --aa-panel-border-color-alpha: 0.3;
    --aa-input-border-color-rgb: 128, 126, 163;
    --aa-input-border-color-alpha: 0.8;
    --aa-background-color-rgb: 255, 255, 255;
    --aa-background-color-alpha: 1;
    --aa-input-background-color-rgb: 255, 255, 255;
    --aa-input-background-color-alpha: 1;
    --aa-selected-color-rgb: 179, 173, 214;
    --aa-selected-color-alpha: 0.205;
    --aa-description-highlight-background-color-rgb: 245, 223, 77;
    --aa-description-highlight-background-color-alpha: 0.5;
    --aa-panel-shadow: 0 0 0 1px rgba(35, 38, 59, 0.1), 0 6px 16px -4px rgba(35, 38, 59, 0.15);
}

/* Base Autocomplete Styles */
.aa-Autocomplete *, .aa-DetachedFormContainer *, .aa-Panel * {
    box-sizing: border-box;
}

.aa-Autocomplete, .aa-DetachedFormContainer, .aa-Panel {
    color: rgba(var(--aa-text-color-rgb), var(--aa-text-color-alpha));
    font-family: var(--aa-font-family);
    font-size: var(--aa-font-size);
    font-weight: 400;
    line-height: 1em;
    margin: 0;
    padding: 0;
    text-align: left;
}

/* Form Styles */
.aa-Form {
    align-items: center;
    background-color: rgba(var(--aa-input-background-color-rgb), var(--aa-input-background-color-alpha));
    border: 1px solid rgba(var(--aa-input-border-color-rgb), var(--aa-input-border-color-alpha));
    border-radius: 3px;
    display: flex;
    line-height: 1em;
    margin: 0;
    position: relative;
    width: 100%;
}

.aa-Form:focus-within {
    border-color: rgba(var(--aa-primary-color-rgb), 1);
    box-shadow: rgba(var(--aa-primary-color-rgb), var(--aa-primary-color-alpha)) 0 0 0 2px, inset rgba(var(--aa-primary-color-rgb), var(--aa-primary-color-alpha)) 0 0 0 2px;
    outline: medium none currentColor;
}

/* Input Wrapper Styles */
.aa-InputWrapperPrefix {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    height: var(--aa-search-input-height);
    order: 1;
}

.aa-InputWrapper {
    order: 3;
    position: relative;
    width: 100%;
}

.aa-Input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
    border: 0;
    color: rgba(var(--aa-text-color-rgb), var(--aa-text-color-alpha));
    font: inherit;
    height: var(--aa-search-input-height);
    padding: 0;
    width: 100%;
}

.aa-Input::-moz-placeholder {
    color: rgba(var(--aa-muted-color-rgb), var(--aa-muted-color-alpha));
    opacity: 1;
}

.aa-Input::placeholder {
    color: rgba(var(--aa-muted-color-rgb), var(--aa-muted-color-alpha));
    opacity: 1;
}

.aa-Input:focus {
    border-color: none;
    box-shadow: none;
    outline: none;
}

.aa-InputWrapperSuffix {
    align-items: center;
    display: flex;
    height: var(--aa-search-input-height);
    order: 4;
}

/* Clear Button */
.aa-ClearButton {
    align-items: center;
    background: none;
    border: 0;
    color: rgba(var(--aa-muted-color-rgb), var(--aa-muted-color-alpha));
    cursor: pointer;
    display: flex;
    height: 100%;
    margin: 0;
    padding: 0 calc(var(--aa-spacing) * 0.83333 - .5px);
}

.aa-ClearButton:focus, .aa-ClearButton:hover {
    color: rgba(var(--aa-text-color-rgb), var(--aa-text-color-alpha));
}

.aa-ClearButton[hidden] {
    display: none;
}

.aa-ClearButton svg {
    stroke-width: var(--aa-icon-stroke-width);
    width: var(--aa-icon-size);
}

/* Panel Styles */
.aa-Panel {
    background-color: rgba(var(--aa-background-color-rgb), var(--aa-background-color-alpha));
    border-radius: calc(var(--aa-spacing) / 4);
    box-shadow: var(--aa-panel-shadow);
    margin: 8px 0 0;
    overflow: hidden;
    position: absolute;
    transition: opacity .2s ease-in, filter .2s ease-in;
}

.aa-Panel button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
    border: 0;
    margin: 0;
    padding: 0;
}

.aa-PanelLayout {
    height: 100%;
    margin: 0;
    max-height: var(--aa-panel-max-height);
    overflow-y: auto;
    padding: 0;
    position: relative;
    text-align: left;
}

/* Source Styles */
.aa-Source {
    margin: 0;
    padding: 0;
    position: relative;
    width: 100%;
}

.aa-Source:empty {
    display: none;
}

.aa-List {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Item Styles */
.aa-Item {
    align-items: center;
    border-radius: 3px;
    cursor: pointer;
    display: grid;
    min-height: calc(var(--aa-spacing) * 2.5);
    padding: calc(var(--aa-spacing-half) / 2);
}

.aa-Item[aria-selected="true"] {
    background-color: rgba(var(--aa-selected-color-rgb), var(--aa-selected-color-alpha));
}

/* JTL-Shop Integration Styles */

/* Custom integration styles - maintain JTL-Shop layout */
.algolia-search-wrapper {
    min-width: 300px;
}

/* Override Algolia theme to integrate with JTL-Shop styling */
.algolia-search-wrapper .aa-Form,
#algolia-autocomplete .aa-Form,
#algolia-autocomplete-mobile .aa-Form {
    width: 100%;
}

.algolia-search-wrapper .aa-Input,
#algolia-autocomplete .aa-Input,
#algolia-autocomplete-mobile .aa-Input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Hide the unnecessary submit button */
.algolia-search-wrapper .aa-SubmitButton,
#algolia-autocomplete .aa-SubmitButton,
#algolia-autocomplete-mobile .aa-SubmitButton,
.aa-InputWrapperPrefix .aa-SubmitButton {
    display: none;
}

/* Position clear button inside the input field */
.algolia-search-wrapper .aa-InputWrapper,
#algolia-autocomplete .aa-InputWrapper,
#algolia-autocomplete-mobile .aa-InputWrapper {
    position: relative;
}

.algolia-search-wrapper .aa-ClearButton:hover,
#algolia-autocomplete .aa-ClearButton:hover,
#algolia-autocomplete-mobile .aa-ClearButton:hover {
    color: #dc3545;
}

.algolia-search-wrapper .aa-ClearIcon,
#algolia-autocomplete .aa-ClearIcon,
#algolia-autocomplete-mobile .aa-ClearIcon {
    width: 16px;
    height: 16px;
}

/* Hide the suffix wrapper since we're positioning clear button absolutely */
.algolia-search-wrapper .aa-InputWrapperSuffix,
#algolia-autocomplete .aa-InputWrapperSuffix,
#algolia-autocomplete-mobile .aa-InputWrapperSuffix {
    display: none;
}

/* Ensure autocomplete closes when modal opens */
/* Simplified: JavaScript adds body.algolia-modal-open class */
body.algolia-modal-open .aa-Panel {
    display: none;
}

/* Reset autocomplete state when modal is hidden */
body.algolia-modal-open .aa-Autocomplete {
    pointer-events: none;
}

/* Improve positioning of loading indicator */
.algolia-search-wrapper .aa-LoadingIndicator,
#algolia-autocomplete .aa-LoadingIndicator,
#algolia-autocomplete-mobile .aa-LoadingIndicator {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.algolia-search-wrapper .aa-Input:focus,
#algolia-autocomplete .aa-Input:focus,
#algolia-autocomplete-mobile .aa-Input:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: 0;
}

/* Enhanced dropdown positioning - Now handled by Cartzilla theme */
/* Commented code removed - see algolia-cartzilla-theme.css for panel positioning */

.algolia-search-wrapper .aa-PanelLayout,
#algolia-autocomplete .aa-PanelLayout,
#algolia-autocomplete-mobile .aa-PanelLayout {
    height: 100%;
    margin: 0;
    max-height: var(--aa-panel-max-height);
    overflow-y: hidden; /* Remove second scrollbar */
    overflow-x: hidden; /* Prevent horizontal scroll */
    padding: 0;
    position: relative;
    text-align: left;
}

/* Force full-width panel positioning - override inline styles */
.algolia-search-wrapper .aa-Panel,
#algolia-autocomplete .aa-Panel,
#algolia-autocomplete-mobile .aa-Panel {
    left: 0 !important;
    right: 0 !important;
    width: unset !important;
    max-width: unset !important;
}

/* Custom product item styling */
.aa-product-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* Combined image sizing for consistency */
.aa-product-image img,
.aa-trending-image img {
    width: 40px;
    height: 40px;
}

.aa-product-image img {
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.aa-product-content {
    flex: 1;
}

.aa-product-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #212529;
    /* 2-zeilige Darstellung wie in Cartzilla */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    max-height: calc(1.4em * 2); /* Fallback für ältere Browser */
}

.aa-product-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.aa-product-price {
    font-weight: 600;
    color: #198754;
}

.aa-product-description {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.aa-product-stock.in-stock {
    color: #198754;
    font-size: 0.75rem;
}

.aa-product-stock.out-of-stock {
    color: #dc3545;
    font-size: 0.75rem;
}

/* Source header styling */
.aa-source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    margin: 0 -1px; /* Prevent background cutoff */
    border-radius: 0.375rem 0.375rem 0 0; /* Round top corners */
}

/* First item after header needs special padding */
.aa-source-header + .aa-list .aa-item:first-child .aa-product-item,
.aa-source-header + .aa-list .aa-item:first-child .aa-trending-item {
    border-top: none;
    padding-top: 0.75rem;
}

/* Button styles moved to algolia-cartzilla-theme.css to avoid duplication */
/* See algolia-cartzilla-theme.css for gradient button styling */
.aa-Panel .aa-show-all-button,
.aa-Panel .aa-full-search-button {
    background: linear-gradient(to bottom, #FFC400, #FF7600);
    color: white;
    border: none;
    border-radius: 0.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(255, 118, 0, 0.3);
    opacity: 1;
    visibility: visible;
}

.aa-Panel .aa-show-all-button:hover,
.aa-Panel .aa-full-search-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 118, 0, 0.4);
    color: white;
}

.aa-no-results {
    padding: 1rem;
    text-align: center;
    color: #6c757d;
}

/* Trending items styling */
.aa-trending-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.aa-trending-image img {
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    border: 1px solid #e9ecef;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.aa-trending-content {
    flex: 1;
    min-width: 0; /* Prevent text overflow */
}

.aa-trending-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aa-trending-price {
    color: #198754;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.125rem;
}

.aa-trending-brand {
    color: #6c757d;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* InstantSearch Widget Styling */
.ais-SearchBox-form {
    position: relative;
}

.ais-SearchBox-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 35px;
    border: 2px solid #e9ecef;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.ais-SearchBox-input:focus {
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.ais-SearchBox-reset {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 1.2rem;
    color: #6c757d;
}

.ais-SearchBox-reset:hover {
    color: #dc3545;
}

/* Rating Menu Styling */
.ais-RatingMenu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ais-RatingMenu-item {
    margin-bottom: 0.5rem;
}

.ais-RatingMenu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: #495057;
    border-radius: 0.375rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.ais-RatingMenu-link:hover {
    background-color: #f8f9fa;
    color: #0d6efd;
    text-decoration: none;
}

.ais-RatingMenu-link--selected {
    background-color: #e7f1ff;
    color: #0d6efd;
    border-color: #b6d7ff;
}

.ais-RatingMenu-starIcon {
    color: #ffc107;
    font-size: 1.1rem;
}

.ais-RatingMenu-starIcon--full {
    color: #ffc107;
}

.ais-RatingMenu-starIcon--empty {
    color: #dee2e6;
}

.ais-RatingMenu-label {
    flex: 1;
    font-weight: 500;
}

.ais-RatingMenu-count {
    color: #6c757d;
    font-size: 0.875rem;
    background-color: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
}

.ais-RatingMenu-item--selected .ais-RatingMenu-count {
    background-color: #0d6efd;
    color: white;
}

/* SortBy Widget Styling */
.ais-SortBy-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.ais-SortBy-select:focus {
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Algolia Search Overlay Styles - Using official InstantSearch CSS classes */
.algolia-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    overflow-y: auto;
}

.algolia-search-overlay-content {
    position: relative;
    background: white;
    margin: 2rem auto;
    border-radius: 0.5rem;
    max-width: 1200px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.algolia-search-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    /* gap: 2rem; */
    padding: 2rem;
    min-height: 500px;
}

.algolia-close-search {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
    padding: 0;
    width: auto;
    height: auto;
}

.algolia-close-search:hover {
    color: #dc3545;
}

/* Algolia Search Integration Styles - Now merged locally */
.algolia-search-wrapper {
    min-width: 300px;
    max-width: 500px;
}

/* Algolia Product Hits Styling - JTL Card Layout */
.ais-Hits-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    padding: 0;
    list-style: none;
    margin: 0;
}

.hit-item {
    background: white;
    /* border entfernt, um doppelten Rahmen im Modal zu vermeiden */
    border-radius: 0.375rem;
    overflow: hidden;
    transition: all 0.15s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}
.hit-description {
    display: none;
}

.hit-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-color: #adb5bd;
}

.hit-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.hit-image {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
}

.hit-item:hover .hit-image {
    transform: scale(1.05);
}

/* Spezielle Behandlung für keinBild.gif */
.hit-image[src*="keinBild.gif"] {
    width: 80px;
    height: 80px;
    object-fit: contain;
    opacity: 0.4;
    transform: none;
}

.hit-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: center;
    text-align: center;
}

.hit-rating {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.25rem;
}

.hit-rating .star {
    color: #ffc107;
    font-size: 0.875rem;
}

.hit-name {
    font-size: 0.7rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: #212529;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0rem;
}

.hit-price-container {
    margin-bottom: 1rem;
    margin-top: auto;
}

.hit-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #198754;
    margin: 0;
}

.hit-old-price {
    font-size: 0.875rem;
    color: #6c757d;
    text-decoration: line-through;
    margin-left: 0.5rem;
}

.hit-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hit-quantity-controls {
    display: flex;
    align-items: center;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    overflow: hidden;
    flex: 1;
}

.hit-qty-btn {
    background: none;
    border: none;
    padding: 0.375rem 0.75rem;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}

.hit-qty-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.hit-qty-input {
    border: none;
    text-align: center;
    width: 50px;
    padding: 0.375rem 0.25rem;
    font-size: 0.875rem;
}

.hit-add-to-cart {
    background: #0d6efd;
    border: 1px solid #0d6efd;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.hit-add-to-cart:hover {
    background: #0b5ed7;
    border-color: #0a58ca;
    color: white;
    transform: translateY(-1px);
}

.hit-meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.hit-sku {
    font-weight: 500;
}

.hit-stock {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.hit-stock.in-stock {
    color: #198754;
}

.hit-stock.out-of-stock {
    color: #dc3545;
}

/* Highlight styling */
.ais-Highlight-highlighted {
    background: #fef3c7;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

.ais-Snippet-highlighted {
    background: #fef3c7;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

