/**
 * Healthium Treatment Search — Frontend Styles
 *
 * Consistent with Healthium Clinics' teal/white medical aesthetic.
 * Fully responsive — mobile-first approach.
 */

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
    --hts-teal:        #007a8b;
    --hts-teal-light:  #009aad;
    --hts-teal-dark:   #005f6b;
    --hts-teal-bg:     rgba(0, 122, 139, 0.08);
    --hts-teal-glow:   rgba(0, 122, 139, 0.25);
    --hts-white:       #ffffff;
    --hts-off-white:   #f7f9fa;
    --hts-grey-100:    #f0f3f5;
    --hts-grey-200:    #e2e7eb;
    --hts-grey-400:    #9ba6b0;
    --hts-grey-600:    #5a6872;
    --hts-grey-800:    #2d3640;
    --hts-grey-900:    #1a2129;
    --hts-shadow-sm:   0 2px 8px rgba(0,0,0,0.08);
    --hts-shadow-md:   0 8px 30px rgba(0,0,0,0.12);
    --hts-shadow-lg:   0 16px 60px rgba(0,0,0,0.18);
    --hts-radius:      12px;
    --hts-radius-sm:   8px;
    --hts-transition:  0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --hts-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Floating Trigger Button ───────────────────────────────────── */
.hts-floating-trigger {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 999998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--hts-teal), var(--hts-teal-dark));
    color: var(--hts-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 122, 139, 0.4);
    transition: all var(--hts-transition);
    -webkit-tap-highlight-color: transparent;
}

.hts-floating-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 122, 139, 0.55);
}

.hts-floating-trigger:active {
    transform: scale(0.96);
}

/* Hide floating trigger on desktop (>= 981px) since we use header icon */
@media (min-width: 981px) {
    .hts-floating-trigger {
        display: none;
    }
}

/* ── Header Search Icon (desktop) ──────────────────────────────── */
.hts-header-search-item {
    display: flex;
    align-items: center;
}

.hts-header-search-item .et_pb_module_inner,
.hts-header-search-item .dd-mi-w,
.hts-header-search-item .dd-mi {
    display: flex;
    align-items: center;
}

.hts-header-search-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: inherit;
    transition: color var(--hts-transition), opacity var(--hts-transition);
    opacity: 0.75;
}

.hts-header-search-btn:hover {
    color: var(--hts-teal);
    opacity: 1;
}

.hts-header-search-btn svg {
    flex-shrink: 0;
    display: block;
}

/* On tablet/mobile, hide the header icon (floating button is shown) */
@media (max-width: 980px) {
    .hts-header-search-item {
        display: none !important;
    }
}

/* ── Overlay ───────────────────────────────────────────────────── */
.hts-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    font-family: var(--hts-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Backdrop */
.hts-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 36, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: hts-fadeIn 0.3s ease forwards;
}

/* Container */
.hts-overlay__container {
    position: relative;
    z-index: 2;
    max-width: 680px;
    width: 92%;
    margin: 0 auto;
    margin-top: 8vh;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--hts-white);
    border-radius: var(--hts-radius);
    box-shadow: var(--hts-shadow-lg);
    overflow: hidden;
    animation: hts-slideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Close button */
.hts-overlay__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--hts-grey-100);
    color: var(--hts-grey-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--hts-transition);
}

.hts-overlay__close:hover {
    background: var(--hts-grey-200);
    color: var(--hts-grey-900);
}

/* Header */
.hts-overlay__header {
    padding: 32px 32px 0;
    flex-shrink: 0;
}

.hts-overlay__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--hts-grey-900);
    margin: 0 0 4px;
    line-height: 1.3;
}

.hts-overlay__subtitle {
    font-size: 14px;
    color: var(--hts-grey-400);
    margin: 0;
    line-height: 1.4;
}

/* ── Search Box ────────────────────────────────────────────────── */
.hts-search-box {
    position: relative;
    margin: 20px 32px 0;
    flex-shrink: 0;
}

.hts-search-box__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hts-grey-400);
    pointer-events: none;
    transition: color var(--hts-transition);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hts-search-box__input {
    width: 100% !important;
    padding: 14px 48px 14px 52px !important;
    font-size: 16px !important;
    font-family: var(--hts-font);
    color: var(--hts-grey-900);
    background: var(--hts-off-white) !important;
    border: 2px solid var(--hts-grey-200) !important;
    border-radius: var(--hts-radius-sm) !important;
    outline: none;
    transition: all var(--hts-transition);
    box-sizing: border-box !important;
    margin: 0 !important;
    text-indent: 0 !important;
}

.hts-search-box__input::placeholder {
    color: var(--hts-grey-400);
}

.hts-search-box__input:focus {
    border-color: var(--hts-teal);
    background: var(--hts-white);
    box-shadow: 0 0 0 4px var(--hts-teal-glow);
}

.hts-search-box__input:focus ~ .hts-search-box__icon {
    color: var(--hts-teal);
}

/* Spinner */
.hts-search-box__spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.hts-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--hts-grey-200);
    border-top-color: var(--hts-teal);
    border-radius: 50%;
    animation: hts-spin 0.7s linear infinite;
}

/* Clear button */
.hts-search-box__clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--hts-grey-200);
    color: var(--hts-grey-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--hts-transition);
}

.hts-search-box__clear:hover {
    background: var(--hts-grey-400);
    color: var(--hts-white);
}

/* ── Results ───────────────────────────────────────────────────── */
.hts-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px 32px 24px;
    overscroll-behavior: contain;
}

/* Custom scrollbar */
.hts-results::-webkit-scrollbar {
    width: 6px;
}
.hts-results::-webkit-scrollbar-track {
    background: transparent;
}
.hts-results::-webkit-scrollbar-thumb {
    background: var(--hts-grey-200);
    border-radius: 3px;
}
.hts-results::-webkit-scrollbar-thumb:hover {
    background: var(--hts-grey-400);
}

/* Initial / empty state */
.hts-results__initial {
    text-align: center;
    padding: 40px 20px;
    color: var(--hts-grey-400);
    animation: hts-fadeIn 0.4s ease;
}

.hts-results__initial-icon {
    margin-bottom: 12px;
    opacity: 0.3;
}

.hts-results__initial p {
    font-size: 15px;
    margin: 0;
}

/* No results */
.hts-results__empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--hts-grey-600);
    animation: hts-fadeIn 0.3s ease;
}

.hts-results__empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.hts-results__empty p {
    margin: 0 0 4px;
    font-size: 15px;
}

.hts-results__empty p:last-child {
    color: var(--hts-grey-400);
    font-size: 13px;
}

/* Category Group */
.hts-group {
    margin-bottom: 20px;
    animation: hts-fadeUp 0.35s ease forwards;
    opacity: 0;
}

.hts-group:nth-child(1) { animation-delay: 0s; }
.hts-group:nth-child(2) { animation-delay: 0.05s; }
.hts-group:nth-child(3) { animation-delay: 0.1s; }
.hts-group:nth-child(4) { animation-delay: 0.15s; }
.hts-group:nth-child(5) { animation-delay: 0.2s; }

.hts-group__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hts-grey-100);
}

.hts-group__badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--hts-teal-dark);
    background: var(--hts-teal-bg);
    border-radius: 20px;
    white-space: nowrap;
}

.hts-group__count {
    font-size: 12px;
    color: var(--hts-grey-400);
}

/* Result Item */
.hts-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--hts-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: all var(--hts-transition);
    cursor: pointer;
    position: relative;
}

.hts-item:hover,
.hts-item.hts-item--active {
    background: var(--hts-off-white);
    transform: translateX(4px);
}

.hts-item:active {
    background: var(--hts-grey-100);
}

/* Thumbnail */
.hts-item__thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--hts-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--hts-grey-100);
}

.hts-item__thumb-placeholder {
    width: 52px;
    height: 52px;
    border-radius: var(--hts-radius-sm);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--hts-teal-bg), var(--hts-grey-100));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hts-teal);
    opacity: 0.6;
}

.hts-item__body {
    flex: 1;
    min-width: 0;
}

.hts-item__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--hts-grey-900);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hts-item__excerpt {
    font-size: 13px;
    color: var(--hts-grey-400);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hts-item__arrow {
    flex-shrink: 0;
    color: var(--hts-grey-200);
    transition: all var(--hts-transition);
}

.hts-item:hover .hts-item__arrow,
.hts-item.hts-item--active .hts-item__arrow {
    color: var(--hts-teal);
    transform: translateX(3px);
}

/* Results total */
.hts-results__total {
    text-align: center;
    font-size: 12px;
    color: var(--hts-grey-400);
    padding: 12px 0 0;
    border-top: 1px solid var(--hts-grey-100);
    margin-top: 8px;
}

/* ── Highlight matched text ────────────────────────────────────── */
.hts-highlight {
    background: rgba(0, 122, 139, 0.15);
    color: var(--hts-teal-dark);
    border-radius: 2px;
    padding: 0 2px;
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes hts-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes hts-slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes hts-fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ── Overlay close animation ───────────────────────────────────── */
.hts-overlay--closing .hts-overlay__backdrop {
    animation: hts-fadeOut 0.2s ease forwards;
}

.hts-overlay--closing .hts-overlay__container {
    animation: hts-slideUp 0.2s ease forwards;
}

@keyframes hts-fadeOut {
    to { opacity: 0; }
}

@keyframes hts-slideUp {
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.97);
    }
}

/* ── Body scroll lock ──────────────────────────────────────────── */
body.hts-body-locked {
    overflow: hidden !important;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 980px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
    .hts-overlay__container {
        width: 95%;
        margin-top: 5vh;
        max-height: 88vh;
    }

    .hts-overlay__header {
        padding: 28px 24px 0;
    }

    .hts-overlay__title {
        font-size: 20px;
    }

    .hts-search-box {
        margin: 16px 24px 0;
    }

    .hts-results {
        padding: 14px 24px 20px;
    }

    .hts-item {
        padding: 10px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 600px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .hts-overlay__container {
        width: 100%;
        margin-top: 0;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        animation: hts-slideFromBottom 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .hts-overlay--closing .hts-overlay__container {
        animation: hts-slideToBottom 0.25s ease forwards;
    }

    .hts-overlay__header {
        padding: 20px 20px 0;
    }

    .hts-overlay__title {
        font-size: 18px;
    }

    .hts-overlay__subtitle {
        font-size: 13px;
    }

    .hts-overlay__close {
        top: 14px;
        right: 14px;
        width: 32px;
        height: 32px;
    }

    .hts-search-box {
        margin: 14px 20px 0;
    }

    .hts-search-box__input {
        font-size: 16px; /* prevents iOS zoom */
        padding: 12px 44px 12px 44px;
    }

    .hts-results {
        padding: 12px 20px 24px;
    }

    .hts-item {
        gap: 10px;
        padding: 10px;
    }

    .hts-item__thumb,
    .hts-item__thumb-placeholder {
        width: 42px;
        height: 42px;
    }

    .hts-item__title {
        font-size: 14px;
    }

    .hts-item__excerpt {
        font-size: 12px;
        -webkit-line-clamp: 1;
    }

    .hts-item__arrow {
        display: none;
    }

    .hts-group__badge {
        font-size: 10px;
        padding: 3px 10px;
    }

    .hts-floating-trigger {
        width: 50px;
        height: 50px;
        bottom: 90px;
        right: 18px;
    }

    .hts-floating-trigger svg {
        width: 20px;
        height: 20px;
    }

    .hts-results__initial {
        padding: 28px 16px;
    }

    .hts-results__initial-icon svg {
        width: 36px;
        height: 36px;
    }
}

/* ── Mobile slide animations ───────────────────────────────────── */
@keyframes hts-slideFromBottom {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes hts-slideToBottom {
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Very small (≤ 380px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    .hts-overlay__header {
        padding: 16px 16px 0;
    }

    .hts-overlay__title {
        font-size: 16px;
    }

    .hts-search-box {
        margin: 12px 16px 0;
    }

    .hts-results {
        padding: 10px 16px 20px;
    }

    .hts-item__thumb,
    .hts-item__thumb-placeholder {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }
}
