/* ═══════════════════════════════════════════
   Search Page Styles
   ═══════════════════════════════════════════ */

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; padding: 0; background: #f5f7fa; color: #2d3748;
}
.container { max-width: 980px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 0 0 14px; color: #1a202c; }

/* ── Search bar (top) ── */
.search-bar {
    display: flex; gap: 8px; margin-bottom: 10px;
    background: #fff; padding: 8px; border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06); border: 1px solid #e2e8f0;
}
.search-input-wrapper {
    flex: 1; min-width: 0; position: relative; display: flex; align-items: center;
}
.search-bar input[type=text] {
    flex: 1; min-width: 0; width: 100%;
    padding: 12px 36px 12px 16px; font-size: 16px;
    border: none; outline: none; background: transparent;
}
.search-bar input[type=text]::placeholder { color: #a0aec0; }
.clear-btn {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: #edf2f7; color: #718096; border: none; border-radius: 50%;
    font-size: 13px; font-weight: 600; cursor: pointer;
    opacity: 0; visibility: hidden; transition: all .2s ease;
}
.clear-btn.visible { opacity: 1; visibility: visible; }
.clear-btn:hover { background: #e2e8f0; color: #2d3748; }
.search-bar button[type=submit] {
    padding: 10px 24px; font-size: 15px; font-weight: 600;
    background: #4299e1; color: #fff; border: 0; border-radius: 8px;
    cursor: pointer; white-space: nowrap; transition: background .15s;
}
.search-bar button[type=submit]:hover { background: #3182ce; }
.search-bar button[type=submit]:disabled { opacity: .7; cursor: not-allowed; }

/* ── Loading overlay ── */
.loading-overlay {
    display: none; position: fixed; inset: 0; z-index: 999;
    background: rgba(255,255,255,.6); backdrop-filter: blur(2px);
    align-items: center; justify-content: center; flex-direction: column; gap: 12px;
}
.loading-overlay.active { display: flex; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid #e2e8f0; border-top-color: #4299e1;
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: #4a5568; font-weight: 500; }

/* ── Filter Cards ── */
.filter-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    margin-bottom: 10px; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.filter-card-header {
    padding: 10px 16px; font-size: 13px; font-weight: 700; color: #2d3748;
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; user-select: none; list-style: none;
}
.filter-card-header::-webkit-details-marker { display: none; }
.filter-card-header::after {
    content: '▾'; margin-left: auto; font-size: 12px; color: #a0aec0;
    transition: transform .2s;
}
details.filter-card:not([open]) .filter-card-header { border-bottom: none; }
details.filter-card[open] .filter-card-header {
    border-bottom: 1px solid #f0f4f8;
}
details.filter-card:not([open]) .filter-card-header::after { transform: rotate(-90deg); }
.filter-icon { font-size: 14px; }
.filter-card-body { padding: 12px 16px; }

/* Split row: left (tips+mode) + right (engine) */
.filter-split-row {
    display: flex; gap: 20px; align-items: flex-start;
}
.split-left { flex: 1; display: flex; align-items: center; gap: 16px; }
.split-right {
    flex-shrink: 0; width: 200px;
    border-left: 1px solid #f0f4f8; padding-left: 20px;
}
.engine-label {
    font-size: 12px; font-weight: 700; color: #718096; margin-bottom: 8px;
}
.engine-switch { display: flex; flex-direction: column; gap: 6px; }
.engine-switch .radio-card { padding: 6px 12px; font-size: 12px; }
.search-tips {
    flex-shrink: 0; font-size: 12px; color: #718096; line-height: 1.6;
}
.search-tips .tips-title { font-weight: 600; color: #4a5568; margin-bottom: 2px; }
.search-tips ul { margin: 0; padding-left: 16px; }
.search-tips li { margin: 1px 0; }
.search-tips code {
    background: #edf2f7; padding: 1px 5px; border-radius: 3px;
    font-family: ui-monospace, Menlo, monospace; font-size: 11px; font-weight: 600; color: #2b6cb0;
}
.search-tips em { color: #4a5568; font-style: italic; }

/* Radio cards (visible radio circle) */
.radio-group { display: flex; gap: 8px; flex: 1; }
.radio-card {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; flex: 1;
    border: 1.5px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; transition: all .15s; font-size: 13px; color: #4a5568;
}
.radio-card:hover { border-color: #4299e1; background: #f7fbff; }
.radio-card input[type=radio] {
    appearance: auto; width: 16px; height: 16px; accent-color: #4299e1;
    margin: 0; flex-shrink: 0;
}
.radio-card:has(input:checked) {
    border-color: #4299e1; background: #f0f7ff; color: #2b6cb0; font-weight: 600;
}

/* ── Info Tabs (Guide + Steps) ── */
.info-tabs {
    margin-bottom: 12px;
}
.tab-buttons {
    display: flex; gap: 4px; margin-bottom: 0;
}
.tab-btn {
    padding: 8px 16px; font-size: 13px; font-weight: 600;
    background: #f7fafc; color: #718096;
    border: 1px solid #e2e8f0; border-bottom: none;
    border-radius: 8px 8px 0 0; cursor: pointer;
    transition: all .15s; outline: none;
}
.tab-btn:hover { background: #edf2f7; color: #4a5568; }
.tab-btn.active { background: #fff; color: #2b6cb0; border-color: #e2e8f0; }
.tab-content {
    display: none; background: #fff; border: 1px solid #e2e8f0; border-radius: 0 8px 8px 8px;
    padding: 16px 20px; font-size: 13px; line-height: 1.7; color: #2d3748;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.tab-content.active { display: block; }
.tab-content h3 {
    font-size: 15px; margin: 0 0 10px; color: #1a202c;
}
.tab-content h4 {
    font-size: 13px; margin: 14px 0 6px; color: #2b6cb0; font-weight: 700;
    border-bottom: 1px solid #edf2f7; padding-bottom: 4px;
}
.tab-content h4:first-of-type { margin-top: 4px; }
.tab-content table {
    width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12px;
}
.tab-content th {
    text-align: left; padding: 5px 8px; background: #f7fafc;
    border: 1px solid #edf2f7; font-weight: 600; color: #4a5568;
}
.tab-content td { padding: 5px 8px; border: 1px solid #edf2f7; }
.tab-content code {
    background: #edf2f7; padding: 1px 6px; border-radius: 3px;
    font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 600; color: #2b6cb0;
}
.tab-content .example {
    background: #f0fff4; border: 1px solid #c6f6d5; border-radius: 6px;
    padding: 8px 12px; margin: 6px 0; font-size: 12px;
}
.tab-content .example strong { color: #22543d; }
.tab-content .warn {
    background: #fffbeb; border: 1px solid #fefcbf; border-radius: 6px;
    padding: 6px 10px; margin: 6px 0; font-size: 12px; color: #744210;
}
.tab-content ul { margin: 4px 0; padding-left: 18px; }
.tab-content li { margin: 2px 0; }
.steps-list {
    margin: 6px 0; padding-left: 18px; color: #4a5568;
    font-family: ui-monospace, Menlo, monospace; line-height: 1.7; font-size: 12px;
}
.steps-list li { margin: 1px 0; }

/* 3 equal columns for facet + page + file filters */
.filter-grid-3col {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
    align-items: start;
}
.facet-empty { font-size: 12px; color: #a0aec0; font-style: italic; }

/* Page range inputs */
.page-range {
    display: flex; align-items: center; gap: 8px;
}
.range-label { font-size: 13px; color: #718096; white-space: nowrap; }
.page-range input[type=number] {
    width: 72px; padding: 7px 10px; font-size: 13px;
    border: 1.5px solid #e2e8f0; border-radius: 8px; outline: none;
    text-align: center; transition: border-color .15s;
}
.page-range input[type=number]:focus {
    border-color: #4299e1; box-shadow: 0 0 0 2px rgba(66,153,225,.1);
}

/* Pill buttons for file type */
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn {
    display: inline-flex; align-items: center;
    padding: 7px 18px; font-size: 13px;
    background: #f7fafc; border: 1.5px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; transition: all .15s; user-select: none; color: #4a5568;
}
.pill-btn:hover { border-color: #4299e1; background: #f0f7ff; }
.pill-btn input[type=radio] { display: none; }
.pill-btn:has(input:checked) {
    background: #edf2f7; border-color: #cbd5e0; color: #2d3748; font-weight: 600;
}

/* Keep legacy pills for any other usage */
.pills { display: flex; gap: 5px; flex-wrap: wrap; }
.pills label {
    display: inline-flex; align-items: center;
    padding: 5px 12px; font-size: 13px;
    background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 20px;
    cursor: pointer; transition: all .15s; user-select: none;
}
.pills label:hover { border-color: #4299e1; background: #ebf8ff; }
.pills input[type=radio] { display: none; }
.pills label:has(input:checked) {
    background: #4299e1; color: #fff; border-color: #4299e1;
}

/* ── Help Guide ── */
.help-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; font-size: 13px; font-weight: 600;
    background: #ebf8ff; color: #2b6cb0; border: 1px solid #bee3f8; border-radius: 6px;
    cursor: pointer; transition: all .2s; margin-bottom: 10px; user-select: none;
}
.help-toggle:hover { background: #bee3f8; }
.help-toggle .arrow { transition: transform .2s; display: inline-block; }
.help-toggle.open .arrow { transform: rotate(90deg); }
.help-guide {
    display: none; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 16px 20px; margin-bottom: 14px; font-size: 13px; line-height: 1.7;
    color: #2d3748; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.help-guide.open { display: block; }
.help-guide h3 {
    font-size: 15px; margin: 0 0 10px; color: #1a202c;
    display: flex; align-items: center; gap: 6px;
}
.help-guide h4 {
    font-size: 13px; margin: 14px 0 6px; color: #2b6cb0; font-weight: 700;
    border-bottom: 1px solid #edf2f7; padding-bottom: 4px;
}
.help-guide h4:first-of-type { margin-top: 4px; }
.help-guide table {
    width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12px;
}
.help-guide th {
    text-align: left; padding: 5px 8px; background: #f7fafc;
    border: 1px solid #edf2f7; font-weight: 600; color: #4a5568;
}
.help-guide td { padding: 5px 8px; border: 1px solid #edf2f7; }
.help-guide code {
    background: #edf2f7; padding: 1px 6px; border-radius: 3px;
    font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 600;
    color: #2b6cb0;
}
.help-guide .example {
    background: #f0fff4; border: 1px solid #c6f6d5; border-radius: 6px;
    padding: 8px 12px; margin: 6px 0; font-size: 12px;
}
.help-guide .example strong { color: #22543d; }
.help-guide .warn {
    background: #fffbeb; border: 1px solid #fefcbf; border-radius: 6px;
    padding: 6px 10px; margin: 6px 0; font-size: 12px; color: #744210;
}
.help-guide ul { margin: 4px 0; padding-left: 18px; }
.help-guide li { margin: 2px 0; }

/* ── Search Steps ── */
.search-steps {
    background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 8px 14px; margin-bottom: 12px; font-size: 12px;
}
.search-steps summary {
    font-size: 12px; color: #718096; font-weight: 600; cursor: pointer;
    user-select: none; list-style: none; display: flex; align-items: center; gap: 4px;
}
.search-steps summary::-webkit-details-marker { display: none; }
.search-steps summary::before {
    content: '▶'; font-size: 9px; transition: transform .15s; display: inline-block;
}
.search-steps[open] summary::before { transform: rotate(90deg); }
.search-steps ol {
    margin: 6px 0 2px; padding-left: 18px; color: #4a5568;
    font-family: ui-monospace, Menlo, monospace; line-height: 1.7;
}
.search-steps ol li { margin: 1px 0; }

/* ── Meta ── */
.meta {
    background: #fff; padding: 10px 14px; border-radius: 8px;
    border: 1px solid #e2e8f0; margin-bottom: 14px;
    color: #2d3748; font-size: 14px; line-height: 1.6;
}
.meta strong { color: #2b6cb0; }
.meta .badge {
    display: inline-block; padding: 2px 8px; margin-left: 4px;
    background: #e6fffa; color: #234e52; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.meta .pageinfo { float: right; color: #718096; font-size: 13px; }
.alert {
    padding: 10px 14px; background: #fff5f5; color: #742a2a;
    border-left: 3px solid #fc8181; margin-bottom: 14px; font-size: 13px; border-radius: 4px;
}

/* ── Result items ── */
.item {
    background: #fff; padding: 14px 16px; margin-bottom: 8px;
    border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid #e2e8f0; transition: border-color .2s, box-shadow .2s;
    position: relative;
}
.item:hover { border-color: #bee3f8; box-shadow: 0 2px 8px rgba(66,153,225,.1); }
.item-header { display: flex; align-items: flex-start; gap: 10px; }
.item-rank {
    flex-shrink: 0; width: 28px; height: 28px;
    background: #edf2f7; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #718096;
}
.item:first-child .item-rank { background: #ebf8ff; color: #2b6cb0; }
.item:nth-child(2) .item-rank { background: #f0fff4; color: #276749; }
.item:nth-child(3) .item-rank { background: #fffff0; color: #975a16; }
.item-body { flex: 1; min-width: 0; }
.item h3 { margin: 0 0 4px; font-size: 15px; line-height: 1.5; }
.item h3 a { color: #2d3748; text-decoration: none; }
.item h3 a:hover { color: #2b6cb0; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.item-tag {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; font-size: 11px; font-weight: 600;
    border-radius: 4px;
}
.item-tag.pages { background: #f0fff4; color: #276749; }
.item-tag-plain {
    font-size: 12px; color: #718096;
}
.ext-badge {
    display: inline-flex; align-items: center; padding: 2px 7px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    border-radius: 4px; letter-spacing: .3px;
}
.ext-pdf { background: #fed7d7; color: #c53030; }
.ext-doc, .ext-docx { background: #bee3f8; color: #2a4365; }
.ext-ppt, .ext-pptx { background: #fefcbf; color: #975a16; }
.ext-xls, .ext-xlsx { background: #c6f6d5; color: #22543d; }
.ext-other { background: #edf2f7; color: #4a5568; }
.item .actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.item .actions a {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; font-size: 12px; font-weight: 500;
    border-radius: 6px; text-decoration: none; transition: all .15s;
}
.item .actions a.view { background: #4299e1; color: #fff; }
.item .actions a.view:hover { background: #3182ce; }
.item .actions a.download { background: #fff; color: #4a5568; border: 1px solid #e2e8f0; }
.item .actions a.download:hover { background: #edf2f7; border-color: #cbd5e0; }

/* ── Keyword highlight ── */
mark.kw {
    background: #fefcbf; color: #744210; padding: 0 2px;
    border-radius: 2px; font-weight: 600; text-decoration: none;
}

/* ── Empty ── */
.empty {
    text-align: center; padding: 50px 20px; color: #a0aec0; font-size: 14px;
    background: #fff; border-radius: 8px; border: 1px dashed #e2e8f0;
}

/* ── Pagination ── */
.pagination {
    display: flex; gap: 4px; justify-content: center;
    margin: 14px 0; flex-wrap: wrap; align-items: center;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 8px;
    border-radius: 6px; text-decoration: none; color: #4a5568;
    background: #fff; border: 1px solid #e2e8f0; font-size: 13px;
    transition: all .15s;
}
.pagination a:hover { background: #edf2f7; border-color: #cbd5e0; }
.pagination .current {
    background: #4299e1; color: #fff; border-color: #4299e1; font-weight: 600;
}
.pagination .disabled {
    color: #cbd5e0; pointer-events: none; background: #f7fafc; border-color: #edf2f7;
}
.pagination .ellipsis { border: none; background: none; min-width: 20px; color: #a0aec0; }
.pagination .nav-btn { font-weight: 500; padding: 0 10px; }

/* ── Faceted search ── */
.facet-panel {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 12px 14px; margin-bottom: 12px;
}
.facet-panel .facet-title {
    font-size: 11px; color: #718096; font-weight: 700; margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: .5px;
}
.facet-list { display: flex; flex-wrap: wrap; gap: 6px; }
.facet-item {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; font-size: 12px;
    background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 16px;
    cursor: pointer; transition: all .15s; text-decoration: none; color: #4a5568;
}
.facet-item:hover { border-color: #4299e1; background: #ebf8ff; color: #2b6cb0; }
.facet-item.active { background: #4299e1; color: #fff; border-color: #4299e1; }
.facet-count {
    background: rgba(0,0,0,.08); padding: 1px 6px; border-radius: 10px;
    font-size: 10px; font-weight: 600;
}
.facet-item.active .facet-count { background: rgba(255,255,255,.25); }

/* ── Trending searches ── */
.trending-panel {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 16px 18px; margin-top: 8px;
}
.trending-title {
    font-size: 14px; font-weight: 700; color: #2d3748; margin-bottom: 12px;
    display: flex; align-items: center; gap: 6px;
}
.trending-list { display: flex; flex-wrap: wrap; gap: 8px; }
.trending-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; font-size: 13px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 1px solid #e2e8f0; border-radius: 20px;
    cursor: pointer; transition: all .2s; text-decoration: none; color: #2d3748;
}
.trending-item:hover {
    border-color: #4299e1; background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    color: #2b6cb0; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(66,153,225,.15);
}
.trending-badge {
    background: #4299e1; color: #fff; padding: 1px 6px; border-radius: 10px;
    font-size: 10px; font-weight: 700; min-width: 18px; text-align: center;
}
.trending-empty { color: #a0aec0; font-size: 13px; font-style: italic; }

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile ≤ 640px
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .container { padding: 12px 10px; }
    h1 { font-size: 18px; margin-bottom: 10px; }
    .search-bar { flex-wrap: wrap; padding: 6px; }
    .search-input-wrapper { min-width: 100%; }
    .search-bar input[type=text] { min-width: 100%; padding: 10px 34px 10px 12px; font-size: 15px; }
    .clear-btn { right: 4px; width: 26px; height: 26px; font-size: 12px; }
    .search-bar button[type=submit] { width: 100%; padding: 12px; font-size: 15px; }
    /* Filter cards mobile */
    .filter-split-row { flex-direction: column; gap: 12px; }
    .split-left { flex-direction: column; align-items: stretch; gap: 8px; }
    .split-right { width: 100%; border-left: none; border-top: 1px solid #f0f4f8; padding-left: 0; padding-top: 12px; }
    .engine-switch { flex-direction: row; }
    .search-tips { display: none; }
    .radio-group { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .radio-card { padding: 6px 10px; font-size: 12px; flex: 0 0 auto; }
    .filter-grid-3col { grid-template-columns: 1fr; }
    .page-range input[type=number] { flex: 1; width: auto; }
    .pill-btn { padding: 6px 14px; font-size: 12px; }
    .filter-card-body { padding: 10px 12px; }
    /* Rest */
    .help-guide { padding: 12px 14px; font-size: 12px; }
    .help-guide h3 { font-size: 14px; }
    .help-guide table { font-size: 11px; }
    .help-toggle { font-size: 12px; padding: 5px 10px; }
    .meta { font-size: 13px; padding: 8px 12px; }
    .meta .pageinfo { float: none; display: block; margin-top: 4px; }
    .item { padding: 12px; }
    .item h3 { font-size: 14px; }
    .item-rank { width: 24px; height: 24px; font-size: 11px; }
    .item-meta { gap: 5px; }
    .item-tag { font-size: 10px; padding: 1px 6px; }
    .item .actions a { padding: 6px 10px; font-size: 12px; }
    .pagination a, .pagination span { min-width: 30px; height: 30px; font-size: 12px; padding: 0 6px; }
    .pagination .nav-btn { padding: 0 8px; font-size: 12px; }
    .facet-item { font-size: 11px; padding: 3px 8px; }
    .trending-item { font-size: 12px; padding: 5px 10px; }
}
