/**
 * 2007-2017 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author PrestaShop SA <contact@prestashop.com>
 *  @copyright  2007-2017 PrestaShop SA
 *  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */

/* Moderne Suchmodul-Stile */
/* Such-Wrapper - Standard PrestaShop Overlay-Priorität */
.search-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    z-index: 1050 !important; /* Kompatibel mit Megamenü und Theme */
    max-width: 363px; /* 10% wider than 330px */
    margin: 0;
}

/* Such-Icon Rotationsanimation */
@keyframes search-icon-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-btn.rotating .search-icon {
    animation: search-icon-rotate 1s linear infinite;
}

.search-container {
    position: relative;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-form {
    display: flex;
    align-items: center;
    padding: 8px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    font-size: 14px;
    border:1px solid #83d0f5;
    border-radius: 4px 0 0 4px;
    outline: none;
    transition: border-color 0.2s;
    height: 42px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.search-input:focus {
    border-color: #009FE3;
    box-shadow: 0 0 0 0.2rem rgba(0, 159, 227, 0.25);
}

.search-btn {
    background-color: #009FE3;
    color: #fff;
    border: none;
    padding: 0 20px;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    transition: background-color 0.2s;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    position: relative;
}

/* SVG Such-Icon Styling */
.search-icon {
    color: #fff;
    fill: none;
    stroke: currentColor;
}

.search-btn:hover,
.search-btn:focus {
    background-color: #0088cc;
    outline: 2px solid #0088cc;
    outline-offset: 2px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-top: none;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 8px;
    display: none !important;
    z-index: 1046 !important;
    width: 100%;
    box-sizing: border-box;
    pointer-events: auto;
}

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

.result-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    color: inherit;
    position: relative;
    z-index: 1045 !important;
}

.result-item:hover {
    background-color: #f5f5f5;
}

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

.result-image {
    width: 50px;
    height: 50px;
    margin-right: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 1044 !important;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.result-info {
    flex: 1;
    position: relative;
    z-index: 1044 !important;
}

.result-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
    position: relative;
    z-index: 1043 !important;
}

.result-price {
    color: #e74c3c;
    font-weight: bold;
    position: relative;
    z-index: 1043 !important;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* Such-Eingabe Container */
.search-input-container {
    position: relative;
    display: flex;
    flex: 1;
}

/* Nur für Screenreader */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* Schreibmaschinen-Effekt */
.search-input.typewriter {
    position: relative;
}

.search-input.typewriter::after {
    content: '|';
    color: #009FE3;
    font-weight: bold;
    animation: blink 1s infinite;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes delete {
    from { width: 100%; }
    to { width: 0; }
}

/* Responsives Design */
@media (max-width: 768px) {
    .search-wrapper {
        right: 10px;
        left: 10px;
        max-width: none;
        width: calc(100% - 20px); /* Better mobile width calculation */
    }
    
    .search-results {
        width: 100%;
        left: 0;
        right: 0;
    }
}

/* Legacy-Kompatibilität - altes Such-Widget ausblenden */
#search_widget,
.search-widget .search_button,
.search-widget .search_toggle,
#header .search-widget,
#header .search_button,
#header .search_toggle {
    display: none !important;
}

/* Suchmodul z-index Werte - kompatibel mit Megamenü (z-index: 10000) */

/* Moderate z-index Werte für Such-Elemente die nicht mit Navigation interferieren */
.search-wrapper {
    z-index: 1050 !important;
    position: relative;
}

.search-container {
    z-index: 1049 !important;
    position: relative;
}

.search-form {
    z-index: 1048 !important;
    position: relative;
}

.search-input {
    z-index: 1047 !important;
    position: relative;
}

.search-btn {
    z-index: 1047 !important;
    position: relative;
}

.search-results {
    z-index: 1046 !important;
    position: absolute;
}

.search-result-item {
    z-index: 1045 !important;
    position: relative;
}

/* Sicherstellen, dass Megamenü seine normale Priorität behält */
.mm_menus_ul {
    z-index: auto;
}

/* Zusätzliche Regeln für Header-Kontext */
#header .search-wrapper,
.header .search-wrapper,
body .search-wrapper {
    z-index: 1050 !important;
    position: relative !important;
}

#header .search-results,
.header .search-results,
body .search-results {
    z-index: 1046 !important;
    position: absolute !important;
}

/* Megamenü normale Funktionalität wiederherstellen */
.ets_mm_megamenu .mm_menus_ul,
#ets_mm_megamenu .mm_menus_ul,
body .ets_mm_megamenu .mm_menus_ul {
    z-index: auto;
}

/* Suchergebnisse mit moderater Priorität anzeigen */
.search-results.show,
.search-results.active {
    z-index: 1046 !important;
    position: absolute !important;
    display: block !important;
}

/* Close Button Styling */
.search-close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
    gap: 6px;
    position: sticky;
    bottom: 0;
    z-index: 1047 !important;
}

.search-close-button:hover,
.search-close-button:focus {
    background-color: #e9ecef;
    color: #495057;
    outline: 2px solid #009FE3;
    outline-offset: -2px;
}

.search-close-button .close-icon {
    color: inherit;
    stroke: currentColor;
    flex-shrink: 0;
}

.search-close-button span {
    user-select: none;
}

/* Hide close button when search results are empty */
.search-results:empty .search-close-button,
.search-results .search-close-button:only-child {
    display: none !important;
}

/* Ensure close button appears only when results are active */
.search-results:not(.active) .search-close-button,
.search-close-button {
    display: none !important;
}

/* Show close button only when search results are active */
.search-results.active .search-close-button {
    display: flex !important;
}