/* Icon Trigger Button */
.live-search-icon-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.live-search-icon-trigger:hover {
    background-color: rgba(0, 0, 0, 0.05);
    opacity: 0.8;
}

/* Modal Overlay */
.live-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.live-search-modal.active {
    display: block;
}

.live-search-modal.visible {
    opacity: 1;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    max-width: 700px;
    margin: 80px auto 0;
    padding: 0 20px 40px;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    z-index: 1;
}

.live-search-modal.visible .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: -50px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    padding: 12px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    /* Ensure large enough touch target on mobile */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Modal Search Input */
.modal-search-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.modal-search-icon {
    position: absolute;
    left: 20px;
    color: #9ca3af;
    pointer-events: none;
    display: flex;
}

.modal-search-input {
    width: 100%;
    padding: 20px 60px;
    /* 16px prevents iOS auto-zoom on focus */
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
}

.modal-search-input::placeholder {
    color: #9ca3af;
}

.modal-search-loader {
    position: absolute;
    right: 20px;
    display: flex;
}

.modal-search-loader .spinner {
    animation: modal-rotate 1s linear infinite;
    color: #6b7280;
}

.modal-search-loader .spinner circle {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
    animation: modal-dash 1.5s ease-in-out infinite;
}

@keyframes modal-rotate {
    100% { transform: rotate(360deg); }
}

@keyframes modal-dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Modal Search Results */
.modal-search-results {
    max-height: 70vh;
    max-height: 70dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-results-container {
    padding: 0;
}

.modal-results-container:empty {
    display: none;
}

.modal-search-result-item {
    padding: 16px 20px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

.modal-search-result-item:last-child {
    border-bottom: none;
}

.modal-search-result-item:hover {
    background-color: #f9fafb;
}

.modal-result-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.modal-result-excerpt {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 6px;
}

.modal-result-meta {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-post-type-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bb-primary-color);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.modal-relevance-score {
    display: inline-block;
    padding: 2px 6px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 4px;
    font-size: 11px;
}

.modal-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

.modal-no-results svg {
    margin-bottom: 12px;
    color: #d1d5db;
}

.modal-highlight {
    background-color: #fef3c7;
    font-weight: 600;
    border-radius: 2px;
}

/*
 * Body scroll lock – simple overflow hidden only.
 * Touch-based scroll prevention is handled in JS to avoid
 * position:fixed issues on Samsung Internet / Android.
 */
body.search-modal-open {
    overflow: hidden;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin-top: 50px;
        padding: 0 12px 20px;
    }

    .modal-close {
        top: -48px;
        right: 12px;
    }

    .modal-search-input {
        padding: 16px 50px;
    }

    .modal-search-results {
        max-height: 70vh;
        max-height: 70dvh;
    }
}
