/**
 * Meilisearch Search Styles for Aldersbach
 * Matches existing monastery aesthetic (dark header, gold accents)
 * Colors: #732822 (dark red), #a47934 (gold), #c7ad7c (light gold)
 */

/* ===== Quick Search in Header ===== */
.quick-search-wrapper {
    position: relative;
}

/* Position in top-bar (gold bar) - inline element */
.top-bar .quick-search-wrapper {
    position: relative;
    flex-shrink: 0;
}

#aldersbach-quick-search {
    width: 180px;
    padding: 8px 35px 8px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fff url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat right 10px center;
    background-size: 18px;
}

#aldersbach-quick-search:focus {
    width: 260px;
    border-color: #a47934;
    outline: none;
    box-shadow: 0 0 0 2px rgba(164, 121, 52, 0.2);
}

#aldersbach-quick-search::placeholder {
    color: #999;
}

/* Quick Search Dropdown */
#aldersbach-quick-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 320px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: none;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
}

#aldersbach-quick-search-results.visible {
    display: block;
}

.search-result-item {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.search-result-item:last-of-type {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
    background: #f5f5f5;
}

.search-result-title {
    font-weight: 600;
    color: #732822;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.3;
}

.search-result-title mark {
    background: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
    color: inherit;
}

.search-result-snippet {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-snippet mark {
    background: #fff3cd;
    padding: 0 2px;
    color: inherit;
}

.search-view-all {
    display: block;
    padding: 12px 16px;
    text-align: center;
    color: #a47934;
    font-weight: 500;
    text-decoration: none;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    border-radius: 0 0 8px 8px;
    font-size: 13px;
}

.search-view-all:hover {
    background: #f0f0f0;
    color: #732822;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.search-loading-quick {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ===== Full Search Page ===== */
.search-page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.search-page-form {
    margin-bottom: 30px;
}

#search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 18px;
    font-family: inherit;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #fff url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>') no-repeat right 18px center;
    background-size: 22px;
}

#search-input:focus {
    border-color: #a47934;
    outline: none;
    box-shadow: 0 0 0 3px rgba(164, 121, 52, 0.15);
}

#search-input::placeholder {
    color: #999;
}

#search-stats {
    margin-bottom: 20px;
    color: #666;
    font-size: 15px;
    padding: 0 5px;
}

#search-stats strong {
    color: #732822;
}

/* Search Results */
.search-result {
    padding: 20px 0;
    border-bottom: 1px solid #eee;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result h4 {
    margin: 0 0 8px 0;
    font-size: 1.2em;
    line-height: 1.3;
}

.search-result h4 a {
    color: #732822;
    text-decoration: none;
    transition: color 0.2s;
}

.search-result h4 a:hover {
    text-decoration: underline;
    color: #a47934;
}

.search-result h4 mark {
    background: #fff3cd;
    padding: 0 3px;
    border-radius: 2px;
    color: inherit;
}

.search-result-meta {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
}

.search-result-url {
    color: #a47934;
}

.search-result-category {
    margin-left: 15px;
    color: #666;
}

.search-result-category::before {
    content: "| ";
}

.search-result-content {
    color: #444;
    line-height: 1.6;
    margin: 0;
    font-size: 14px;
}

.search-result-content mark {
    background: #fff3cd;
    padding: 0 2px;
    color: inherit;
}

.search-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.search-error {
    color: #d32f2f;
    padding: 20px;
    background: #ffebee;
    border-radius: 8px;
    margin-top: 20px;
}

.search-no-results-full {
    text-align: center;
    padding: 40px;
    color: #666;
}

.search-no-results-full p {
    margin: 10px 0;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .quick-search-wrapper {
        margin-left: 10px;
    }

    #aldersbach-quick-search {
        width: 150px;
    }

    #aldersbach-quick-search:focus {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .quick-search-wrapper {
        display: none; /* Hide in mobile header */
    }

    #aldersbach-quick-search-results {
        min-width: 280px;
    }

    #search-input {
        font-size: 16px;
        padding: 12px 45px 12px 16px;
    }

    .search-result h4 {
        font-size: 1.1em;
    }

    .search-result-content {
        font-size: 13px;
    }
}

/* ===== Page Highlighting (destination pages) ===== */
.search-page-highlight {
    background: #fff3cd;
    padding: 1px 3px;
    border-radius: 2px;
    color: inherit;
    box-shadow: 0 0 0 1px rgba(164, 121, 52, 0.3);
}

/* Highlight Info Bar */
.search-highlight-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #732822 0%, #8b3029 100%);
    color: #fff;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

.search-highlight-bar .highlight-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-highlight-bar .highlight-info strong {
    background: #a47934;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
}

.search-highlight-bar .highlight-clear {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, border-color 0.2s;
}

.search-highlight-bar .highlight-clear:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Ensure content isn't hidden behind highlight bar */
body:has(.search-highlight-bar) {
    padding-bottom: 60px;
}

/* Fallback for browsers without :has() support */
@supports not selector(:has(*)) {
    .search-highlight-bar ~ * {
        margin-bottom: 60px;
    }
}

@media (max-width: 768px) {
    .search-highlight-bar {
        padding: 10px 15px;
        font-size: 13px;
    }

    .search-highlight-bar .highlight-clear {
        padding: 5px 10px;
        font-size: 12px;
    }
}
