/* ============================================================
   KSSEED — ADVANCED SEARCH MODAL
   Append this entire block to the bottom of css/style.css
   ============================================================ */

/* ── Search trigger button (in header) ── */
.search-trigger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text-color);
    font-size: 20px;
    transition: var(--transition);
}

.search-trigger:hover {
    background: var(--light-gray);
    color: var(--primary-green);
}

/* ── Backdrop ── */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

/* ── Modal panel ── */
.search-modal {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-30px);
    width: min(760px, 96vw);
    max-height: 88vh;
    background: var(--white);
    border-radius: 0 0 16px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 9001;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.25s ease,
        visibility 0.25s ease;
    overflow: hidden;
}

.search-modal.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* ── Search bar row ── */
.sm-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 22px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.sm-bar-icon {
    font-size: 22px;
    color: var(--primary-green);
    flex-shrink: 0;
}

.sm-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
    color: var(--text-color);
    background: transparent;
}

.sm-input::placeholder {
    color: #aaa;
}

.sm-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: #aaa;
    padding: 4px;
    border-radius: 50%;
    line-height: 1;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sm-close:hover {
    color: var(--text-color);
    background: var(--light-gray);
}

/* ── Filter tabs ── */
.sm-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 22px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
}

.sm-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid #ddd;
    background: none;
    font-size: 13px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.sm-tab:hover {
    border-color: var(--primary-green);
    color: var(--primary-green);
}

.sm-tab.active {
    background: var(--primary-green);
    color: var(--white);
    border-color: var(--primary-green);
}

.sm-tab .sm-cnt {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 0 6px;
    min-width: 18px;
    text-align: center;
}

.sm-tab:not(.active) .sm-cnt {
    background: #eee;
    color: #888;
}

.sm-sort {
    margin-left: auto;
    font-size: 13px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: var(--text-color);
    background: var(--white);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Results area ── */
.sm-results {
    flex: 1;
    overflow-y: auto;
    padding: 10px 22px 20px;
}

.sm-results::-webkit-scrollbar {
    width: 4px;
}

.sm-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* ── Result count label ── */
.sm-meta {
    font-size: 12px;
    color: #aaa;
    padding: 6px 0 10px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

/* ── Individual result card ── */
.sm-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f2f2f2;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    cursor: default;
}

.sm-card:last-child {
    border-bottom: none;
}

.sm-card:hover {
    background: #fafff8;
    border-radius: 8px;
    padding-left: 8px;
    padding-right: 8px;
    margin: 0 -8px;
}

.sm-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--light-gray);
}

.sm-thumb-ph {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--light-gray);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #bbb;
}

.sm-body {
    flex: 1;
    min-width: 0;
}

.sm-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.sm-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-badge-product {
    background: #eaf3de;
    color: #3b6d11;
}

.sm-badge-blog {
    background: #e6f1fb;
    color: #185fa5;
}

.sm-badge-story {
    background: #faeeda;
    color: #854f0b;
}

.sm-badge-faq {
    background: #eeedfe;
    color: #534ab7;
}

.sm-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 480px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-meta-row {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 3px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-preview {
    font-size: 13px;
    color: #777;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-preview mark,
.sm-title mark {
    background: #fff3b0;
    color: #7a5c00;
    border-radius: 2px;
    padding: 0 2px;
}

/* ── States ── */
.sm-state {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 14px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
    line-height: 1.6;
}

.sm-state i {
    font-size: 36px;
    display: block;
    margin-bottom: 10px;
}

.sm-state strong {
    color: var(--text-color);
}

.sm-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: #aaa;
    font-size: 14px;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-spinner i {
    font-size: 20px;
    animation: sm-spin 0.9s linear infinite;
}

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

.sm-load-more {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: none;
    font-family: 'Hanuman', 'Poppins', sans-serif;
    font-size: 14px;
    color: var(--primary-green);
    cursor: pointer;
    transition: var(--transition);
}

.sm-load-more:hover {
    background: var(--light-gray);
}

/* ── Keyboard shortcut hint ── */
.sm-hint {
    flex-shrink: 0;
    padding: 8px 22px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: #ccc;
    align-items: center;
    font-family: 'Hanuman', 'Poppins', sans-serif;
}

.sm-hint kbd {
    background: #f3f3f3;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
    font-size: 11px;
    color: #888;
}

/* ── Clickable card (anchor) ── */
a.sm-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.sm-card:hover {
    background: #f0faf0;
    border-radius: 8px;
    padding-left: 8px;
    padding-right: 8px;
    margin: 0 -8px;
}

a.sm-card:hover .sm-title {
    color: var(--primary-green);
}

/* ── Arrow indicator ── */
.sm-arrow {
    font-size: 20px;
    color: #ccc;
    flex-shrink: 0;
    align-self: center;
    transition: transform 0.2s ease, color 0.2s ease;
}

a.sm-card:hover .sm-arrow {
    color: var(--primary-green);
    transform: translateX(3px);
}


/* ════════════════════════════════════════════════
   RESPONSIVE — LAPTOP  (≤ 1280px)
   Slightly tighter but still full-featured
════════════════════════════════════════════════ */
@media (max-width: 1280px) {
    .search-modal {
        width: min(700px, 94vw);
    }

    .sm-title {
        max-width: 400px;
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — TABLET  (≤ 1024px)
════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .search-modal {
        width: min(680px, 94vw);
        max-height: 85vh;
    }

    .sm-bar {
        padding: 15px 18px;
    }

    .sm-input {
        font-size: 16px;
    }

    .sm-tabs {
        padding: 10px 18px 8px;
        gap: 5px;
    }

    .sm-tab {
        padding: 5px 12px;
        font-size: 13px;
    }

    .sm-results {
        padding: 8px 18px 18px;
    }

    .sm-thumb,
    .sm-thumb-ph {
        width: 50px;
        height: 50px;
    }

    .sm-title {
        font-size: 14px;
        max-width: 360px;
    }

    .sm-hint {
        padding: 8px 18px;
        gap: 12px;
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — LARGE MOBILE  (≤ 768px / tablet portrait)
════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .search-modal {
        /* full-width sheet from top on small screens */
        width: 100vw;
        left: 0;
        transform: translateY(-30px);
        border-radius: 0 0 14px 14px;
        max-height: 80vh;
    }

    .search-modal.open {
        transform: translateY(0);
    }

    .sm-bar {
        padding: 14px 16px;
        gap: 8px;
    }

    .sm-input {
        font-size: 15px;
    }

    .sm-bar-icon {
        font-size: 20px;
    }

    .sm-tabs {
        padding: 10px 14px 8px;
        gap: 5px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sm-tabs::-webkit-scrollbar {
        display: none;
    }

    .sm-tab {
        padding: 5px 11px;
        font-size: 12px;
        flex-shrink: 0;
    }

    .sm-sort {
        display: none;
        /* hidden on small screens — accessed via tab order */
    }

    .sm-results {
        padding: 8px 14px 16px;
    }

    .sm-thumb,
    .sm-thumb-ph {
        width: 46px;
        height: 46px;
        font-size: 18px;
    }

    .sm-title {
        font-size: 14px;
        max-width: 260px;
    }

    .sm-preview {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }

    .sm-hint {
        display: none;
    }

    .sm-card {
        gap: 10px;
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤ 480px)
════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .search-modal {
        max-height: 82vh;
        border-radius: 0 0 12px 12px;
    }

    .sm-bar {
        padding: 12px 14px;
        gap: 8px;
    }

    .sm-input {
        font-size: 15px;
    }

    .sm-tabs {
        padding: 8px 12px 7px;
        gap: 4px;
    }

    .sm-tab {
        padding: 4px 10px;
        font-size: 12px;
    }

    .sm-tab i {
        display: none;
        /* hide icons to save space on very small screens */
    }

    .sm-results {
        padding: 6px 12px 14px;
    }

    .sm-thumb,
    .sm-thumb-ph {
        width: 42px;
        height: 42px;
        border-radius: 6px;
        font-size: 16px;
    }

    .sm-title {
        font-size: 13px;
        max-width: 200px;
    }

    .sm-meta-row {
        font-size: 11px;
    }

    .sm-preview {
        font-size: 12px;
    }

    .sm-card {
        gap: 9px;
        padding: 10px 0;
    }

    .sm-arrow {
        font-size: 16px;
    }

    .sm-badge {
        font-size: 9px;
        padding: 1px 6px;
    }

    .sm-state {
        padding: 30px 16px;
        font-size: 13px;
    }

    .sm-state i {
        font-size: 30px;
        margin-bottom: 8px;
    }

    .sm-load-more {
        font-size: 13px;
        padding: 9px;
    }

    .sm-meta {
        font-size: 11px;
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — VERY SMALL MOBILE  (≤ 360px)
════════════════════════════════════════════════ */
@media (max-width: 360px) {
    .sm-input {
        font-size: 14px;
    }

    .sm-tab {
        padding: 3px 8px;
        font-size: 11px;
    }

    .sm-thumb,
    .sm-thumb-ph {
        width: 38px;
        height: 38px;
    }

    .sm-title {
        font-size: 12px;
        max-width: 170px;
    }
}