/* ============================================================
   BioCode Search Enhancement CSS
   Covers: navbar search button, full-screen overlay,
           live results dropdown, search results page.
   Brand: #175cff (blue), #0a083b (dark navy), #57586e (grey)
   ============================================================ */

/* ── 1. SEARCH ICON BUTTON IN NAVBAR ──────────────────────── */

.biocode-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #57586e;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    padding: 0;
    flex-shrink: 0;
    margin-right: 4px;
}

.biocode-search-btn:hover,
.biocode-search-btn:focus-visible {
    background: rgba(23, 92, 255, 0.08);
    color: #175cff;
    outline: none;
    transform: scale(1.08);
}

.biocode-search-btn svg {
    pointer-events: none;
}

/* Also intercept the existing header search bar on navbar-right layouts */
.has-search-field .search-field input[type="search"] {
    cursor: pointer;
}


/* ── 2. OVERLAY BASE ──────────────────────────────────────── */

.biocode-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    /* hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.biocode-search-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* JS toggles [hidden] attribute — also handle display */
.biocode-search-overlay[hidden] {
    display: flex !important; /* override UA hidden; we animate instead */
}

/* ── Backdrop ── */
.biocode-search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 8, 59, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ── Dialog ── */
.biocode-search-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 20px;
    background: #ffffff;
    border-radius: 20px;
    padding: 32px 32px 28px;  /* uniform padding — no longer needs top gap for close btn */
    box-shadow: 0 24px 80px rgba(10, 8, 59, 0.35);
    animation: biocodeSlideDown 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.biocode-search-overlay[hidden] .biocode-search-dialog {
    animation: none;
}

@keyframes biocodeSlideDown {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ── 3. CLOSE BUTTON ──────────────────────────────────────── */
/* Lives on the dark backdrop, NOT inside the white dialog.    */

.biocode-search-close {
    /* Positioned relative to the overlay (position:fixed viewport) */
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 10;

    /* Layout */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 44px;   /* WCAG touch target */
    min-height: 44px;
    padding: 0 10px;
    border-radius: 22px;

    /* Appearance — white on dark backdrop */
    background: rgba(255, 255, 255, 0.12);
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.biocode-search-close:hover,
.biocode-search-close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    outline: none;
}

/* "ESC" label — visible on desktop, hidden on mobile */
.biocode-close-esc-hint {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    opacity: 0.75;
}

@media (max-width: 600px) {
    .biocode-close-esc-hint { display: none; }
    .biocode-search-close   { padding: 0; width: 44px; justify-content: center; }
}


/* ── 4. SEARCH INPUT ROW ──────────────────────────────────── */

.biocode-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    transition: border-color 0.2s ease;
    position: relative;
}

.biocode-search-input-wrap:focus-within {
    border-color: #175cff;
    box-shadow: 0 0 0 4px rgba(23, 92, 255, 0.1);
}

.biocode-input-icon {
    color: #94a3b8;
    flex-shrink: 0;
}

.biocode-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 18px;
    font-weight: 400;
    color: #0a083b;
    background: transparent;
    min-width: 0;
}

.biocode-search-input::placeholder {
    color: #94a3b8;
}

/* Spinner */
.biocode-search-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #175cff;
    border-radius: 50%;
    animation: biocodeSpinAnim 0.7s linear infinite;
    flex-shrink: 0;
    display: none;
}

.biocode-search-spinner.is-visible {
    display: block;
}

@keyframes biocodeSpinAnim {
    to { transform: rotate(360deg); }
}

.biocode-search-submit {
    background: #175cff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
}

.biocode-search-submit:hover {
    background: #0a45d4;
}


/* ── 5. FILTER TABS ───────────────────────────────────────── */

.biocode-search-filters {
    display: flex;
    gap: 6px;
    margin-top: 14px;
}

.biocode-filter-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #57586e;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.biocode-filter-btn:hover {
    background: #e2e8f0;
    color: #0a083b;
}

.biocode-filter-btn.active {
    background: #175cff;
    color: #fff;
}


/* ── 6. LIVE RESULTS DROPDOWN ─────────────────────────────── */

.biocode-search-results {
    margin-top: 16px;
    display: none; /* shown by JS */
}

.biocode-search-results.is-visible {
    display: block;
}

/* Section labels inside results */
.biocode-live-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin: 0 0 8px;
    padding: 0;
}

/* Course row in live results */
.biocode-live-course {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
}

.biocode-live-course:hover,
.biocode-live-course.is-focused {
    background: #f1f5f9;
}

.biocode-live-course-thumb {
    width: 64px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #e2e8f0;
}

.biocode-live-course-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.biocode-live-course-info {
    flex: 1;
    min-width: 0;
}

.biocode-live-course-title {
    font-size: 14px;
    font-weight: 600;
    color: #0a083b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 3px;
}

.biocode-live-course-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.biocode-live-cat {
    font-size: 11px;
    color: #175cff;
    background: rgba(23, 92, 255, 0.08);
    border-radius: 4px;
    padding: 1px 6px;
}

.biocode-live-price {
    font-size: 12px;
    font-weight: 600;
    color: #57586e;
}

.biocode-live-price .biocode-free-badge {
    color: #16a34a;
}

/* Post row in live results */
.biocode-live-post {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.biocode-live-post:hover,
.biocode-live-post.is-focused {
    background: #f1f5f9;
}

.biocode-live-post-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #94a3b8;
}

.biocode-live-post-title {
    font-size: 14px;
    font-weight: 500;
    color: #0a083b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Divider */
.biocode-live-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 10px 0;
}

/* No results */
.biocode-live-no-results {
    text-align: center;
    padding: 24px 0;
    color: #94a3b8;
    font-size: 14px;
}

/* View all link */
.biocode-live-view-all {
    display: block;
    text-align: center;
    padding: 10px;
    color: #175cff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-top: 1px solid #f1f5f9;
    margin-top: 8px;
    border-radius: 0 0 8px 8px;
    transition: background 0.15s;
}

.biocode-live-view-all:hover {
    background: #f1f5f9;
}


/* ── 7. POPULAR SEARCHES ──────────────────────────────────── */

.biocode-search-popular {
    margin-top: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.biocode-popular-label {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}

.biocode-popular-tag {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #57586e;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.biocode-popular-tag:hover {
    background: #175cff;
    color: #fff;
}


/* ── 8. SEARCH RESULTS PAGE ───────────────────────────────── */

.biocode-search-results-page {
    padding: 48px 0 0;
}

.biocode-srp-header {
    margin-bottom: 40px;
}

.biocode-srp-title {
    font-size: 28px;
    font-weight: 700;
    color: #0a083b;
    margin: 0 0 20px;
    line-height: 1.3;
}

.biocode-srp-title em {
    font-style: italic;
    color: #175cff;
}

/* Results page re-search form */
.biocode-srp-form {
    max-width: 580px;
}

.biocode-srp-form-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 16px;
    transition: border-color 0.2s;
    background: #fff;
}

.biocode-srp-form-inner:focus-within {
    border-color: #175cff;
    box-shadow: 0 0 0 4px rgba(23, 92, 255, 0.08);
}

.biocode-srp-form-inner svg {
    color: #94a3b8;
    flex-shrink: 0;
}

.biocode-srp-form-inner input[type="search"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #0a083b;
    background: transparent;
    min-width: 0;
}

.biocode-srp-form-inner button {
    background: #175cff;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.biocode-srp-form-inner button:hover {
    background: #0a45d4;
}


/* ── 9. RESULTS SECTION HEADER ────────────────────────────── */

.biocode-results-section {
    margin-bottom: 56px;
}

.biocode-results-section-head {
    margin-bottom: 24px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
}

.biocode-results-section-title {
    font-size: 22px;
    font-weight: 700;
    color: #0a083b;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.biocode-result-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #175cff;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    padding: 2px 10px;
    line-height: 1.6;
}


/* ── 10. COURSE CARDS GRID ────────────────────────────────── */

.biocode-course-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .biocode-course-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .biocode-course-grid { grid-template-columns: 1fr; }
}

.biocode-course-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.biocode-course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(23, 92, 255, 0.12);
}

/* Thumbnail */
.biocode-course-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f1f5f9;
}

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

.biocode-course-card:hover .biocode-course-thumb img {
    transform: scale(1.04);
}

.biocode-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}

/* Body */
.biocode-course-body {
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.biocode-course-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.biocode-cat-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #175cff;
    background: rgba(23, 92, 255, 0.08);
    border-radius: 4px;
    padding: 2px 7px;
    text-decoration: none;
    transition: background 0.15s;
}

.biocode-cat-tag:hover {
    background: rgba(23, 92, 255, 0.15);
}

.biocode-course-title {
    font-size: 15px;
    font-weight: 700;
    color: #0a083b;
    line-height: 1.4;
    margin: 0;
    flex: 1;
}

.biocode-course-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.biocode-course-title a:hover {
    color: #175cff;
}

/* Footer: price + CTA */
.biocode-course-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.biocode-price {
    font-size: 15px;
    font-weight: 700;
    color: #0a083b;
}

.biocode-price .woocommerce-Price-amount {
    color: #0a083b;
}

.biocode-free-badge {
    font-size: 13px;
    font-weight: 700;
    color: #16a34a;
    background: #dcfce7;
    border-radius: 4px;
    padding: 2px 8px;
}

.biocode-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #175cff;
    text-decoration: none;
    transition: gap 0.15s;
}

.biocode-view-btn:hover {
    gap: 8px;
}


/* ── 11. POST / PAGE LIST ─────────────────────────────────── */

.biocode-post-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.biocode-post-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 10px;
    transition: background 0.15s;
}

.biocode-post-row:hover {
    background: #f8faff;
}

.biocode-post-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #94a3b8;
    background: #f1f5f9;
    border-radius: 4px;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.biocode-post-info {
    flex: 1;
    min-width: 0;
}

.biocode-post-title {
    font-size: 15px;
    font-weight: 600;
    color: #0a083b;
    margin: 0 0 4px;
}

.biocode-post-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}

.biocode-post-title a:hover {
    color: #175cff;
}

.biocode-post-excerpt {
    font-size: 13px;
    color: #57586e;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.biocode-post-arrow {
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
    display: flex;
}

.biocode-post-row:hover .biocode-post-arrow {
    color: #175cff;
    transform: translateX(3px);
}


/* ── 12. NO RESULTS ───────────────────────────────────────── */

.biocode-no-results {
    text-align: center;
    padding: 64px 24px;
    max-width: 520px;
    margin: 0 auto;
}

.biocode-no-results-icon {
    font-size: 56px;
    margin-bottom: 20px;
    display: block;
}

.biocode-no-results h2 {
    font-size: 22px;
    font-weight: 700;
    color: #0a083b;
    margin: 0 0 12px;
}

.biocode-no-results p {
    font-size: 15px;
    color: #57586e;
    margin: 0 0 20px;
}

.biocode-no-results-tips {
    text-align: left;
    font-size: 14px;
    color: #57586e;
    line-height: 1.8;
    margin: 0 0 32px;
    padding-left: 20px;
}

.biocode-browse-all-btn {
    display: inline-block;
    background: #175cff;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.biocode-browse-all-btn:hover {
    background: #0a45d4;
}


/* ── 13. PAGINATION ───────────────────────────────────────── */

.biocode-pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.biocode-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #57586e;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    margin: 0 2px;
}

.biocode-pagination .page-numbers:hover,
.biocode-pagination .page-numbers.current {
    background: #175cff;
    color: #fff;
}


/* ── 14. MOBILE OVERRIDES ─────────────────────────────────── */

@media (max-width: 768px) {
    /* Push dialog down so close button (top: 18px) doesn't overlap */
    .biocode-search-overlay {
        padding-top: 72px;   /* clear the close button */
        align-items: flex-start;
    }

    .biocode-search-dialog {
        padding: 22px 18px 20px;
        border-radius: 16px;
        /* Allow dialog to grow but leave room for the close button above */
        max-height: calc(100vh - 90px);
    }

    .biocode-search-input {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .biocode-search-submit {
        display: none; /* use Enter key; saves space */
    }

    /* Close button: large tap target on mobile */
    .biocode-search-close {
        top: 12px;
        right: 12px;
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
    }

    /* Search results page */
    .biocode-srp-title {
        font-size: 22px;
    }

    .biocode-post-row {
        padding: 12px 10px;
    }

    .biocode-post-excerpt {
        display: none;
    }
}
