/* ============================================================
   SECTION 1: RESET & BASE
   ============================================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    max-width: 850px;
    margin: 40px auto;
    padding: 0 20px;
    color: #222;
    background-color: #fafafa;
    line-height: 1.5;
}

body.results {
    max-width: 100%;
    padding: 0 40px;
}

.divider {
    border: 0;
    border-top: 1px solid #e0e0e0;
    margin: 25px 0;
}

/* ============================================================
   SECTION 2: HEADER
   ============================================================ */
.header-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    width: 100%;
}

.header-title {
    font-size: 1.8rem;
    line-height: 1.2;
    margin: 0;
    padding-right: 30px;
    white-space: nowrap;
    border-right: 2px solid #e0e0e0;
    text-align: center;
}

.header-logo {
    flex-shrink: 0;
}

.header-logo img {
/*     max-width: 90px; */
/*     height: auto; */
    height: 100px;
    display: block;
    border-radius: 4px;
}

.title-link {
    text-decoration: none;
    color: #2C4F77;
    cursor: pointer;
}

.title-link:hover {
    color: #0066cc;
}

/* ============================================================
   SECTION 3: SEARCH FORM
   ============================================================ */
.search-form {
    background: #ffffff;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
}

.search-row {
    display: flex;
    gap: 12px;
}

.scope-dropdown {
    padding: 10px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fcfcfc;
    cursor: pointer;
}

input[type="text"] {
    flex-grow: 1;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    padding: 10px 20px;
    font-size: 0.95rem;
    background-color: #0066cc;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background-color: #0052a3;
}

.clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    font-size: 0.95rem;
    color: #555;
    background-color: #eeeeee;
    border: 1px solid #cccccc;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.15s ease;
}

.clear-btn:hover {
    background-color: #e0e0e0;
    color: #111;
    border-color: #999;
}

/* ============================================================
   SECTION 4: ACTION BAR (Flags + Note Toggle)
   ============================================================ */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0 5px 0;
    padding: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.lang-flags {
    display: flex;
    gap: 6px;
    padding: 0;
}

.flag-btn {
    display: inline-block;
    padding: 2px 6px;
    font-size: 14px;
    text-decoration: none;
    border-radius: 3px;
    background: #f0f0f0;
    transition: all 0.15s;
    opacity: 1;
    line-height: 1.2;
    border: 1px solid transparent;
}

.flag-btn:hover {
    background: #e0e0e0;
    text-decoration: none;
}

.flag-btn.active {
    background: #0066cc;
    opacity: 1;
    border-color: #0066cc;
}

.flag-btn.active:hover {
    background: #0052a3;
    border-color: #0052a3;
}

.note-toggle {
    display: flex;
    align-items: center;
}

.note-btn {
    display: inline-block;
    padding: 2px 10px;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    border-radius: 3px;
    background: #0066cc;
    color: #ffffff;
    transition: all 0.15s;
    line-height: 1.8;
    border: 1px solid transparent;
    cursor: pointer;
}

.note-btn:hover {
    background: #0052a3;
    text-decoration: none;
    color: #ffffff;
}

.note-btn.active {
    background: white;
    color: #0066cc;
    border-color: red;
}

.note-btn.active:hover {
    background: #e0e0e0;
    color: #333;
}

/* ============================================================
   SECTION 5: RESULTS - SIDE BY SIDE
   ============================================================ */
.search-status {
    font-size: 0.9rem;
    color: #666;
}

.results-container {
    margin-top: 20px;
}

.result-item {
    background: #ffffff;
    padding: 16px 20px;
    margin-bottom: 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

.result-num {
    font-weight: bold;
    color: #0066cc;
    font-family: monospace;
    font-size: 1.1rem;
    flex-shrink: 0;
    min-width: 60px;
}

.result-text {
    color: #2d3748;
    font-size: 1.05rem;
    line-height: 1.8;
    text-align: justify;
    flex: 1;
}

.parallel-text {
    border-left: 1px dashed #e0e0e0;
    padding-left: 16px;
    margin-left: 4px;
    flex: 1;
}

/* ============================================================
   SECTION 6: FOOTNOTES
   ============================================================ */
.nota {
    color: #555;
    font-size: 0.9rem;
    display: inline;
}

.nota::before {
    content: "［";
}

.nota::after {
    content: "］";
}

/* Notes hidden by default */
.notes-hidden .nota {
    display: none !important;
}

/* Notes visible when toggled */
.notes-visible .nota {
    display: inline !important;
}

/* Superscript callout when notes are hidden */
.fn-callout {
    color: #0066cc;
    font-weight: bold;
    font-size: 0.75rem;
    padding: 0 1px;
}

/* ============================================================
   SECTION 7: PAGINATION
   ============================================================ */
.pagination-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    padding: 15px;
}

.nav-btn {
    padding: 8px 20px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
}

.nav-btn:hover {
    background: #0056b3;
    color: white;
    text-decoration: none;
}

.page-info {
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
}

/* ============================================================
   SECTION 8: HOME VIEW - HIERARCHICAL TREE (index.php)
   ============================================================ */
.section-title {
    font-size: 1.4rem;
    color: #2C4F77;
    margin-top: 30px;
    margin-bottom: 5px;
}

.section-subtitle {
    font-size: 0.95rem;
    color: #2C4F77;
    margin-top: 0;
    margin-bottom: 20px;
}

.index-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 20px;
    padding: 10px;
    max-width: 850px;
    margin-left: 0;
    margin-right: auto;
}

.tree-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    padding: 2px 12px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid transparent;
    transition: background-color 0.15s ease;
}

.tree-item:hover {
    background-color: #f0f6fc;
    border-color: #d0e1fd;
}

.tree-range {
    font-size: 0.8rem;
    color: #444;
    background: #eef2f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    white-space: nowrap;
}

.tree-item[data-type="pars"] {
    font-size: 1.35rem;
    font-weight: bold;
    border-bottom: 1px dashed #e0e0e0;
    margin-top: 15px;
    margin-left: 0px;
}
.tree-item[data-type="pars"] .tree-name {
    color: brown;
}

.tree-item[data-type="sectio"] {
    font-size: 1.15rem;
    font-weight: bold;
    margin-left: 15px;
}
.tree-item[data-type="sectio"] .tree-name {
    color: steelblue;
}

.tree-item[data-type="caput"] {
    font-size: 1.05rem;
    font-weight: bold;
    margin-left: 30px;
}
.tree-item[data-type="caput"] .tree-name {
    color: #222222;
}

.tree-item[data-type="sub"] {
    font-size: 0.95rem;
    margin-left: 45px;
}
.tree-item[data-type="sub"] .tree-name {
    color: darkgreen;
}

.tree-item[data-type="minor"] {
    font-size: 0.9rem;
    margin-left: 60px;
}
.tree-item[data-type="minor"] .tree-name {
    color: navy;
}

.tree-item[data-type="compendium"],
.tree-item[data-type="adnotatio"] {
    font-size: 0.95rem;
    font-style: italic;
    margin-left: 45px;
}
.tree-item[data-type="compendium"] .tree-name,
.tree-item[data-type="adnotatio"] .tree-name {
    color: maroon;
}
.tree-item[data-type="compendium"] .tree-range {
    background-color: #fcebe8;
    color: maroon;
}

.missing-index-notice {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 40px;
    background: #f0f0f0;
    border-radius: 6px;
}

/* ============================================================
   SECTION 9: NO RESULTS
   ============================================================ */
.no-results-box {
    padding: 20px;
    background-color: #fff1f0;
    border-left: 4px solid #f5222d;
    color: #a8071a;
    border-radius: 0 4px 4px 0;
    font-style: italic;
}

/* ============================================================
   SECTION 10: FOOTER
   ============================================================ */
.footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid #e0e0e0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: #6c757d;
}

.footer-info {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-copyright {
    font-weight: normal;
}

/* ============================================================
   SECTION 11: RESPONSIVE (MOBILE)
   ============================================================ */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    body.results {
        padding: 10px;
    }

    .header-container {
        flex-direction: column;
        gap: 15px;
    }

    .header-title {
        font-size: 1.4rem;
        padding-right: 0;
        border-right: none;
        white-space: normal;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-row input[type="text"] {
        min-width: unset;
    }

    .result-item {
        flex-direction: column;
        gap: 8px;
        padding: 12px 15px;
    }

    .result-num {
        min-width: unset;
    }

    .parallel-text {
        border-left: none;
        border-top: 1px dashed #e0e0e0;
        padding-left: 0;
        padding-top: 12px;
        margin-left: 0;
        margin-top: 4px;
    }

    .action-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .flag-btn {
        font-size: 12px;
        padding: 2px 5px;
    }

    .note-btn {
        font-size: 12px;
        padding: 2px 8px;
    }

    .index-tree {
        max-width: 100%;
        padding: 5px;
    }

    .tree-item {
        padding: 2px 8px;
        font-size: 0.9rem;
    }

    .tree-item[data-type="pars"] {
        font-size: 1.1rem;
        margin-top: 10px;
    }
    .tree-item[data-type="sectio"] {
        font-size: 1rem;
        margin-left: 10px;
    }
    .tree-item[data-type="caput"] {
        font-size: 0.95rem;
        margin-left: 20px;
    }
    .tree-item[data-type="sub"] {
        font-size: 0.9rem;
        margin-left: 30px;
    }
    .tree-item[data-type="minor"] {
        font-size: 0.85rem;
        margin-left: 40px;
    }
    .tree-item[data-type="compendium"],
    .tree-item[data-type="adnotatio"] {
        font-size: 0.9rem;
        margin-left: 30px;
    }

    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .footer-info {
        justify-content: center;
    }
}
