/* General Body and Typography */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background: #fdfcf8;
    color: #333;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header and Navigation */
header {
    background: #197689;
    color: #fff;
    padding: 1.5em 1em;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

h1 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-weight: 300;
    font-size: 2.2em;
}

nav.top-nav {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 0.9em;
}

nav.top-nav a {
    color: #fff;
    text-decoration: none;
    padding: 0.4em 0.8em;
    border-radius: 4px;
    transition: background-color 0.2s;
}

nav.top-nav a:hover,
nav.top-nav a.active-nav {
    background-color: rgba(255, 255, 255, 0.15);
    text-decoration: underline;
}

/* Search Form Elements */
#search-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    margin-bottom: 1em;
}

.main-search-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    width: 100%;
    max-width: 800px;
}

#query,
#category-filter-select {
    padding: 0.6em 0.8em;
    border-radius: 6px;
    border: 1px solid #ccc;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 42px;
    box-sizing: border-box;
    font-size: 1em;
}

#query:focus,
#category-filter-select:focus {
    border-color: #e34926;
    box-shadow: 0 0 0 3px rgba(227, 73, 38, 0.25);
    outline: none;
}

#query {
    flex-grow: 1;
    min-width: 250px;
}

#category-filter-select {
    flex-shrink: 0;
    width: 200px;
    cursor: pointer;
}

#search-form button[type="submit"],
#clear-button {
    color: #fff;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    padding: 0.6em 1.2em;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    height: 42px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#search-form button[type="submit"] {
    background: #e34926;
}

#search-form button[type="submit"]:hover {
    background: #c13715;
}

#clear-button {
    background: #6c757d;
    font-weight: normal;
}

#clear-button:hover {
    background: #5a6268;
}

#search-form button:active {
    transform: translateY(1px);
}

button:focus-visible {
    outline: 2px solid #197689;
    outline-offset: 2px;
}


/* Stats and Results Info */
#stats {
    margin-top: 1em;
    font-size: 0.9em;
    color: #f0f0f0;
    min-height: 1.2em;
    line-height: 1.4;
}

#stats strong {
    font-weight: 600;
}

.stats-button {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.2em 0.6em;
    font-size: 0.9em;
    cursor: pointer;
    margin-left: 0.5em;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
}

.stats-button:hover:not(:disabled) {
    background: #5a6268;
}

.stats-button:disabled {
    background: #aaa;
    cursor: not-allowed;
}

/* Main Content Area */
main {
    margin: 2em auto;
    width: 90vw;
    max-width: 1200px;
    padding: 0;
    transition: all 0.3s ease-in-out;
    flex-grow: 1;
}

main.search-conducted {
    border: 2px solid #197689;
    padding: 1.5em;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(25, 118, 137, 0.1);
}

/* KWIC Headings */
.kwic-headings {
    display: grid;
    grid-template-columns: 1fr auto 1fr 140px;
    column-gap: 1.3em;
    padding: 0 1em 0.5em 1em;
    border-bottom: 2px solid #ddd;
    margin-bottom: 1em;
    font-family: sans-serif;
}

.kwic-headings>div {
    font-weight: bold;
    font-size: 0.8em;
    text-transform: uppercase;
}

.kwic-headings .lctx-col {
    text-align: right;
    color: #197689;
}

.kwic-headings .kw-col {
    text-align: center;
    color: #e34926;
}

.kwic-headings .rctx-col {
    text-align: left;
    color: #197689;
}

/* KWIC Results Display */
.concordance {
    display: grid;
    grid-template-columns: 1fr auto 1fr 140px;
    align-items: baseline;
    background: #fff;
    margin-bottom: 0.5em;
    padding: 0.8em 1em;
    column-gap: 1.3em;
    transition: background-color 0.2s;
    border-bottom: 1px solid #fdd9cf;
}

.concordance[data-wid]:not([data-wid=""]):hover {
    background-color: #e8f1f3;
}

#hits .concordance:last-child {
    border-bottom: none;
}

.no-hits-message {
    grid-column: 1 / -1;
    text-align: center;
    color: #666;
    font-style: italic;
    background-color: transparent;
}

.left,
.right {
    font-size: 0.95em;
    color: #444;
    word-break: break-word;
    overflow: hidden;
    line-height: 1.4;
}

.left {
    text-align: right;
}

.right {
    text-align: left;
}

.kw-col {
    text-align: center;
}

/* --- STYLING FOR CORRECTIONS (DEL/INS) --- */
.del {
    color: #c0392b;
    background-color: #ffe4dc;
    text-decoration: line-through;
    text-decoration-color: #c0392b;
    border-radius: 2px;
    padding: 0.05em 0.1em;
}

.ins {
    color: #135e6d;
    background-color: #d4eaf0;
    text-decoration: none;
    font-weight: 600;
    border-radius: 2px;
    padding: 0.05em 0.1em;
}

/* Base style for central keywords */
.kw-col .kw {
    background-color: #dcedc8;
    padding: 0.1em 0.4em;
    border-radius: 4px;
    border: 2px solid transparent;
}

/* Style for a DELETED central keyword */
.kw-col .kw.del {
    text-decoration: line-through;
    text-decoration-color: #c0392b;
    text-decoration-thickness: 1.5px;
    background-color: #ffe4dc;
}

/* Style for an INSERTED central keyword */
.kw-col .kw.ins {
    border: 2px solid #135e6d;
    background-color: #d4eaf0;
}


/* Metadata Column (Category, Doc ID) */
.meta-col {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
    justify-content: center;
    align-items: flex-start;
}

.label {
    font-size: 0.8em;
    color: #fff;
    background: #e34926;
    border-radius: 10px;
    padding: 0.1em 0.6em;
    overflow-wrap: break-word;
}

.docid-hit {
    font-size: 0.75em;
    color: #888;
    white-space: nowrap;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1em;
    box-sizing: border-box;
}

.modal-content {
    background: #fff;
    padding: 1.5em 2em;
    border-radius: 8px;
    min-width: 300px;
    width: 80vw;
    max-width: 750px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

#modal-body h4,
.static-content h2 {
    margin-top: 0;
    color: #197689;
}

#modal-body h5 {
    margin-top: 1.2em;
    margin-bottom: 0.5em;
    color: #197689;
    font-weight: 600;
}

.stats-list,
.static-content ul {
    list-style-type: none;
    padding-left: 0;
}

.stats-list li,
.static-content li {
    padding: 2px 0;
}

.meta-group {
    margin-bottom: 1em;
}

.meta-group ul {
    list-style-type: none;
    padding-left: 1em;
    font-size: 0.95em;
}

.modal-content div,
.modal-content p,
.modal-kwic-preview,
.modal-full-paragraph,
.modal-meta {
    font-size: 1em;
    color: #333;
    line-height: 1.7;
}

.modal-content hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 1.2em 0;
}

.modal-full-paragraph {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 0.8em;
    border-radius: 4px;
}

.close {
    position: absolute;
    right: 1em;
    top: 0.8em;
    color: #aaa;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 0.5;
    padding: .4em .6em;
    border-radius: 50%;
}

.close:hover {
    color: #e34926;
}

/* Pagination Controls */
#pagination-controls {
    text-align: center;
    margin-top: 2em;
    margin-bottom: 1em;
}

#pagination-controls button {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.5em 0.8em;
    margin: 0 0.2em;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.9em;
}

#pagination-controls button:hover:not(:disabled) {
    background-color: #e0e0e0;
}

#pagination-controls button:disabled,
#pagination-controls button.current-page {
    background-color: #197689;
    color: white;
    border-color: #197689;
    cursor: default;
}

#pagination-controls .pagination-ellipsis {
    padding: 0 0.5em;
    color: #777;
}

/* CUSTOM FOOTER STYLES */
#custom-footer {
    background-color: #f5f7f8;
    color: #333;
    padding: 3em 1em;
    border-top: 3px solid #e34926;
    font-size: 0.9em;
}

.footer-grid {
    display: flex;
    justify-content: center;
    gap: 2em;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.footer-column {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    text-align: center;
    padding: 1em;
}

.sponsor-logo {
    margin-bottom: 1.5em;
}

.sponsor-logo img {
    max-height: 80px;
    width: auto;
    max-width: 100%;
}

.social-icons {
    margin-bottom: 1.5em;
}

.social-icons a {
    display: inline-block;
    margin: 0 0.5em;
    width: 28px;
    height: 28px;
}

.social-icons svg {
    fill: #888;
    transition: fill 0.2s ease-in-out;
}

.social-icons a:hover svg {
    fill: #e34926;
}

.contact-info {
    line-height: 1.5;
    color: #555;
}

.contact-info p {
    margin: 0.2em 0;
}

.contact-info a {
    color: #197689;
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

/* Styles for the help text popup */
.static-content ul {
    padding-left: 20px;
}

.static-content code {
    background-color: #eee;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: "Courier New", monospace;
}

.del-example {
    color: #c0392b;
    background-color: #ffe4dc;
    text-decoration: line-through;
}

.ins-example {
    color: #135e6d;
    background-color: #d4eaf0;
    font-weight: 600;
}

.kw-del-example {
    text-decoration: line-through;
    text-decoration-color: #c0392b;
    padding: 0.1em 0.2em;
    background-color: #dcedc8;
    border-radius: 4px;
}

.kw-ins-example {
    border: 2px solid #135e6d;
    padding: 0.1em 0.2em;
    border-radius: 4px;
    background-color: #dcedc8;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .footer-grid {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 600px) {

    .concordance,
    .kwic-headings {
        grid-template-columns: 1fr;
        grid-row-gap: 4px;
    }

    .left,
    .right,
    .kw-col,
    .kwic-headings .lctx-col,
    .kwic-headings .rctx-col,
    .kwic-headings .kw-col {
        text-align: left;
    }

    .meta-col,
    .kwic-headings .meta-col {
        flex-direction: row;
        gap: 0.6em;
        align-items: center;
        margin-top: 0.5em;
    }
}