/**
 * OD Search - Frontend Styles
 */

/* Search Container */
.od-live-search {
    position: relative;
    width: 100%;
    max-width: 278px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Search Input Wrapper */
.od-search-input-wrapper {
    position: relative;
    width: 100%;
}

/* Search Input */
.od-search-input {
    width: 100%;
    padding: 6px 36px 6px 10px;
    font-size: 18px;
    line-height: 1.5;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.od-search-input:focus {
    border-color: #08a4ef;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.od-search-input::placeholder {
    color: #999;
}

/* Loading Spinner */
.od-search-spinner {
    display: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: od-search-spin 0.8s linear infinite;
}

.od-search-spinner.visible {
    display: block;
}

@keyframes od-search-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Results Container */
.od-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 99999;
}

/* Individual Result */
.od-search-result {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #eee;
    transition: background-color 0.15s ease;
}

.od-search-result:last-child {
    border-bottom: none;
}

.od-search-result:hover,
.od-search-result-highlighted {
    background-color: #f5f5f5;
}

.od-search-result:focus {
    outline: none;
    background-color: #f0f0f0;
}

/* Result Type Badge */
.od-result-type {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    border-radius: 3px;
    margin-bottom: 4px;
}

/* Result Title */
.od-result-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.3;
}

.od-search-result:hover .od-result-title {
    color: #0073aa;
}

/* Result Excerpt */
.od-result-excerpt {
    display: block;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Highlighted Match */
.od-search-results mark {
    background-color: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* No Results */
.od-search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Error Message */
.od-search-error {
    padding: 16px;
    text-align: center;
    color: #dc3545;
    font-size: 14px;
}

/* Screen Reader Only */
.od-search-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .od-live-search {
        max-width: 100%;
    }
    
    .od-search-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .od-search-results {
        max-height: 300px;
    }
    
    .od-search-result {
        padding: 10px 14px;
    }
    
    .od-result-title {
        font-size: 14px;
    }
    
    .od-result-excerpt {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .od-search-input {
        background: #2d2d2d;
        border-color: #41b903;
        color: #ffffff;
    }
    
    .od-search-input::placeholder {
        color: #888;
    }
    
    .od-search-results {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .od-search-result {
        border-bottom-color: #444;
    }
    
    .od-search-result:hover,
    .od-search-result-highlighted {
        background-color: #3a3a3a;
    }
    
    .od-result-title {
        color: #eee;
    }
    
    .od-result-excerpt {
        color: #aaa;
    }
    
    .od-search-results mark {
        background-color: #665500;
    }
}

/* Scrollbar Styling */
.od-search-results::-webkit-scrollbar {
    width: 8px;
}

.od-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.od-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.od-search-results::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
