/* Noske search result styling */
.search-result {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* KWIC styling - single column layout */
.kwic-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
}

.kwic-container:hover {
    background-color: #f8f9fa;
}

.kwic-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem;
    width: 100%;
    font-size: 1rem;
    line-height: 1.5;
}

.context-left {
    color: #6c757d;
    text-align: right;
    flex: 0 1 auto;
}

.keyword {
    background-color: #fff3cd;
    padding: 2px 6px;
    border-radius: 4px;
    color: #856404;
    font-weight: bold;
    font-size: 1.1em;
    flex: 0 0 auto;
}

.context-right {
    color: #6c757d;
    text-align: left;
    flex: 0 1 auto;
}

/* Override table styling for better KWIC display */
#hitsbox table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

#hitsbox table td {
    padding: 0.5rem;
    border: none;
    vertical-align: top;
}

#hitsbox table tr {
    border-bottom: 1px solid #dee2e6;
}

#hitsbox table tr:last-child {
    border-bottom: none;
}

/* Make the table look more like a list */
#hitsbox .table-auto {
    display: block;
}

#hitsbox .table-auto tbody {
    display: block;
}

#hitsbox .table-auto tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
}

#hitsbox .table-auto tr:hover {
    background-color: #f8f9fa;
}

#hitsbox .table-auto td {
    display: inline;
    padding: 0;
    border: none;
}

/* Hide table headers for better KWIC display */
#hitsbox .table-auto thead {
    display: none;
}

#hitsbox .table-auto th {
    display: none;
}

.list-group-item {
    border: 1px solid #dee2e6;
    margin-bottom: 0.5rem;
    border-radius: 0.375rem;
}

.list-group-item:hover {
    background-color: #f8f9fa;
}

#noske-hits .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Fix Typesense hits layout - override Algolia grid styles */
#typesense-search-container .ais-Hits-list {
    display: block !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    grid-gap: 0 !important;
    gap: 0 !important;
    columns: auto !important;
    column-count: 1 !important;
}

#typesense-search-container .ais-Hits-item {
    display: list-item !important;
    list-style: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 1.5rem !important;
    padding: 1rem !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 0.375rem !important;
    background-color: #fff !important;
    float: none !important;
    flex: none !important;
    grid-column: auto !important;
    grid-row: auto !important;
    break-inside: avoid !important;
}

#typesense-search-container .ais-Hits-item:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    transition: box-shadow 0.15s ease-in-out !important;
}

/* Ensure the hits container itself is not using grid or columns */
#typesense-search-container #hits {
    display: block !important;
    columns: none !important;
    column-count: 1 !important;
}

/* Override any potential CSS Grid or Flexbox Grid styles */
#typesense-search-container .ais-Hits {
    display: block !important;
}

/* Search input styling */
#noske-search input {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#noske-search input:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Results container */
#hitsbox {
    min-height: 300px;
    margin-top: 1rem;
}

/* KWIC (Keyword in Context) styling */
.kwic-container {
    margin: 0.5rem 0;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
}

.kwic-container:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transition: all 0.15s ease-in-out;
}

/* Left and right context styling */
.kwic-container .text-muted {
    color: #6c757d !important;
}

/* Keyword highlighting */
.kwic-container .fw-bold.text-primary {
    background-color: #fff3cd;
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    border: 1px solid #ffecb5;
    font-weight: 600 !important;
    color: #664d03 !important;
}

/* Pagination styling */
#noske-pagination-test .pagination {
    justify-content: center;
    margin-top: 2rem;
}

#noske-pagination-test .page-link {
    color: #0d6efd;
    border-color: #dee2e6;
}

#noske-pagination-test .page-link:hover {
    color: #0a58ca;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

#noske-pagination-test .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

/* Stats container */
#noske-stats {
    margin-top: 1rem;
}

#noske-stats .alert {
    margin-bottom: 0;
}

/* Search toggle buttons */
.btn-group .btn {
    position: relative;
    flex: 1 1 auto;
}

.btn-group .btn:focus {
    z-index: 3;
}

/* Loading spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Error and info alerts */
.alert {
    border-radius: 0.375rem;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffecb5;
    color: #664d03;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c2c7;
    color: #721c24;
}

/* Code examples in help text */
.alert code {
    color: inherit;
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

/* Button styling for search and clear */
.noske-search-btn,
.noske-clear-btn {
    transition: all 0.15s ease-in-out;
}

.noske-search-btn:hover,
.noske-clear-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #noske-search-container .col-md-4,
    #noske-search-container .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.25rem;
    }

    .btn-group .btn:last-child {
        margin-bottom: 0;
    }
}

/* Table styling for results */
#hitsbox table {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    border-collapse: collapse;
}

#hitsbox table th,
#hitsbox table td {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
}

#hitsbox table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

#hitsbox table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Search engine toggle tooltip */
[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* Collapsible card headers */
.card-header[data-bs-toggle="collapse"] {
    cursor: pointer;
    user-select: none;
}

.card-header[data-bs-toggle="collapse"]:hover {
    background-color: #f8f9fa;
}