/**
 * Autotech Search — premium iOS-style bottom sheet
 */

.at-search-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.42);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 10090;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.at-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.at-search-container {
    width: 100%;
    height: auto;
    max-height: min(78vh, 640px);
    background: #f2f2f7;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.16);
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.28s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Idle (popular chips only) — hug content, no tall empty sheet */
.at-search-container.is-idle {
    max-height: none;
}

/* Searching / results — allow growth, scroll inside body */
.at-search-container.has-results,
.at-search-container.is-loading {
    max-height: min(78vh, 640px);
}

.at-search-overlay.active .at-search-container {
    transform: translateY(0);
}

.at-search-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 6px;
    flex-shrink: 0;
}

.at-search-sheet-handle span {
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: #c7c7cc;
}

.at-search-header {
    width: 100%;
    margin: 0 auto;
    padding: 4px 18px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    background: #f2f2f7;
    flex-shrink: 0;
}

.at-search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 14px;
    padding: 0 14px 0 16px;
    min-height: 52px;
    border: 1px solid rgba(60, 60, 67, 0.1);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.at-search-input-wrapper:focus-within {
    border-color: rgba(60, 60, 67, 0.18);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 0 0 4px color-mix(in srgb, var(--secondary-color, #e41f27) 12%, transparent);
}

.at-search-icon {
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.at-search-icon svg {
    width: 20px;
    height: 20px;
}

.at-search-input {
    width: 100%;
    height: 52px;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    color: #1c1c1e;
    outline: none;
    padding: 0;
    box-sizing: border-box;
    letter-spacing: -0.01em;
}

.at-search-input::placeholder {
    color: #8e8e93;
    font-weight: 500;
}

.at-search-clear {
    border: none;
    background: rgba(120, 120, 128, 0.18);
    color: #636366;
    cursor: pointer;
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.at-search-clear svg {
    width: 12px;
    height: 12px;
}

.at-search-loader {
    margin-left: 8px;
    display: flex;
    align-items: center;
}

.at-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid color-mix(in srgb, var(--secondary-color, #e41f27) 18%, transparent);
    border-top-color: var(--secondary-color, #e41f27);
    border-radius: 50%;
    animation: at-spin 0.6s linear infinite;
}

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

.at-search-close {
    border: none;
    background: rgba(120, 120, 128, 0.14);
    color: #1c1c1e;
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.at-search-close:hover,
.at-search-close:active {
    background: rgba(120, 120, 128, 0.22);
}

.at-search-close svg {
    width: 16px;
    height: 16px;
}

.at-search-body {
    width: 100%;
    margin: 0 auto;
    padding: 2px 18px 22px;
    overflow-y: auto;
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.at-search-container.has-results .at-search-body,
.at-search-container.is-loading .at-search-body {
    max-height: min(58vh, 480px);
    overflow-y: auto;
}

.at-search-suggestions {
    animation: at-fadeInUp 0.35s ease;
}

.at-search-section-title {
    font-size: 13px;
    letter-spacing: -0.01em;
    color: #8e8e93;
    font-weight: 650;
    margin: 10px 0 12px;
    text-transform: none;
}

.at-search-popular-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.at-popular-item {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid rgba(60, 60, 67, 0.1);
    border-radius: 999px;
    color: #1c1c1e;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -0.01em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.at-popular-item:hover,
.at-popular-item:active {
    background: var(--secondary-color, #e41f27);
    border-color: var(--secondary-color, #e41f27);
    color: #fff;
}

.at-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    animation: at-fadeInUp 0.28s ease;
}

.at-search-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(60, 60, 67, 0.08);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.at-search-item:active {
    transform: scale(0.985);
}

.at-search-item:focus {
    outline: 2px solid var(--secondary-color, #e41f27);
    outline-offset: 2px;
}

.at-search-image {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: contain;
    background: #f8f8fa;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(60, 60, 67, 0.06);
}

.at-search-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.at-search-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.at-search-name {
    font-size: 14px;
    font-weight: 650;
    color: #1c1c1e;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.at-search-model-cat {
    font-size: 12px;
    color: #8e8e93;
    font-weight: 500;
}

.at-search-pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.at-search-price {
    font-size: 14px;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -0.02em;
}

.at-search-mrp {
    font-size: 11px;
    text-decoration: line-through;
    color: #8e8e93;
}

.at-search-empty {
    text-align: center;
    padding: 28px 16px 18px;
    animation: at-fadeIn 0.3s ease;
}

.at-search-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.85;
    color: #8e8e93;
    display: flex;
    justify-content: center;
}

.at-search-empty-title {
    font-size: 17px;
    font-weight: 700;
    color: #1c1c1e;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.at-search-empty-text {
    font-size: 13px;
    color: #8e8e93;
}

.at-search-skeletons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.at-search-skeleton-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(60, 60, 67, 0.08);
    background: #fff;
    box-sizing: border-box;
}

.at-skeleton-image {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    margin-right: 12px;
    background: #ebebf0;
    flex-shrink: 0;
}

.at-skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.at-skeleton-title {
    width: 55%;
    height: 14px;
    background: #ebebf0;
    border-radius: 6px;
}

.at-skeleton-subtitle {
    width: 35%;
    height: 11px;
    background: #ebebf0;
    border-radius: 6px;
}

.at-skeleton-price {
    width: 22%;
    height: 12px;
    background: #ebebf0;
    border-radius: 6px;
}

.at-shimmer {
    background: linear-gradient(90deg, #ebebf0 25%, #f5f5f7 50%, #ebebf0 75%);
    background-size: 200% 100%;
    animation: at-shimmer-run 1.4s infinite linear;
}

@keyframes at-shimmer-run {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes at-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes at-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

body.at-search-lock,
body.at-chatbot-lock {
    overflow: hidden !important;
    touch-action: none;
    overscroll-behavior: none;
}

body.at-search-lock .at-tabbar,
body.at-search-lock .offcanvas__stikcy--toolbar,
body.at-search-lock .whatsapp-float-container,
body.at-search-lock .autotech-chatbot-trigger,
body.at-search-lock #scroll__top,
body.at-search-lock .pwa-install-banner {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

@media (max-width: 991px) {
    .at-search-container {
        max-height: min(78vh, 640px);
    }

    .at-search-container.is-idle {
        max-height: none;
    }

    .at-search-header {
        padding: 2px 16px 14px;
        gap: 10px;
    }

    .at-search-input-wrapper {
        min-height: 50px;
        padding: 0 12px 0 14px;
        border-radius: 14px;
    }

    .at-search-input {
        height: 50px;
        font-size: 16px;
    }

    .at-search-body {
        padding: 0 16px 20px;
    }

    .at-search-container.has-results .at-search-body,
    .at-search-container.is-loading .at-search-body {
        max-height: min(56vh, 460px);
    }

    .at-search-content {
        gap: 8px;
    }
}

@media (min-width: 992px) {
    .at-search-overlay {
        align-items: center;
        justify-content: flex-start;
        padding-top: max(6vh, 40px);
        padding-bottom: 40px;
    }

    .at-search-container {
        width: min(560px, 92vw);
        margin: 0 auto;
        border-radius: 18px;
        height: auto;
        max-height: min(72vh, 620px);
        transform: translateY(18px) scale(0.98);
        opacity: 0;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, max-height 0.28s ease;
    }

    .at-search-container.is-idle {
        max-height: none;
    }

    .at-search-overlay.active .at-search-container {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    .at-search-sheet-handle {
        display: none;
    }

    .at-search-header {
        padding: 18px 20px 14px;
    }

    .at-search-body {
        padding: 4px 20px 22px;
    }

    .at-search-container.has-results .at-search-body,
    .at-search-container.is-loading .at-search-body {
        max-height: min(52vh, 420px);
    }
}

.at-search-segment-badge {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 6px;
    background: color-mix(in srgb, var(--secondary-color, #e41f27) 12%, #fff);
    color: var(--secondary-color, #e41f27);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.at-search-segment-badge.small,
.at-search-segment-badge.big {
    background: color-mix(in srgb, var(--secondary-color, #e41f27) 12%, #fff);
    color: var(--secondary-color, #e41f27);
}
