/* ==========================================================================
   Custom Product Search Styles (Refined v8 - Layout Shift Fix)
   ========================================================================== */

/* Container */
.custom-search-container {
    position: relative; /* Needed for original positioning of results */
    max-width: 800px; /* Width of the input area */
    width: 100%; /* Allow shrinking */
    margin: 0; /* Align left by default, adjust in Elementor if needed */
    padding: 0;
}

/* Form Wrapper */
.custom-search-form {
    display: flex !important;
    align-items: center !important;
    width: 100%;
    border: none; /* No border on form */
    border-radius: 5px;
    background-color: rgb(226 230 240); /* Background on form */
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    height: 48px; /* Height */
}
/* Focus Outline */
.custom-search-form:focus-within {
     border-color: transparent;
     box-shadow: none;
     outline: 2px solid #d7dce2; /* Outline color */
     outline-offset: 1px;
}


/* Icon Wrapper */
.custom-search-icon-wrapper {
    padding-left: 15px;
    padding-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #42454c; /* Icon color */
    flex-shrink: 0;
    height: 48px;
    box-sizing: border-box;
    border-radius: 5px 0 0 5px;
    background-color: rgb(226 230 240); /* Match form background */
}
.custom-search-icon-wrapper svg {
    display: block;
    width: 18px;
    height: 18px;
}
/* Style the new SVG icon parts */
.custom-search-icon-wrapper svg circle,
.custom-search-icon-wrapper svg line {
    stroke: currentColor; /* Use the color set on the wrapper */
    stroke-linecap: round; /* Ensure line ends are rounded */
}


/* Input field styling */
#custom-search-input {
    flex-grow: 1 !important;
    border: none !important;
    padding: 10px 15px 10px 0 !important;
    font-size: 1em !important;
    outline: none !important;
    box-shadow: none !important;
    background-color: rgb(226 230 240) !important; /* Match form background */
    color: #222b38 !important;
    min-width: 0;
    height: 48px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border-radius: 0 5px 5px 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    line-height: normal !important;
    vertical-align: middle;
}
/* Placeholder Styling */
#custom-search-input::placeholder { color: #42454c !important; opacity: 1 !important; }
#custom-search-input::-moz-placeholder { color: #42454c !important; opacity: 1 !important; }
#custom-search-input:-ms-input-placeholder { color: #42454c !important; }
#custom-search-input::-ms-input-placeholder { color: #42454c !important; }

/* Hide browser's default search cancel button */
#custom-search-input::-webkit-search-cancel-button,
#custom-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}


/* Results Dropdown Container - Positioned by JS when moved to body */
#custom-search-results {
    /* position: absolute !important; <<< REMOVED - Handled by JS */
    /* top: calc(100% + 10px) !important; <<< REMOVED - Handled by JS */
    /* left: 0 !important; <<< REMOVED - Handled by JS */
    /* transform: none !important; <<< REMOVED */
    width: 800px !important; /* Set the desired DESKTOP width */
    max-width: calc(100vw - 20px) !important; /* Prevent overflow */
    background-color: #ffffff !important;
    border: 1px solid #d7dce2 !important;
    border-radius: 5px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15) !important;
    z-index: 1001 !important; /* Above header and overlay */
    box-sizing: border-box !important;
    display: none; /* Default state is hidden */
    flex-direction: column !important;
    max-height: 450px !important; /* Or adjust as needed */
    overflow: hidden; /* Container itself hides overflow, scrollable area handles scroll */
}

/* Scrollable Area */
.search-results-scrollable {
    flex-grow: 1;
    overflow-y: auto; /* Allow vertical scrolling ONLY within this area */
    padding: 15px 15px 15px 43px; /* Left padding of 43px to align with input text */
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* Momentum scrolling on iOS */
}

/* "Søketips" Container */
.search-tips-container {
    padding: 20px 20px 20px 43px; /* Left padding of 43px to align with input text */
    text-align: left; /* Left aligned text */
    color: #5a616a;
}
.search-tips-container h4 {
    font-size: 1.1em;
    color: #222b38;
    margin-top: 0;
    margin-bottom: 10px;
}
.search-tips-container p {
    margin: 0;
    font-size: 0.95em;
}


/* Columns within Scrollable Area */
.search-results-columns {
    display: flex;
    gap: 25px;
}

/* --- Rest of the styles for columns, items, footer remain the same --- */
.search-results-column { flex: 1; min-width: 0; }

/* Adjust product/category column ratio (60/40 split) */
.search-results-products { flex: 0.6; }
.search-results-categories { flex: 0.4; }

.search-results-column h4 { font-size: 0.85em; font-weight: 600; color: #5a616a; margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #ebeef2; padding-bottom: 8px; }
.search-results-column ul { list-style: none; margin: 0; padding: 0; }
.search-results-column li a { display: flex; align-items: center; padding: 8px 5px; text-decoration: none; color: #222b38; border-radius: 3px; transition: background-color 0.2s ease; gap: 12px; }
.search-results-column li a:hover, .search-results-column li a:focus { background-color: #f4f5f6; color: #222b38; outline: none; }
.search-results-products li img { width: 45px; height: 45px; object-fit: contain; flex-shrink: 0; background-color: #ffffff; border: 1px solid #ebeef2; border-radius: 3px; }
.search-results-products li .result-text-content { display: flex; flex-direction: column; min-width: 0; }
.search-results-products li .result-title { font-size: 0.9em; font-weight: 500; line-height: 1.3; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results-products li .result-sku { font-size: 0.8em; color: #7f8286; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results-categories li a { font-size: 0.9em; font-weight: 400; padding: 10px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-no-results, .no-col-results { padding: 15px; text-align: center; color: #7f8286; font-style: italic; font-size: 0.9em; }
.no-col-results { padding: 10px 5px; text-align: left; }

/* Fixed Footer */
.search-results-footer { border-top: 1px solid #d7dce2; padding: 12px 15px; text-align: center; background-color: #f8f9fa; flex-shrink: 0; box-sizing: border-box; }
.search-results-footer a { font-size: 0.9em; color: #222b38; text-decoration: none; font-weight: 500; display: block; transition: color 0.2s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results-footer a:hover { color: #0056b3; text-decoration: none; }


/* Responsive Adjustments */
@media (max-width: 820px) { /* Adjust breakpoint slightly wider than results width */
    #custom-search-results {
        /* Make dropdown take more screen width on mobile */
        max-width: 95vw !important;
        /* Center dropdown relative to viewport when on body */
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 90vw !important; /* Adjust width */
    }
    
    /* Prevent iOS zoom on input focus by setting font-size to at least 16px */
    #custom-search-input {
        font-size: 16px !important;
    }
}
@media (max-width: 768px) { /* Stacking columns */
    .search-results-scrollable { padding: 5px; } /* Reduce padding */
    .search-results-columns { flex-direction: column; gap: 10px; }
    .search-results-column { padding-bottom: 10px; border-bottom: 1px solid #ebeef2; }
    .search-results-column:last-child { padding-bottom: 0; border-bottom: none; }
    /* Adjust padding for tips/results on mobile */
    .search-results-scrollable,
    .search-tips-container {
        padding-left: 15px; /* Reduce left padding */
        padding-right: 15px;
    }
    .search-results-footer { padding: 10px 15px; }
}

/* Screen reader text */
.screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; }

/* Search Overlay */
#search-results-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    z-index: 999; /* Lower z-index than header and results */
    display: none; /* Hidden by default */
    touch-action: none; /* Prevent scroll bleed-through on touch */
}

/* Ensure header stays above overlay */
.elementor-location-header {
    position: relative; /* Or sticky/fixed depending on your header */
    z-index: 1000; /* Higher than overlay, lower than results */
}

/* --- REMOVED body.search-results-open styles --- */