/**
 * SAP Search Styles v2.0
 * Grouped dropdown: Authors + Content sections.
 * All selectors namespaced to .sap-* — zero theme conflict.
 *
 * Brand color: #652D90 (SAP purple, sampled from site)
 */

/* ── Brand tokens (scoped to wrapper to avoid theme conflicts)── */
.sap-search-wrap,
.sap-search-dropdown {
    --sap-purple:      #652D90;
    --sap-purple-dark: #4e2070;
    --sap-purple-tint: #f3eaf9;
    --sap-purple-pale: #e8d5f5;
}

/* ── Wrapper ─────────────────────────────────────────────────── */
.sap-search-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
}

/* ── Form row ────────────────────────────────────────────────── */
.sap-search-form {
    display: flex;
    align-items: stretch;
    width: 100%;
}

/* ── Input ───────────────────────────────────────────────────── */
.sap-search-wrap .sap-search-form .sap-search-input,
.sap-search-wrap .sap-search-form .sap-search-input:not([type="submit"]) {
    flex: 1;
    padding: 10px 14px !important;
    font-size: 15px !important;
    line-height: 1.4 !important;
    border: 2px solid #d0d0d0 !important;
    border-right: none !important;
    border-radius: 4px 0 0 4px !important;
    outline: none !important;
    background: #fff !important;
    color: #222 !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease;
    -webkit-appearance: none;
    min-width: 0;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
}

.sap-search-wrap .sap-search-form .sap-search-input:focus {
    border-color: var(--sap-purple) !important;
    border-right: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* ── Submit button (rendered as div to avoid theme resets) ───── */
.sap-search-wrap .sap-search-btn {
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    border: 2px solid var(--sap-purple);
    border-radius: 0 4px 4px 0;
    background: var(--sap-purple);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    user-select: none;
}

.sap-search-wrap .sap-search-btn:hover,
.sap-search-wrap .sap-search-btn:focus {
    background: var(--sap-purple-dark);
    border-color: var(--sap-purple-dark);
    color: #fff;
    outline: 2px solid var(--sap-purple-dark);
    outline-offset: 2px;
}

/* ── Dropdown container ──────────────────────────────────────── */
.sap-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    max-height: 520px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.sap-search-dropdown[hidden] {
    display: none;
}

/* ── Result list (reset) ─────────────────────────────────────── */
.sap-result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Group header ────────────────────────────────────────────── */
.sap-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
    pointer-events: none;
    user-select: none;
}

/* Add a top border on groups after the first */
.sap-group-header + .sap-group-header,
.sap-view-all + .sap-group-header {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 14px;
}

.sap-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #888;
}

.sap-group-count {
    font-size: 11px;
    color: #aaa;
    background: #f4f4f4;
    border-radius: 10px;
    padding: 1px 7px;
}

/* ── Result item (shared) ────────────────────────────────────── */
.sap-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.1s ease;
    outline: none;
}

.sap-result-item:hover,
.sap-result-item:focus,
.sap-result-item.is-active {
    background: var(--sap-purple-tint);
}

/* ── Avatar / thumbnail ──────────────────────────────────────── */
.sap-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sap-item-thumb {
    border-radius: 4px; /* square-ish for post thumbnails */
}

.sap-avatar-placeholder {
    display: inline-block;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sap-purple-pale), var(--sap-purple-tint));
    flex-shrink: 0;
}

.sap-thumb-placeholder {
    display: inline-block;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: linear-gradient(135deg, #e8e8e8, #d0d0d0);
    flex-shrink: 0;
}

/* ── Item body text ──────────────────────────────────────────── */
.sap-item-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.sap-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sap-item-title mark {
    background: #fff3b0;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.sap-item-meta {
    font-size: 12px;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sap-item-date {
    font-weight: 500;
    color: #999;
}

/* ── Badge (post type label) ─────────────────────────────────── */
.sap-item-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sap-purple);
    background: var(--sap-purple-pale);
    border-radius: 3px;
    padding: 2px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.sap-badge-post {
    color: #555;
    background: #f0f0f0;
}

/* ── View all footer link ────────────────────────────────────── */
.sap-view-all {
    display: block;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sap-purple);
    cursor: pointer;
    text-align: right;
    transition: background 0.1s ease;
    outline: none;
    border-top: 1px solid #f2f2f2;
}

.sap-view-all:hover,
.sap-view-all:focus,
.sap-view-all.is-active {
    background: var(--sap-purple-tint);
}

/* ── No results ──────────────────────────────────────────────── */
.sap-no-results {
    padding: 16px 14px;
    font-size: 14px;
    color: #777;
    text-align: center;
}

.sap-no-results strong { color: #222; }

/* ── Responsive ──────────────────────────────────────────────── */
@media ( max-width: 600px ) {
    .sap-search-wrap    { max-width: 100%; }
    .sap-search-input   { font-size: 16px; } /* prevent iOS zoom */
    .sap-search-dropdown { max-height: 380px; }
}
