/* ============================================================
   Smart Search for WordPress — Frontend Styles
   ============================================================ */

/* ── Wrapper ──────────────────────────────────────────────── */
.ss-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
}

/* ── Form ─────────────────────────────────────────────────── */
.ss-search-form {
    position: relative;
    width: 100%;
}

.ss-input-group {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 999px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ss-input-group:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.ss-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 18px;
    font-size: 15px;
    background: transparent;
    color: #333;
    min-width: 0;
}

.ss-input::placeholder {
    color: #aaa;
}

.ss-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #0073aa;
    color: #fff;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ss-submit:hover {
    background: #005a87;
}

/* ── Live results dropdown ────────────────────────────────── */
.ss-live-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 99999;
    max-height: 70vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.ss-live-results[hidden] {
    display: none;
}

/* ── Individual result item ───────────────────────────────── */
.ss-result-item {
    display: block;
    padding: 14px 18px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

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

.ss-result-item:hover,
.ss-result-item:focus {
    background: #f5f9ff;
    outline: none;
}

.ss-result-item:focus {
    box-shadow: inset 0 0 0 2px #0073aa;
}

.ss-result-title {
    font-weight: 600;
    font-size: 15px;
    color: #0073aa;
    margin: 0 0 4px;
    line-height: 1.3;
}

.ss-result-excerpt {
    font-size: 13px;
    color: #555;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ss-result-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* ── Highlight ────────────────────────────────────────────── */
mark.ss-highlight {
    background: #fff3cd;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Loading spinner ──────────────────────────────────────── */
.ss-loading {
    text-align: center;
    padding: 16px;
    color: #888;
    font-size: 14px;
}

.ss-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: ss-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes ss-spin {
    to { transform: rotate(360deg); }
}

/* ── No results ───────────────────────────────────────────── */
.ss-no-results {
    padding: 18px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ── "See all results" footer link ───────────────────────── */
.ss-see-all {
    display: block;
    text-align: center;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #0073aa;
    text-decoration: none;
    border-top: 1px solid #eee;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

.ss-see-all:hover {
    background: #f0f7ff;
    text-decoration: underline;
}

/* ── Parsed query notice ──────────────────────────────────── */
.ss-parsed-notice {
    font-size: 12px;
    color: #888;
    padding: 8px 18px 0;
    font-style: italic;
}

/* ── Powered by ───────────────────────────────────────────── */
.ss-powered-by {
    font-size: 10px;
    color: #ccc;
    text-align: right;
    margin-top: 4px;
    padding-right: 4px;
}

/* ── Search results page ──────────────────────────────────── */
.ss-search-results-header {
    margin-bottom: 24px;
}

.ss-search-results-header h2 {
    font-size: 20px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media ( max-width: 600px ) {
    .ss-search-wrapper {
        max-width: 100%;
    }

    .ss-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 10px 14px;
    }

    .ss-live-results {
        border-radius: 8px;
        max-height: 60vh;
    }
}

/* ── Elementor widget overrides ───────────────────────────── */

/* HFE widget wrapper needs relative positioning for dropdown */
.elementor-widget-hfe-search-button .elementor-widget-container,
.elementor-widget-wpr-search .elementor-widget-container {
    position: relative;
}

/* Dropdown when injected inside Elementor widget containers */
.elementor-widget-hfe-search-button .ss-live-results,
.elementor-widget-wpr-search .ss-live-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 320px;
    z-index: 999999;
}

/* Make HFE input match our style while keeping its icon */
.hfe-search-form__input:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px;
}
