/* Buscador Avanzado — pantalla completa con scroll */
.bible-search-overlay,
.bible-search-overlay * {
    box-sizing: border-box;
}

.bible-search-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    z-index: 10000;
    display: none;
    padding: 0;
    margin: 0;
    background: var(--ui-bg, #fff);
    overflow: hidden;
}

.bible-search-overlay.open {
    display: block;
}

.bible-search-overlay.bible-search-dark {
    background: var(--ui-bg-dark, #212121);
}

.bible-search-panel {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    height: 100dvh;
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: inherit;
    color: var(--ui-text, #1a1a1a);
}

.bible-search-overlay.bible-search-dark .bible-search-panel {
    color: var(--ui-text-dark, #ececec);
}

.bible-search-overlay.bible-search-dark #searchInput,
.bible-search-overlay.bible-search-dark #searchBookFilter,
.bible-search-overlay.bible-search-dark .bible-search-toolbar button,
.bible-search-overlay.bible-search-dark #searchLoadMore,
.bible-search-overlay.bible-search-dark .search-result-item {
    background: var(--ui-surface-dark, #2f2f2f);
    border-color: var(--ui-border-dark, #444);
    color: var(--ui-text-dark, #ececec);
}

.bible-search-overlay.bible-search-dark .bible-search-header,
.bible-search-overlay.bible-search-dark .bible-search-toolbar {
    border-color: var(--ui-border-dark, #444);
}

body.bible-search-open {
    overflow: hidden;
    touch-action: none;
}

body.bible-search-open .app-bottom-bar,
body.bible-search-open #ttsPanel,
body.bible-search-open .tts-panel {
    visibility: hidden !important;
    pointer-events: none !important;
}

.bible-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--ui-border, #e5e5e5);
    background: inherit;
    position: sticky;
    top: 0;
    z-index: 2;
}

.bible-search-header h2 {
    margin: 0;
    font-size: 1.1rem !important;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.bible-search-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem !important;
    flex-shrink: 0;
}

.bible-search-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ui-border, #e5e5e5);
    background: inherit;
}

.bible-search-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

#searchInput {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 12px 14px;
    font-size: 16px !important;
    border: 1px solid var(--ui-border, #d0d0d0);
    border-radius: 10px;
    background: var(--ui-surface, #f7f7f8);
    color: inherit;
}

.bible-search-toolbar button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--ui-border, #d0d0d0);
    border-radius: 10px;
    background: var(--ui-surface, #f7f7f8);
    color: inherit;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 14px !important;
    padding: 0;
}

#voiceSearchBtn.is-listening {
    background: #e53935;
    border-color: #c62828;
    color: #fff;
    animation: voice-search-pulse 1.1s ease-in-out infinite;
}

@keyframes voice-search-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.bible-search-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    width: 100%;
}

#searchBookFilter {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--ui-border, #d0d0d0);
    background: var(--ui-surface, #f7f7f8);
    color: inherit;
    font-size: 14px !important;
}

.bible-search-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: center;
}

.bible-search-filters label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px !important;
    cursor: pointer;
}

.bible-search-hint {
    margin: 10px 0 0;
    font-size: 12px !important;
    color: var(--ui-text-secondary, #6b6b6b);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

#searchStats {
    padding: 10px 16px;
    font-size: 13px !important;
    color: var(--ui-text-secondary, #6b6b6b);
    overflow-wrap: anywhere;
    background: inherit;
}

.bible-search-results {
    padding: 0 16px 16px;
    overflow: visible;
}

.search-result-item {
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--ui-border, #e5e5e5);
    border-left: 3px solid #0066cc;
    background: var(--ui-surface, #f7f7f8);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    overflow: hidden;
}

.search-result-item:active,
.search-result-item:hover {
    background: rgba(0, 102, 204, 0.08);
}

.result-reference {
    font-weight: 600;
    font-size: 14px !important;
    color: #0066cc;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.result-snippet {
    font-size: 14px !important;
    line-height: 1.5;
    color: inherit;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.bible-search-overlay img,
.bible-search-overlay picture,
.result-snippet img {
    display: none !important;
}

.highlight {
    background: rgba(255, 214, 0, 0.45);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
    font-weight: 600;
}

.no-results,
.search-loading {
    text-align: center;
    padding: 32px 16px;
    color: var(--ui-text-secondary, #6b6b6b);
    font-size: 14px !important;
}

#searchLoadMore {
    display: block;
    width: calc(100% - 32px);
    margin: 0 16px 24px;
    padding: 14px;
    border: 1px solid var(--ui-border, #d0d0d0);
    border-radius: 10px;
    background: var(--ui-surface, #f7f7f8);
    color: inherit;
    font-size: 14px !important;
    font-weight: 500;
    cursor: pointer;
}

#searchLoadMore[hidden] {
    display: none !important;
}

.bible-search-open-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px dashed rgba(0, 102, 204, 0.45);
    border-radius: 8px;
    background: rgba(0, 102, 204, 0.06);
    color: #0066cc;
    font-size: 13px !important;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.bible-search-open-btn:active {
    background: rgba(0, 102, 204, 0.12);
}
