/* ======================================
   ENHANCED GLASSMORPHISM SEARCH RESULTS
   Kompatibel mit Header Design - Verstärkter Glassy Look
====================================== */

/* KRITISCH: Search Container Fixes für backdrop-filter */
.search-container {
    position: relative;
    z-index: 1000;
    isolation: isolate; /* Erstellt eigenen stacking context */
}

.search-input-wrapper {
    position: relative;
    z-index: 1001;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    /* KRITISCH: Background muss semi-transparent sein für backdrop-filter */
    background: rgba(0, 0, 0, 0.4); /* Fallback für ältere Browser */
    background: var(--store-glass, rgba(0, 0, 0, 0.4));
    backdrop-filter: blur(120px) saturate(1.2); /* Verstärkter Blur mit Saturation */
    -webkit-backdrop-filter: blur(120px) saturate(1.2);
    border: 1px solid var(--store-glass-border);
    border-radius: 20px;
    margin-top: 5px;
    box-shadow: 
        0 8px 32px var(--store-shadow),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    z-index: 9999; /* ERHÖHT: Sehr hoher z-index für backdrop-filter */
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* KRITISCH: Stellt sicher dass backdrop-filter funktioniert */
    isolation: isolate;
    contain: layout style paint;
}

.search-results.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.search-results-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Sehr subtile Border */
    background: rgba(255, 255, 255, 0.03); /* Sehr subtle Background */
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(40px); /* Zusätzlicher Blur für Header */
    -webkit-backdrop-filter: blur(40px);
    border-radius: 20px 20px 0 0;
}

.search-results-count {
    color: rgba(255, 255, 255, 0.6); /* Verwaschen wie im Header */
    font-size: 0.9rem;
    font-weight: 500;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03); /* Sehr subtile Border */
    outline: none;
    backdrop-filter: blur(20px); /* Blur für jedes Item */
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

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

/* Enhanced Hover Effect mit Glassmorphism */
.search-result-item:hover,
.search-result-item.active,
.search-result-item:focus {
    background: rgba(255, 255, 255, 0.08); /* Stärkere Transparenz beim Hover */
    border-left: 3px solid var(--store-primary);
    backdrop-filter: blur(60px); /* Verstärkter Blur beim Hover */
    -webkit-backdrop-filter: blur(60px);
    transform: translateX(2px); /* Subtle Movement */
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset; /* Glassmorphism Glow */
}

/* Glassmorphic Shine Effect */
.search-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: all 0.6s ease;
    z-index: 1;
}

.search-result-item:hover::before {
    left: 100%;
}

.search-result-item[aria-selected="true"] {
    background: rgba(104, 190, 124, 0.1);
    backdrop-filter: blur(80px);
    -webkit-backdrop-filter: blur(80px);
}

.search-result-image {
    width: 50px;
    height: 50px;
    border-radius: 12px; /* Größere Border-Radius */
    overflow: hidden;
    margin-right: 1rem;
    flex-shrink: 0;
    background: var(--store-glass); /* Glassmorphism Background */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle Border */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-result-item:hover .search-result-image img {
    transform: scale(1.05); /* Zoom Effect on Hover */
}

.search-result-content {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 2;
}

.search-result-name {
    color: rgba(255, 255, 255, 0.9); /* Leicht transparent */
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
    line-height: 1.3;
    transition: color 0.3s ease;
}

.search-result-item:hover .search-result-name {
    color: rgba(255, 255, 255, 1); /* Volle Opacity beim Hover */
}

.search-result-name mark {
    background: var(--store-primary);
    color: var(--store-dark);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.3); /* Glowy Effekt */
}

.search-result-category {
    color: rgba(255, 255, 255, 0.5); /* Sehr transparent */
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
    transition: color 0.3s ease;
}

.search-result-item:hover .search-result-category {
    color: rgba(255, 255, 255, 0.7); /* Heller beim Hover */
}

.search-result-price {
    color: var(--store-primary);
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3); /* Glowy Effekt */
    transition: all 0.3s ease;
}

.search-result-item:hover .search-result-price {
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.5); /* Verstärkter Glow */
    transform: scale(1.02);
}

.search-result-stock {
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.search-result-stock.in-stock {
    color: var(--store-success);
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.2);
}

.search-result-stock.low-stock {
    color: var(--store-warning);
    text-shadow: 0 0 5px rgba(255, 165, 0, 0.2);
}

.search-result-stock.out-of-stock {
    color: var(--store-error);
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.2);
}

.search-result-actions {
    margin-left: 1rem;
    position: relative;
    z-index: 2;
}

.search-add-to-cart {
    background: var(--store-primary);
    color: var(--store-dark);
    border: none;
    border-radius: 10px; /* Größere Border-Radius */
    width: 38px;
    height: 38px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 
        0 2px 8px rgba(0, 255, 136, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset; /* Glassmorphism Shadow */
    position: relative;
    overflow: hidden;
}

/* Glassmorphic Button Shine Effect */
.search-add-to-cart::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: transform 0.6s ease;
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
}

.search-add-to-cart:hover::before {
    transform: translateX(0) translateY(0) rotate(45deg);
}

.search-add-to-cart:hover {
    background: var(--store-secondary);
    transform: scale(1.08) translateY(-1px);
    box-shadow: 
        0 4px 16px rgba(0, 255, 136, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.search-add-to-cart:focus {
    outline: 2px solid var(--store-primary);
    outline-offset: 2px;
}

.search-add-to-cart:disabled {
    background: var(--store-text-muted);
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
    backdrop-filter: blur(10px);
}

.search-results-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04); /* Sehr subtile Border */
    background: rgba(255, 255, 255, 0.02); /* Noch subtiler */
    position: sticky;
    bottom: 0;
    backdrop-filter: blur(80px); /* Verstärkter Blur */
    -webkit-backdrop-filter: blur(80px);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) inset; /* Inner Shadow */
}

.search-view-all {
    width: 100%;
    background: rgba(255, 255, 255, 0.03); /* Glassmorphism Background */
    color: var(--store-primary);
    border: 1px solid rgba(0, 255, 136, 0.3); /* Transparente Border */
    border-radius: 12px; /* Größere Border-Radius */
    padding: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.search-view-all::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.1), transparent);
    transition: left 0.6s ease;
}

.search-view-all:hover,
.search-view-all:focus {
    background: var(--store-primary);
    color: var(--store-dark);
    border-color: var(--store-primary);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 16px rgba(0, 255, 136, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.search-view-all:hover::before {
    left: 100%;
}

.search-loading,
.search-no-results,
.search-error {
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6); /* Verwaschen */
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
}

.search-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--store-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results-icon,
.search-error-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--store-primary);
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.no-results-suggestions {
    text-align: left;
    margin-top: 1rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.no-results-suggestions ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.no-results-suggestions li {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.3s ease;
}

.no-results-suggestions li:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* ======================================
   LIGHT MODE GLASSMORPHISM ANPASSUNGEN
====================================== */
body.light-mode .search-results {
    background: rgba(255, 255, 255, 0.6); /* ERHÖHT: Mehr Transparenz für besseren Blur */
    background: var(--store-glass, rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05) inset;
    backdrop-filter: blur(120px) saturate(1.2) brightness(1.1);
    -webkit-backdrop-filter: blur(120px) saturate(1.2) brightness(1.1);
}

body.light-mode .search-results-header {
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .search-results-count {
    color: rgba(0, 0, 0, 0.6);
}

body.light-mode .search-result-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

body.light-mode .search-result-item:hover,
body.light-mode .search-result-item.active,
body.light-mode .search-result-item:focus {
    background: rgba(0, 0, 0, 0.05);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.1) inset;
}

body.light-mode .search-result-item::before {
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

body.light-mode .search-result-image {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .search-result-name {
    color: rgba(0, 0, 0, 0.8);
}

body.light-mode .search-result-item:hover .search-result-name {
    color: rgba(0, 0, 0, 1);
}

body.light-mode .search-result-category {
    color: rgba(0, 0, 0, 0.5);
}

body.light-mode .search-result-item:hover .search-result-category {
    color: rgba(0, 0, 0, 0.7);
}

body.light-mode .search-add-to-cart {
    box-shadow: 
        0 2px 8px rgba(0, 255, 136, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

body.light-mode .search-add-to-cart:hover {
    box-shadow: 
        0 4px 16px rgba(0, 255, 136, 0.4),
        0 0 0 1px rgba(0, 0, 0, 0.1) inset;
}

body.light-mode .search-results-footer {
    background: rgba(0, 0, 0, 0.01);
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

body.light-mode .search-view-all {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 255, 136, 0.3);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.03) inset;
}

body.light-mode .search-view-all:hover {
    box-shadow: 
        0 4px 16px rgba(0, 255, 136, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

body.light-mode .search-loading,
body.light-mode .search-no-results,
body.light-mode .search-error {
    color: rgba(0, 0, 0, 0.6);
}

body.light-mode .no-results-suggestions {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-mode .no-results-suggestions li {
    color: rgba(0, 0, 0, 0.7);
}

body.light-mode .no-results-suggestions li:hover {
    color: rgba(0, 0, 0, 0.9);
}

/* ======================================
   MOBILE SPECIFIC GLASSMORPHISM
====================================== */
@media (max-width: 768px) {
    .search-results {
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        margin-top: 10px;
        backdrop-filter: blur(100px); /* Etwas weniger Blur auf Mobile */
        -webkit-backdrop-filter: blur(100px);
    }
    
    .search-result-item {
        padding: 0.8rem;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
    
    .search-result-image {
        width: 42px;
        height: 42px;
        margin-right: 0.8rem;
        border-radius: 10px;
    }
    
    .search-result-name {
        font-size: 0.9rem;
    }
    
    .search-add-to-cart {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }
}

/* ======================================
   ENHANCED SCROLLBAR - GLASSMORPHISM
====================================== */
.search-results::-webkit-scrollbar {
    width: 10px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 5px;
    margin: 5px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

/* Light mode scrollbar */
body.light-mode .search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

body.light-mode .search-results::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-mode .search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

/* ======================================
   HIGH CONTRAST MODE SUPPORT
====================================== */
@media (prefers-contrast: high) {
    .search-result-item:hover,
    .search-result-item.active {
        background: #000000;
        color: #ffffff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    
    .search-result-name mark {
        background: #ffff00;
        color: #000000;
        box-shadow: none;
    }
    
    .search-results {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(0, 0, 0, 0.95);
    }
}

/* ======================================
   REDUCED MOTION SUPPORT
====================================== */
@media (prefers-reduced-motion: reduce) {
    .search-result-item,
    .search-add-to-cart,
    .search-view-all {
        transition: none;
    }
    
    .search-result-item::before,
    .search-add-to-cart::before,
    .search-view-all::before {
        display: none;
    }
    
    .search-loading-spinner {
        animation: none;
        border: 3px solid var(--store-primary);
    }
    
    .search-results {
        transition: opacity 0.1s ease;
    }
}

/* ======================================
   PERFORMANCE OPTIMIZATIONS
====================================== */
.search-results,
.search-result-item,
.search-add-to-cart,
.search-view-all {
    will-change: transform, opacity, backdrop-filter;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ======================================
   DEBUGGING & BROWSER SUPPORT
====================================== */

/* Fallback für Browser ohne backdrop-filter Support */
@supports not (backdrop-filter: blur(1px)) {
    .search-results {
        background: rgba(0, 0, 0, 0.85) !important;
    }
    
    body.light-mode .search-results {
        background: rgba(255, 255, 255, 0.95) !important;
    }
}

/* Force backdrop-filter on specific elements that might interfere */
.search-results * {
    isolation: auto; /* Reset isolation für child elements */
}

/* Ensure proper stacking context for header */
#header {
    z-index: 999; /* Niedriger als search results */
}

/* DEBUGGING: Temporäre Test-Klasse - entfernen nach dem Testen */
.search-results.debug-blur {
    background: rgba(255, 0, 0, 0.3) !important; /* Rote transparente Background */
    backdrop-filter: blur(50px) !important;
    -webkit-backdrop-filter: blur(50px) !important;
}

/* ======================================
   PRINT STYLES
====================================== */
@media print {
    .search-results {
        display: none !important;
    }
}