/* 1. SEARCH BAR CONTAINER (Transparent Pill) */
.wd-search-form {
    position: relative !important;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px !important;
    /* Force Pill Shape */
    box-shadow: none !important;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 5px;
    /* Minimal padding */
    height: 52px;
    margin: 0 auto;
    max-width: 800px;
    /* Widened from 650px */
    z-index: 20;
    /* High z-index for bar itself */
}

/* FIX: Inner Form must be flex/grow too */
.wd-search-form form.searchform {
    display: flex !important;
    align-items: center !important;
    flex: 1 !important;
    min-width: 0 !important;
    /* Critical for shrink */
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    height: 100% !important;
    border: none !important;
}

/* SPOTLIGHT ELEVATION MODE (Active Input) */
.wd-search-form.pc-spotlight-active {
    position: relative !important;
    z-index: 100001 !important;
    /* Above Backdrop (99990) & Spotlight (100000) */
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2) !important;
    /* Highlight Ring */
    background: #fff !important;
    /* Context Opaque */
    border-color: transparent !important;
}

.wd-search-form.pc-spotlight-active input[type="text"] {
    color: #333 !important;
    /* Dark text on white bg */
}

.wd-search-form.pc-spotlight-active .pc-vision-trigger svg,
.wd-search-form.pc-spotlight-active .pc-mic-trigger svg,
.wd-search-form.pc-spotlight-active button[type="submit"] {
    color: #333 !important;
    /* Dark icons */
}

/* Darker Divider for Light Background */
.wd-search-form.pc-spotlight-active .pc-mic-trigger::before {
    background: rgba(0, 0, 0, 0.15);
}

/* Input Text */
.wd-search-form input[type="text"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding-left: 20px !important;
    padding-right: 5px !important;
    /* No more icon overlap! */
    /* Space for icons (Reduced since no loop) */
    height: 100% !important;
    font-size: 15px !important;
    color: #fff !important;
    font-weight: 500 !important;
    /* width: auto !important; - REMOVING PER USER FEEDBACK as it breaks mobile layout */
    /* Flexbox friendly */
    flex: 1;
    min-width: 0;
    /* CRITICAL: Allows input to shrink below default size on mobile */
    /* Take available space */
    border-radius: 30px !important;
    position: relative;
    z-index: 10;
    /* Text firmly ABOVE placeholder */
}

/* Force Icons Visible on Mobile */
@media (max-width: 768px) {

    .pc-vision-trigger,
    .pc-mic-trigger {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-shrink: 0 !important;
    }
}

/* GRADIENT PLACEHOLDER OVERLAY (Backdrop) */
.pc-placeholder-overlay {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    font-size: 15px;
    /* Unused but kept */
    pointer-events: all;
    /* Blocks interaction below */
    z-index: 99990;
    /* High Z-index */

    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);

    /* Display Control */
    display: block;
    /* Always in DOM, controlled by opacity/visibility for transition */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* HEADER ELEVATION (Spotlight Active) */
/* Lifts the entire header out of the Stacking Context Trap */
.pc-header-elevated {
    position: relative !important;
    z-index: 100002 !important;
    /* ABOVE Backdrop (99990) & Spotlight (100000) - Actually Spotlight is also 100k+? Wait Spotlight is 100000. Header should be slightly below Spotlight or above? 
       Spotlight (100000) covers Page.
       Header (100002) covers Spotlight? NO.
       Spotlight Panel needs to be ABOVE Header if possible. 
       Actually, Search Bar is IN header. 
       If Header is 100002, Search Bar is 100002.
       Spotlight is 100000.
       Header covers Spotlight top edge?
       Spotlight starts at Header Bottom. So they don't overlap.
       So Header 100002 is FINE.
    */
    background: #fff !important;
    /* Ensure Header is opaque against backdrop */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* HIDE NATIVE RESULTS if conflicting */
.wd-search-results-wrapper {
    display: none !important;
}

.wd-search-form input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

/* HIDE NATIVE & THEME CLEAR BUTTONS (X) - Aggressive Mode */
.wd-search-form input[type="text"]::-webkit-search-decoration,
.wd-search-form input[type="text"]::-webkit-search-cancel-button,
.wd-search-form input[type="text"]::-webkit-search-results-button,
.wd-search-form input[type="text"]::-webkit-search-results-decoration,
.wd-search-form .search-clear-action,
.wd-search-form .wd-cross,
.wd-search-form .reset-search-btn,
.wd-search-form .wd-clear-search,
.wd-search-form .close-search-result {
    display: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    z-index: -1 !important;
}

/* HIDE SEARCH SUBMIT BUTTON (Magnifying Glass) */
.wd-search-form button[type="submit"] {
    display: none !important;
}

/* AI Summary Section */
.pc-ai-summary {
    background: #fbfbfb;
    padding: 18px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    /* Align top for long text */
}

/* ... Thinking Dots ... */

.pc-ai-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    line-height: 1.5;
    /* FIX TRUNCATION */
    flex: 1;
    /* Take remaining space */
    min-width: 0;
    /* Flexbox text overflow fix */
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Modern wrapping */
    white-space: normal;
    /* Force wrapping */
}


/* 3. SUBMIT BUTTON (Icon Only) */
.wd-search-form button[type="submit"] {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.8) !important;
    right: 15px !important;
    font-size: 0 !important;
    /* Hide text */
    width: 20px;
    height: 100%;
    opacity: 0.9;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wd-search-form button[type="submit"]::before {
    content: '\f002';
    /* FontAwesome Search */
    font-family: "fontawesome";
    font-size: 18px;
    position: absolute;
}

.wd-search-form button[type="submit"]:hover {
    color: #E30E11 !important;
}


/* 4. TRIGGER ICONS (Mic, Cam) - FLEXBOX LAYOUT */
.pc-vision-trigger,
.pc-mic-trigger {
    position: relative !important;
    top: auto;
    transform: none;
    right: auto;
    width: auto;
    /* Let padding define width */
    height: 20px;
    min-width: 20px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    z-index: 20;
    flex-shrink: 0;
    /* Don't shrink */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Specific Margins/Order */
.pc-mic-trigger {
    margin-left: 12px;
    /* Gap from Vision to Divider */
    padding-left: 12px;
    /* Gap from Divider to Mic */
    padding-right: 5px;
    position: relative;
}

/* SEPARATOR LINE (Centered Vertically & Horizontally) */
.pc-mic-trigger::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 16px;
    /* Shorter than full height */
    background: rgba(255, 255, 255, 0.3);
}

.pc-vision-trigger {
    margin-left: 8px;
}

.pc-vision-trigger svg,
.pc-mic-trigger svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5;
    /* Minimalist Thin */
    width: 20px;
    /* Force SVG size */
    height: 20px;
}

@media (max-width: 768px) {
    .wd-search-form.wd-header-search-form-mobile {
        max-width: 65vw !important;
        /* Balanced Width: Fits text better than 58vw, fits screen better than calc() */
        width: 100% !important;
        flex: 1;
        min-width: 0;
        margin-right: 5px !important;
    }
}

.pc-vision-trigger:hover svg,
.pc-mic-trigger:hover svg {
    /* Scale ONLY the icon, not the border/container */
    transform: scale(1.15);
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.pc-vision-trigger:hover,
.pc-mic-trigger:hover {
    color: #fff;
    /* Removed transform from here to stop border moving */
}

/* Tooltip/Shadows on Hover (Text Shadow for Icon) */
/* .pc-vision-trigger:hover { text-shadow... } - Removed to avoid artifacts */

.pc-mic-active {
    color: #E30E11 !important;
    animation: pc-pulse 1s infinite;
}


/* 5. DROPDOWN RESULTS (SPLIT LAYOUT - MEGA PANEL) */
/* 5. SPOTLIGHT RESULTS (Global/Modal) */
.pc-ai-search-results {
    position: fixed;
    /* Always Fixed */
    /* Top is set by JS (Header Bottom), Left/Right/Margin by JS (0/Auto) */
    z-index: 100000;
    /* Above Backdrop (9999) */

    /* Mega Focus Width */
    width: 800px !important;
    min-width: 0 !important;
    max-width: 96vw !important;
    /* Safety cap */

    height: auto;
    max-height: 80vh;
    /* Limit height */

    background: #fff;
    /* Fallback */
    background: rgba(255, 255, 255, 0.95);
    /* Glass-like opaque */
    backdrop-filter: blur(12px);

    border-radius: 20px;
    /* Deep Shadow for Float Effect */
    box-shadow:
        0 30px 60px -10px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05);

    border: none;
    overflow: hidden;
    /* Hide outer scroll */
    margin-top: 15px;
    /* Visual Gap from Header */

    /* Animation State */
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.pc-ai-search-results.wd-opened {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: pcSpotlightEnter 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes pcSpotlightEnter {
    from {
        opacity: 0;
        transform: translateY(-15px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Flex Container */
.pc-ai-content {
    display: flex;
    max-height: 550px;
    align-items: stretch;
}

/* LEFT COLUMN: AI SUMMARY */
.pc-ai-summary {
    width: 260px;
    /* Fixed Width Sidebar */
    flex-shrink: 0;
    background: #f8f9fa;
    /* Sidebar Gray */
    border-right: 1px solid #eee;
    border-bottom: none;

    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
    /* Horizontal alignment: left */
    justify-content: center;
    /* Vertical alignment: center */
    overflow-y: auto;
    /* Allow independent scroll if text is long */
}

/* RIGHT COLUMN: PRODUCTS GRID */
.pc-ai-products {
    flex: 1;
    /* Take remaining space */
    padding: 25px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    overflow-y: auto;
    /* Main scroll area */
    align-content: start;
    background: #fff;
}


/* --- RESTORED ANIMATIONS (Dots & Icons) --- */
.pc-ai-thinking-dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-left: 5px;
}

.pc-ai-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0E22E3, #E30E11);
    animation: pcDotBounce 1.4s infinite ease-in-out both;
}

.pc-ai-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.pc-ai-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes pcDotBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.pc-ai-bot-icon {
    width: 28px;
    height: 28px;
    color: #555;
    flex-shrink: 0;
}

.pc-ai-text {
    font-size: 14px;
    color: #333;
    font-weight: 400;
    line-height: 1.6;
}

/* New Formatting Styles */
.pc-ai-text b {
    font-weight: 600;
    color: #000;
}

.pc-ai-text br {
    display: block;
    /* Ensure breaks create real space */
    content: "";
    /* Clean fix */
    margin-bottom: 8px;
    /* Add spacing between thoughts */
}

/* Mobile: Bulletproof Fixed Layout */
@media (max-width: 768px) {

    /* 1. Force Overlay Hide on Focus & Content */
    .wd-search-form:focus-within .pc-placeholder-overlay,
    .wd-search-form.pc-has-content .pc-placeholder-overlay {
        opacity: 0 !important;
        visibility: hidden !important;
        transition: none !important;
    }

    /* 2. Bar adjustments */
    /* 2. Bar adjustments */
    .wd-search-form {
        border-radius: 30px !important;
        height: 48px;
        /* margin-right & width handled by main mobile query above */
    }

    .wd-search-form input[type="text"] {
        font-size: 14px !important;
        /* Readable size */
        padding-left: 15px !important;
        padding-right: 5px !important;
        /* Low padding as confirmed */
        border-radius: 30px !important;
    }

    /* FORCE DARK TEXT ON MOBILE WHEN ACTIVE (Fix Analyzing message) */
    .wd-search-form.pc-spotlight-active input[type="text"],
    .wd-search-form.pc-spotlight-active input[type="text"]:disabled {
        color: #333 !important;
        opacity: 1 !important;
        /* Override browser disabled fade */
        -webkit-text-fill-color: #333 !important;
        /* iOS Safari Fix */
    }

    /* 3. Dropdown: FIXED POSITION (Centered Floating Modal) */
    .pc-ai-search-results {
        position: fixed !important;
        /* Top calculated by JS */
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        /* True Centering */
        bottom: auto !important;

        transform: translateY(-10px) !important;
        /* Base state for animation */

        width: 95vw !important;
        min-width: 0 !important;
        max-width: 600px !important;

        height: auto;
        max-height: 80vh;

        margin-top: 10px;
        border-radius: 20px !important;
        box-shadow: 0 10px 100px rgba(0, 0, 0, 0.4);
        z-index: 100000 !important;

        overflow-y: auto;
    }

    .pc-ai-content {
        flex-direction: column;
        min-height: 100%;
    }

    .pc-ai-summary {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #f0f0f0;
        padding: 20px;
        background: #fdfdfd;
        flex-shrink: 0;
    }

    /* Animation Unified */
    .pc-ai-search-results.wd-opened {
        transform: translateY(0) !important;
        animation: pcSpotlightEnter 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    }

    .pc-ai-search-results::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }

    .pc-ai-text {
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    /* FIX: Mobile Overflow & Grid */
    .pc-ai-products {
        grid-template-columns: 1fr;
        /* Stack products vertically */
        padding: 15px;
        /* Reduce padding */
        gap: 10px;
    }

    .pc-ai-item {
        padding: 10px;
        /* Compact item padding */
        background: #f9f9f9;
        /* Subtle card background for better separation */
        border: 1px solid #eee;
    }
}


/* Custom Scrollbar (Sidebar & Main separately) */
.pc-ai-summary::-webkit-scrollbar,
.pc-ai-products::-webkit-scrollbar {
    width: 5px;
}

/* ... */

.pc-ai-search-results.wd-opened {
    display: block;
    animation: pcSlideDownDesktop 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes pcSlideDownDesktop {
    from {
        opacity: 0;
        transform: translate(0, -15px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

@keyframes pcSlideDownMobile {
    from {
        opacity: 0;
        transform: translate(-50%, -15px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.pc-ai-item {
    display: flex;
    gap: 15px;
    padding: 12px;
    text-decoration: none !important;
    border-radius: 12px;
    transition: all 0.2s ease;
    align-items: center;
    color: inherit;
    border: 1px solid transparent;
}

.pc-ai-item:hover {
    background: #f4f4f4;
    /* Light Hover */
    transform: translateX(3px);
}

.pc-ai-img {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #eee;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pc-ai-img img {
    max-width: 100%;
    max-height: 100%;
    mix-blend-mode: multiply;
}

.pc-ai-title {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
    line-height: 1.3;
}

.pc-ai-price {
    font-weight: 700;
    color: #333;
    font-size: 13px;
}

.pc-ai-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pc-ai-score {
    font-size: 10px;
    background: #f0f9eb;
    color: #75b325;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
}


/* 8. LOADING & ERROR STATES */
.pc-ai-loading {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #888;
    font-size: 14px;
}

.pc-ai-error {
    padding: 30px;
    text-align: center;
    color: #d32f2f;
    font-size: 13px;
}

.pc-icon-spin {
    display: inline-block;
    animation: pc-spin 1s linear infinite;
}

@keyframes pc-spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes pc-pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}


/* Drag & Drop State */
/* Drag & Drop State (Red Alert Style) */
.wd-search-form.pc-drag-active {
    position: relative;
    box-shadow: 0 0 0 4px rgba(217, 44, 44, 0.3) !important;
    /* Red Glow */
    border-color: #d92c2c !important;
    background: #fff !important;
}

.wd-search-form.pc-drag-active::after {
    content: 'Upuść zdjęcie tutaj...';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 600;
    font-size: 16px;
    color: #fff;
    /* White Text */

    z-index: 100;
    pointer-events: none;

    background-color: rgba(217, 44, 44, 0.95);
    /* Red Background */
    backdrop-filter: blur(4px);
    border-radius: 30px;

    /* Icon via Mask or Background Image? Background Image is easier for colors provided SVG is colored */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='2' y='5' width='20' height='14' rx='2.5' ry='2.5'%3E%3C/rect%3E%3Ccircle cx='12' cy='12' r='3.5'%3E%3C/circle%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 24px;
    background-position: calc(50% - 100px) center;
    /* Position icon to left of text */
    padding-left: 30px;
    /* Offset text to balance */
}

/* Hide inner elements */
.wd-search-form.pc-drag-active * {
    opacity: 0.1;
}

/* 9. SKELETON LOADING (SHIMMER) */
.pc-skeleton-card {
    height: 80px;
    background: #f0f0f0;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.pc-skeleton-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            hsla(0, 0%, 100%, 0.5) 50%,
            transparent 100%);
    animation: pcShimmer 1.5s infinite;
}

@keyframes pcShimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}