/* ========================================= */
/* --- PASEK WYSZUKIWANIA --- */
/* ========================================= */
.ai-search-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 40px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    box-sizing: border-box;
}

.ai-search-wrapper .ai-search-box {
    display: flex !important;
    align-items: center !important;
    background: #ffffff !important;
    border-radius: 50px !important;
    padding: 6px 8px 6px 24px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.3s ease !important;
    border: none !important;
    position: relative !important;
}

.ai-search-wrapper .ai-search-box:focus-within {
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15), 0 0 0 2px #6366f1 !important;
}

.ai-search-wrapper .ai-search-input-container {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    gap: 12px !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    flex: 1 1 auto !important;
}

.ai-sparkle-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.ai-search-wrapper .ai-search-input {
    flex-grow: 1 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 1.05rem !important;
    color: #1f2937 !important;
    background: transparent !important;
    padding: 12px 36px 12px 0 !important; /* Prawy padding zapobiega nakładaniu się tekstu na X */
    margin: 0 !important;
    min-width: 0 !important;
    text-overflow: ellipsis !important;
}

/* Stylizowanie placeholdera */
.ai-search-wrapper .ai-search-input::placeholder {
    color: #9ca3af;
    opacity: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

/* Przycisk wyczyszczenia tekstu (X) */
.ai-search-wrapper .ai-search-clear {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    border: none !important;
    font-size: 20px !important;
    line-height: 1 !important;
    color: #9ca3af !important;
    cursor: pointer !important;
    padding: 4px 8px !important;
    border-radius: 50% !important;
    transition: color 0.2s, background-color 0.2s !important;
    z-index: 5 !important;
    display: none;
}

.ai-search-wrapper .ai-search-clear:hover {
    color: #1f2937 !important;
    background-color: #f3f4f6 !important;
}

.ai-search-wrapper .ai-search-submit {
    background: #6366f1 !important;
    border: none !important;
    border-radius: 50px !important;
    width: 46px !important;
    height: 46px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background 0.2s, transform 0.1s !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative !important;
    z-index: 6 !important;
}

.ai-search-wrapper .ai-search-submit:hover {
    background: #4f46e5 !important;
    transform: scale(1.03) !important;
}

.ai-search-wrapper .ai-search-submit svg {
    width: 20px !important;
    height: 20px !important;
    stroke: #ffffff !important;
    fill: none !important;
    display: block !important;
    margin: 0 !important;
}

/* ========================================= */
/* --- MODAL (SZTYWNE POZYCJONOWANIE RWD) --- */
/* ========================================= */
.ai-search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.ai-search-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.ai-search-modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 1050px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    border-radius: 24px;
    padding: 32px;
    position: relative;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    box-sizing: border-box;
}

.ai-search-modal-overlay.active .ai-search-modal-content {
    transform: translateY(0) scale(1);
}

.ai-search-modal-close {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    background: #f3f4f6 !important;
    border: none !important;
    border-radius: 50% !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 22px !important;
    color: #4b5563 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    z-index: 10;
}

.ai-search-modal-close:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

/* ========================================= */
/* --- SIATKA PRODUKTÓW --- */
/* ========================================= */
.ai-search-status {
    font-size: 1.1rem;
    color: #1f2937;
    margin-bottom: 20px;
}

.ai-search-results {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 18px !important;
    margin-bottom: 30px !important;
}

.ai-secondary-title {
    grid-column: 1 / -1;
    margin-top: 15px;
    margin-bottom: 2px;
    font-size: 1.1rem;
    color: #4b5563;
    font-weight: 600;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 10px;
}

.ai-product-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    text-decoration: none !important;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.ai-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.08);
}

.ai-product-image {
    width: 100%;
    height: 145px;
    object-fit: cover;
    background: #f9fafb;
}

.ai-product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.ai-product-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px 0;
    line-height: 1.35;
}

.ai-product-price {
    font-weight: 700;
    color: #4f46e5;
    margin-top: auto;
    font-size: 0.9rem;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 7px;
}

/* Cena regularna przy promocji – przekreślona, przygaszona */
.ai-product-price .ai-price-regular {
    color: #9ca3af;
    font-weight: 500;
    font-size: 0.8rem;
    text-decoration: line-through;
}

/* Cena aktualna / promocyjna – bez domyślnego podkreślenia <ins> */
.ai-product-price .ai-price-current {
    color: #4f46e5;
    text-decoration: none;
}

/* ========================================= */
/* --- KAFELKI NARZĘDZI (CROSS-PROMO) --- */
/* ========================================= */
.ai-search-cross-promo {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid #f3f4f6;
}

.ai-search-cross-promo h4 {
    font-size: 0.98rem;
    color: #4b5563;
    margin: 0 0 16px 0;
    font-weight: 500;
}

.ai-promo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.ai-promo-card {
    display: flex;
    flex-direction: column;
    padding: 18px;
    border-radius: 16px;
    text-decoration: none !important;
    transition: all 0.25s ease;
    box-sizing: border-box;
    position: relative;
}

.promo-generator {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
}
.promo-generator .ai-promo-badge { background: #ede9fe; color: #6d28d9; }
.promo-generator .ai-promo-title { color: #4c1d95; }
.promo-generator .ai-promo-action { color: #6d28d9; }
.promo-generator:hover {
    border-color: #c4b5fd;
    box-shadow: 0 10px 20px rgba(109, 40, 217, 0.1);
    transform: translateY(-3px);
}

.promo-gry {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.promo-gry .ai-promo-badge { background: #d1fae5; color: #047857; }
.promo-gry .ai-promo-title { color: #064e3b; }
.promo-gry .ai-promo-action { color: #047857; }
.promo-gry:hover {
    border-color: #6ee7b7;
    box-shadow: 0 10px 20px rgba(4, 120, 87, 0.1);
    transform: translateY(-3px);
}

.promo-odgloski {
    background: #fff7ed;
    border: 1px solid #fed7aa;
}
.promo-odgloski .ai-promo-badge { background: #ffedd5; color: #c2410c; }
.promo-odgloski .ai-promo-title { color: #7c2d12; }
.promo-odgloski .ai-promo-action { color: #c2410c; }
.promo-odgloski:hover {
    border-color: #fdba74;
    box-shadow: 0 10px 20px rgba(194, 65, 12, 0.1);
    transform: translateY(-3px);
}

.ai-promo-badge {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.ai-promo-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}

.ai-promo-desc {
    font-size: 0.83rem;
    color: #64748b;
    line-height: 1.4;
    margin-bottom: 14px;
}

.ai-promo-action {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: auto;
}

/* ========================================= */
/* --- MEDIA QUERIES (RESPONSYWNOŚĆ MOBILNA) --- */
/* ========================================= */
@media (max-width: 992px) {
    .ai-search-results {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .ai-promo-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (max-width: 768px) {
    .ai-search-wrapper .ai-search-box {
        padding: 4px 6px 4px 14px !important;
    }
    .ai-search-wrapper .ai-search-input-container {
        gap: 8px !important;
    }
    .ai-search-wrapper .ai-search-input {
        font-size: 0.9rem !important;
        padding: 8px 32px 8px 0 !important;
    }
    .ai-search-wrapper .ai-search-submit {
        width: 38px !important;
        height: 38px !important;
    }
    .ai-search-wrapper .ai-search-submit svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Wyłączenie flexboxa dla overlay na mobilkach na rzecz absolute position */
    .ai-search-modal-overlay {
        padding: 0;
        display: none;
    }

    .ai-search-modal-overlay.active {
        display: block;
    }

    /* Modal przyklejony na sztywno z odstępem od krawędzi ekranu */
    .ai-search-modal-content {
        position: absolute !important;
        top: 12px !important;
        bottom: 12px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        padding: 20px 14px 14px 14px;
        border-radius: 16px;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    .ai-search-status {
        font-size: 0.98rem;
        padding-right: 36px;
    }
    
    .ai-search-modal-close {
        top: 12px !important;
        right: 12px !important;
        width: 32px !important;
        height: 32px !important;
        font-size: 18px !important;
    }
    
    .ai-search-results {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    .ai-product-image {
        height: 125px;
    }
}

@media (max-width: 480px) {
    .ai-search-wrapper .ai-search-box {
        padding: 3px 5px 3px 12px !important;
    }
    .ai-search-wrapper .ai-search-input {
        font-size: 0.85rem !important;
    }
    .ai-sparkle-icon {
        font-size: 1.1rem;
    }
    .ai-product-title {
        font-size: 0.82rem;
    }
}