/**
 * Sanang Typesense Search - frontend live search widget.
 */

.sts-search {
    position: relative;
    width: 100%;
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    box-sizing: border-box;
}
.sts-search *,
.sts-search *::before,
.sts-search *::after {
    box-sizing: border-box;
}

.sts-search-form {
    margin: 0;
}

.sts-search-combobox {
    position: relative;
    width: 100%;
}

.sts-search .sts-search-input {
    width: 100%;
    height: 56px;
    border: 1px solid #EAEAEA !important;
    background: #FFFFFF;
    border-radius: 4px;
    padding: 16px 40px 16px 16px;
    outline: none;
    box-shadow: none;
    color: #1d2327;
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sts-search .sts-search-input:focus,
.sts-search .sts-search-input:focus-visible {
    border: 1px solid #EAEAEA !important;
    box-shadow: none;
    outline: none;
}
.sts-search .sts-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* Decorative search icon: shown only while the input is EMPTY. Not clickable
   (pointer-events: none) — it's a visual affordance, the placeholder handles
   the rest. It swaps with the clear (X) button once the user types. */
.sts-search .sts-search-icon {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    width: 25px;
    height: 25px;
    max-width: none;
    object-fit: contain;
    display: block;
    pointer-events: none;
}
.sts-search .sts-search-icon[hidden] {
    display: none;
}

/* Standard-search submit button: used when live suggestions are disabled or
   unavailable. It retains the live widget's appearance while remaining a real,
   keyboard-accessible form control. */
.sts-search .sts-search-submit {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none !important;
    border-radius: 0;
    appearance: none;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
    line-height: 0;
}
.sts-search .sts-search-submit:hover,
.sts-search .sts-search-submit:focus,
.sts-search .sts-search-submit:active {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}
.sts-search .sts-search-submit:focus-visible {
    outline: 2px solid #1B2A6B;
    outline-offset: 2px;
}
.sts-search .sts-search-submit-icon {
    display: block;
    width: 25px;
    height: 25px;
    max-width: none;
    object-fit: contain;
}

/* Clear (X) button: shown only while the input has text. */
.sts-search .sts-search-clear {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    width: 25px;
    height: 25px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none !important;
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sts-search .sts-search-clear[hidden] {
    display: none;
}
.sts-search .sts-search-clear:hover,
.sts-search .sts-search-clear:focus,
.sts-search .sts-search-clear:active {
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none;
}
.sts-search .sts-search-clear-icon {
    display: block;
    width: 25px;
    height: 25px;
    max-width: none;
    object-fit: contain;
}

/* Panel (desktop dropdown) */
.sts-search-panel {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: none;
    border-radius: 4px 4px 10px 10px;
    box-shadow: 0px 8px 15px 0px rgba(0, 0, 0, 0.10);
    z-index: 9999;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sts-search-results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sts-search-result {
    padding: 10px 16px;
    cursor: pointer;
    color: #1d2327;
    border: none;
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0;
    vertical-align: middle;
}
.sts-search-result:last-child {
    border-bottom: none;
}
.sts-search-result.is-active,
.sts-search-result:hover {
    background: #f5f5f5;
}
.sts-search-result .sts-result-title mark {
    background: transparent;
    color: inherit;
    font-weight: 700;
    padding: 0;
}

.sts-search-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 16px;
    line-height: 24px;
    color: #646970;
}

/* Loading spinner */
.sts-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #1B2A6B;
    border-radius: 50%;
    animation: sts-spin 0.7s linear infinite;
    flex: 0 0 auto;
}
@keyframes sts-spin {
    to { transform: rotate(360deg); }
}

/* Loading skeleton rows */
.sts-search-skeleton {
    padding: 10px 16px;
    list-style: none;
}
.sts-skeleton-bar {
    display: block;
    height: 16px;
    width: 60%;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: sts-shimmer 1.2s ease-in-out infinite;
}
.sts-search-skeleton:nth-child(2) .sts-skeleton-bar { width: 75%; }
.sts-search-skeleton:nth-child(3) .sts-skeleton-bar { width: 50%; }
@keyframes sts-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .sts-spinner { animation-duration: 1.6s; }
    .sts-skeleton-bar { animation: none; }
}

/* Mobile search input sizing (phones) */
@media (max-width: 767px) {
    .sts-search-panel {
        top: calc(100% + 1px);
        left: 0;
        right: 0;
        width: auto;
        border-radius: 8px;
        box-shadow: 0px 8px 15px 0px #0000001A;
        max-height: 70vh;
        max-height: 70dvh;
    }
    .sts-search-result {
        padding: 11px 8px;
        font-size: 14px;
        line-height: 18px;
        border-bottom: 1px solid #EAEAEA;
    }
    .sts-search-status {
        font-size: 14px;
        line-height: 20px;
    }
    .sts-search .sts-search-input {
        height: 32px;
        padding: 6px 28px 6px 8px !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        line-height: 20px !important;
    }
    .sts-search .sts-search-icon {
        width: 16px;
        height: 16px;
        right: 8px;
    }
    .sts-search .sts-search-submit {
        width: 16px;
        height: 16px;
        right: 8px;
    }
    .sts-search .sts-search-submit-icon {
        width: 16px;
        height: 16px;
    }
    .sts-search .sts-search-clear {
        width: 16px;
        height: 16px;
        right: 8px;
    }
    .sts-search .sts-search-clear-icon {
        width: 16px;
        height: 16px;
    }
}
