/* =====================================================
   Custom AJAX Product Search  |  caps-search.css
   ===================================================== */

/* ── Reset & base ────────────────────────────────── */
#caps-overlay *,
#caps-overlay *::before,
#caps-overlay *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Overlay backdrop ────────────────────────────── */
.caps-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px 24px;
    background: rgba(10, 10, 10, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.caps-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.caps-locked {
    overflow: hidden;
}

/* ── Modal card ──────────────────────────────────── */
.caps-modal {
    width: 100%;
    padding:25px !important;
    max-width: 900px;
    max-height: calc(100vh - 84px);
    background: #fff;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0,0,0,0.08);

    /* Slide-in from top */
    transform: translateY(-28px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.caps-overlay.is-open .caps-modal {
    transform: translateY(0) scale(1);
}

/* ── Header (search bar row) ─────────────────────── */
.caps-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    /* border-bottom: 1px solid #f0f0f0; */
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Input wrapper */
.caps-input-wrap {
    flex: 1;
    display: flex;
    margin-bottom: 40px;
    align-items: center;
    gap: 10px;
    background: #f6f6f6;
    border-radius: 12px;
    padding: 18px 14px !important;
    border: 1.5px solid transparent;
    transition: border-color 0.18s, background 0.18s;
}

.caps-input-wrap:focus-within {
    background: #fff;
    border-color: #222;
}

.caps-ico--search {
    width: 18px;
    height: 18px;
    color: #aaa;
    flex-shrink: 0;
    transition: color 0.18s;
}

.caps-input-wrap:focus-within .caps-ico--search {
    color: #444;
}

.caps-input {
    flex: 1;
    border: none !important;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    color: #111;
    line-height: 1.4;
    outline: none;
    min-width: 0;
    /* remove browser search decorations */
    -webkit-appearance: none;
    appearance: none;
}

.caps-input::placeholder {
    color: #bbb;
}

.caps-input::-webkit-search-cancel-button,
.caps-input::-webkit-search-decoration {
    display: none;
}

/* Clear ✕ inside input */
.caps-clear {
    display: none; /* toggled via JS */
    align-items: center;
    justify-content: center;
    background: #ddd;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.caps-clear:hover {
    background: #ccc;
}

.caps-clear svg {
    width: 11px;
    height: 11px;
    color: #555;
}

/* ESC / Close button */
.caps-esc {
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1.5px solid #e8e8e8;
    background: transparent;
    border-radius: 10px;
    padding: 9px 13px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.caps-esc:hover {
    border-color: #aaa;
    color: #444;
}

.caps-esc svg {
    width: 14px;
    height: 14px;
}

/* ── Results area ────────────────────────────────── */
.caps-results {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* Scrollbar (Webkit) */
.caps-results::-webkit-scrollbar {
    width: 6px;
}
.caps-results::-webkit-scrollbar-track {
    background: transparent;
}
.caps-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

/* Results count header */
.caps-results-meta {
    font-size: 12px;
    color: #aaa;
    letter-spacing: 0.03em;
    margin: 30px auto !important;
    padding-bottom: 12px;
    /* border-bottom: 1px solid #f3f3f3; */
}

.caps-results-meta strong {
    color: #333;
}

/* Grid that wraps your Elementor loop cards */
.caps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}

/* Each cell — make Elementor loop items clickable */
.caps-cell {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    border-radius: 12px;
    overflow: hidden;
}

.caps-cell:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* Prevent double-click flashes */
.caps-cell a {
    pointer-events: none; /* JS handles navigation */
    text-decoration: none;
    color: inherit;
}

/* ── States ──────────────────────────────────────── */
.caps-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    color: #ccc;
    text-align: center;
    margin: 30px;
}

.caps-state svg {
    width: 40px;
    height: 40px;
    opacity: 0.4;
}

.caps-state p {
    font-size: 14px;
    color: #bbb;
}

/* Spinner */
.caps-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #eee;
    border-top-color: #222;
    border-radius: 50%;
    animation: caps-spin 0.65s linear infinite;
}

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

/* Empty state */
.caps-state--empty svg {
    opacity: 0.25;
}

.caps-state--empty p strong {
    color: #999;
}

/* ── Fallback card (used when no Elementor template set) ── */
.caps-fc {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #ebebeb;
    background: #fff;
    height: 100%;
    transition: box-shadow 0.2s;
}

.caps-fc:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
}

.caps-fc__img {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f9f9f9;
}

.caps-fc__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.caps-fc:hover .caps-fc__img img {
    transform: scale(1.04);
}

.caps-fc__no-img {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f0f0 0%, #e4e4e4 100%);
}

.caps-fc__body {
    padding: 12px 14px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.caps-fc__name {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.caps-fc__price {
    font-size: 13px;
    color: #444;
    margin-top: auto;
}

.caps-fc__price .woocommerce-Price-amount {
    font-weight: 600;
}

/* ── Animation: stagger cells in ────────────────── */
@keyframes caps-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.caps-cell {
    animation: caps-fadein 0.22s ease both;
}

/* stagger up to 12 items */
.caps-cell:nth-child(1)  { animation-delay: 0.02s; }
.caps-cell:nth-child(2)  { animation-delay: 0.05s; }
.caps-cell:nth-child(3)  { animation-delay: 0.08s; }
.caps-cell:nth-child(4)  { animation-delay: 0.11s; }
.caps-cell:nth-child(5)  { animation-delay: 0.14s; }
.caps-cell:nth-child(6)  { animation-delay: 0.17s; }
.caps-cell:nth-child(7)  { animation-delay: 0.20s; }
.caps-cell:nth-child(8)  { animation-delay: 0.23s; }
.caps-cell:nth-child(9)  { animation-delay: 0.26s; }
.caps-cell:nth-child(10) { animation-delay: 0.29s; }
.caps-cell:nth-child(11) { animation-delay: 0.32s; }
.caps-cell:nth-child(12) { animation-delay: 0.35s; }

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 640px) {
    .caps-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .caps-modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(40px) scale(1);
    }

    .caps-overlay.is-open .caps-modal {
        transform: translateY(0) scale(1);
    }

    .caps-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .caps-esc span {
        display: none;
    }

    .caps-esc {
        padding: 9px 10px;
    }
}

input#caps-input {
    border: none !important;
}
.caps-results-meta {
    border: none !important;
}
button#caps-close {
    height: 30px !important;
    padding: 28px 15px;
}
div#caps-results {
    margin-top: 40px !important;
    margin-bottom: 30px !important;
}