/* ================================================================
   TEXTFINDER.CSS — Fully Responsive (Mobile-First Updates)
   ================================================================ */

.header-div {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1100;
}

/* ---------- Base reset / body ---------- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f9;
    color: #1a1a2e;
}

/* ---------- Page wrapper pushed below fixed header ---------- */
.container-fluid-finder {
    padding-top: 90px;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ================================================================
   MOBILE SIDEBAR TOGGLE BUTTON
   (only visible on mobile, fixed top-left below header)
   ================================================================ */
#mobileSidebarToggleBtn {
    display: none; /* hidden by default, shown via media query */
    position: fixed;
    top: 95px; /* just below the fixed header */
    left: 12px;
    width: 20%;
    z-index: 1040;
    background: #1C1847;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(28,24,71,0.25);
    transition: background 0.2s;
}

    #mobileSidebarToggleBtn:hover {
        background: #2d2b7a;
    }

/* Mobile overlay behind sidebar */
#mobileSidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}

    #mobileSidebarOverlay.active {
        display: block;
    }

/* ================================================================
   SEARCH PAGE — Landing (image 1 state)
   ================================================================ */
#textFinderSearch {
    width: 100%;
    overflow-y: auto;
}

#textFinderImage {
    position: relative;
    width: 100%;
}

    #textFinderImage img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0.75;
        display: block;
    }

    /* Search box overlay */
    #textFinderImage .position-absolute {
        width: 50% !important;
    }

.inputDivGroup {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

#search-input {
    height: 48px;
    border: none;
    font-size: 1rem;
    padding: 0 16px;
    background: rgba(255,255,255,0.97);
}

    #search-input:focus {
        outline: none;
        box-shadow: none;
    }

#search-button {
    background-color: #1C1847;
    font-weight: 700;
    color: #fff;
    height: 48px;
    border: none;
    padding: 0 24px;
    font-size: 1rem;
    transition: background 0.2s;
    white-space: nowrap;
}

    #search-button:hover {
        background-color: #2d2b7a;
    }

#match-word-checkbox-div {
    color: #e8e8ff;
    font-size: 0.78em;
    font-style: italic;
    margin-top: 6px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#suggestions-container {
    display: none;
    z-index: 1000;
    max-height: 220px;
    overflow-y: auto;
    top: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* ================================================================
   RESULTS PAGE LAYOUT
   ================================================================ */

/* ---- Sidebar ---- */
.side-bar {
    border-right: 1px solid #dde0e8;
    background: #fff;
    min-height: 100vh;
}

#sidebar-result-document {
    background: #fff;
    padding: 0 12px 16px;
}

/* Filter header strip */
.fa-filter {
    background: linear-gradient(135deg, #1C1847 60%, #2d2b7a);
    color: #fff;
    padding: 10px 14px;
    width: 100%;
    border-radius: 0px;
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    margin-top: 0 !important;
}

    .fa-filter span {
        margin-left: 10px;
        font-family: 'Segoe UI', sans-serif;
    }

/* Search bar inside sidebar */
#searchDiv {
    position: relative;
    margin-top: 14px;
}

#searchBar {
    width: 100%;
    padding: 9px 36px 9px 12px;
    font-size: 0.9rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

    #searchBar:focus {
        border-color: #1C1847;
    }

#clearBtn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: #aaa;
    line-height: 1;
    padding: 0 4px;
}

    #clearBtn:hover {
        color: #c0392b;
    }

/* Filter checkboxes */
#sidebar-result-document .mt-1 {
    margin-top: 12px !important;
}

.filtered-list-ul-textFinder {
    padding: 10px 8px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin: 8px 0 0;
    background: #fafbfd;
    list-style: none;
}

.filtered-list-textFinder {
    list-style: none;
    margin: 6px 0;
}

.filteredInputs, .filteredInputs_child {
    accent-color: #1C1847;
    margin-right: 8px;
    cursor: pointer;
}

.filtered-label-textFinder {
    font-size: 0.85rem;
    color: #222;
    cursor: pointer;
    font-weight: 500;
}

.nested-checkboxes {
    display: block;
    list-style-type: none;
    padding-left: 8px;
}

    .nested-checkboxes.collapsed {
        display: none;
    }

.toggle-container {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 0;
    border-radius: 4px;
    transition: background 0.15s;
}

    .toggle-container:hover {
        background: #f0f0f8;
    }

    .toggle-container i {
        font-size: 0.65rem;
        color: #888;
        margin-left: auto;
    }

.filtered-list-textFinder_child {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0 2px 10px;
}

.filtered-label-textFinder_child {
    font-size: 0.78rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.filtered-label-textFinder_subDoc {
    font-size: 0.82em;
}

/* ---- Main content area ---- */
#main-content {
    padding: 0 12px 40px;
    background: #f4f6f9;
}

/* Cloned search box at top of results */
.cloned-search-box {
    display: flex !important;
    justify-content: center;
    margin: 16px auto 8px;
    width: 60% !important;
    max-width: 680px;
}

    .cloned-search-box input {
        width: 100%;
    }

    .cloned-search-box #search-button {
        min-width: 90px;
    }

/* Searched word label */
#searchedWordDiv {
    margin: 6px 0 0 12px;
    color: #333;
    font-size: 0.9em;
}

/* Top bar: search word + note */
.mainViewContentDiv {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.mainViewContentInnerDiv {
    text-align: right;
}

    .mainViewContentInnerDiv span {
        font-size: 0.72rem;
        color: #8b0000;
        font-style: italic;
    }

    .mainViewContentInnerDiv a {
        padding-left: 10px;
    }

/* ---- Result cards (parent containers) ---- */
#results-container > .mb-4 {
    background: #fff;
    border: 1px solid #dde0ea !important;
    border-radius: 12px !important;
    padding: 24px 20px 20px !important;
    margin-top: 48px !important;
    box-shadow: 0 2px 12px rgba(28,24,71,0.07);
    transition: box-shadow 0.2s;
}

    #results-container > .mb-4:hover {
        box-shadow: 0 6px 24px rgba(28,24,71,0.13);
    }

    /* Parent doc heading badge */
    #results-container > .mb-4 h4:first-of-type {
        font-size: 1rem !important;
        font-weight: 700;
        background: #fff;
        border: 1px solid #c8cadc;
        border-radius: 6px;
        padding: 4px 14px !important;
        top: -18px !important;
        left: 16px !important;
        color: #1C1847;
        white-space: nowrap;
        max-width: 70%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* PDF count bubble */
    #results-container > .mb-4 h4:last-of-type {
        font-size: 0.7rem !important;
        width: 46px !important;
        height: 46px !important;
        top: -23px !important;
        right: 16px !important;
        border: 2px solid #1C1847 !important;
        color: #1C1847;
        font-weight: 700;
        background: #fff;
    }

/* Individual document item */
.list-group-item {
    background: #fafbfd;
    border: 1px solid #e8eaf0;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px !important;
    margin-top: 36px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Document header row */
.document-div {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 100%;
    margin-bottom: 6px;
    position: relative;
    gap: 0;
}

    .document-div::before {
        display: none;
    }

    .document-div .text-primary {
        order: 1;
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        display: block !important;
        flex-shrink: 0;
        max-width: 55%;
        width: auto !important;
        height: auto !important;
        background: #fff;
        padding: 2px 8px 2px 0 !important;
        margin: 0 !important;
        font-size: 0.92rem !important;
        text-align: left !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal !important;
        z-index: 1;
    }

    .document-div::after {
        content: '';
        order: 2;
        flex: 1;
        border-top: 1px dotted #bbb;
        margin: 0 10px;
        align-self: center;
    }

    .document-div > div {
        order: 3;
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        transform: none !important;
        display: flex !important;
        flex-shrink: 0;
        align-items: center !important;
        justify-content: flex-end !important;
        background: transparent !important;
        width: auto !important;
        max-width: 42%;
        z-index: 1;
    }

/* Show More / Additional lines buttons */
.btn-outline-danger {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
}

/* Show more docs button */
#results-container .d-grid button {
    background-color: #1C1847 !important;
    color: #fff;
    border-radius: 24px;
    font-size: 0.82rem;
    padding: 8px 20px;
    font-weight: 600;
    transition: background 0.2s;
    width: auto !important;
}

    #results-container .d-grid button:hover {
        background-color: #2d2b7a !important;
    }

/* Matching lines list */
ol {
    padding-left: 16px;
}

.list-group-item ol .list-group-item {
    background: #fff;
    border-left: none;
    border-radius: 6px;
    margin-top: 8px !important;
    cursor: pointer;
    font-size: 0.82rem !important;
    text-align: justify;
    transition: background 0.15s;
}

    .list-group-item ol .list-group-item:hover {
        background: #eef0fa;
    }

mark {
    background: #ffe066;
    color: #1a1a2e;
    padding: 0 2px;
    border-radius: 3px;
}

.read-more {
    color: #1C1847 !important;
    font-weight: 600;
}

/* No results image */
#no-result-found img {
    max-width: 320px;
    margin: 40px auto;
    display: block;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

    .pagination .btn {
        min-width: 36px;
        height: 36px;
        font-size: 0.82rem;
        border-radius: 6px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .pagination .btn.active {
            background: #1C1847;
            color: #fff;
            border-color: #1C1847;
        }

    .pagination .btn-secondary {
        background: #e8eaf0;
        color: #1C1847;
        border: 1px solid #c8cadc;
    }

        .pagination .btn-secondary:hover {
            background: #d0d3e8;
        }


.view-more-wrapper {
    display: flex;
    justify-content: center;
}

#view-more-btn {
    background-color: rgb(28, 24, 71);
    color: white;
    width: 50%;
    text-align: center;
}

/* ================================================================
   HIGHLIGHT NOTE
   ================================================================ */
#highlight-note {
    font-size: 0.7rem;
    color: #8b0000;
    font-style: italic;
    text-align: right;
}

/* ================================================================
   DESKTOP (≥ 992px) — unchanged from original
   ================================================================ */
@media (min-width: 992px) {
    .container-fluid-finder {
        padding-top: 90px;
    }

    #textFinderImage {
        height: calc(100vh - 15vh);
    }

        #textFinderImage img {
            height: 100%;
        }

        #textFinderImage .position-absolute {
            width: 42% !important;
        }

    .side-bar {
        position: sticky;
        top: 15vh;
        height: calc(100vh - 15vh);
        overflow-y: auto;
    }

    #main-content {
        margin-top: 0 !important;
    }

    .filtered-label-textFinder_child {
        max-width: 190px;
    }

    .cloned-search-box {
        width: 55% !important;
    }

    /* Hide mobile toggle button on desktop */
    #mobileSidebarToggleBtn {
        display: none !important;
    }
}

/* ================================================================
   TABLET (768px – 991px) — unchanged from original
   ================================================================ */
@media (min-width: 769px) and (max-width: 991px) {
    .container-fluid-finder {
        padding-top: 90px;
    }

    #textFinderImage {
        height: calc(100vh - 15vh);
    }

        #textFinderImage img {
            height: 100%;
        }

        #textFinderImage .position-absolute {
            width: 65% !important;
            bottom: 28% !important;
        }

    .side-bar {
        position: sticky;
        top: 15vh;
        height: calc(100vh - 15vh);
        overflow-y: auto;
        max-width: 260px;
    }

    #sidebar-result-document {
        padding: 12px 10px;
    }

    .filtered-label-textFinder_child {
        max-width: 140px;
    }

    .cloned-search-box {
        width: 75% !important;
    }

    #main-content {
        padding: 0 8px 32px;
    }

    /* Hide mobile toggle button on tablet */
    #mobileSidebarToggleBtn {
        display: none !important;
    }
}

/* ================================================================
   MOBILE (< 768px) — FULLY REWORKED
   ================================================================ */
@media (max-width: 768px) {

    /* --- Spacing --- */
    .container-fluid-finder {
        padding-top: 90px;
    }

    /* --- Show mobile toggle button --- */
    #mobileSidebarToggleBtn {
        margin-top: -35px;
    }

        #mobileSidebarToggleBtn.hidden {
            display: none !important;
        }

    #mobileSidebarCloseWrapper {
        margin-top: 8vh;
    }

    /* ---- SIDEBAR: off-canvas drawer on mobile ---- */
    .side-bar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 82vw;
        max-width: 320px;
        height: 100vh;
        min-height: unset;
        z-index: 1036;
        background: #fff;
        border-right: 2px solid #dde0e8;
        box-shadow: 4px 0 24px rgba(28,24,71,0.18);
        padding: 0 0 32px;
        overflow-y: auto;
        transform: translateX(-110%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    }

        /* When JS adds .open class, slide in */
        .side-bar.mobile-open {
            transform: translateX(0);
        }

    /* Sidebar close button (added by JS) */
    #mobileSidebarCloseBtn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: linear-gradient(135deg, #1C1847 60%, #2d2b7a);
        color: #fff;
        padding: 14px 16px;
        font-size: 0.95rem;
        font-weight: 700;
        border: none;
        width: 100%;
        cursor: pointer;
        letter-spacing: 0.03em;
    }

        #mobileSidebarCloseBtn .close-x {
            font-size: 1.2rem;
            font-weight: 400;
            opacity: 0.8;
        }

    /* Hide the original desktop filter header in mobile sidebar */
    .side-bar .d-none.d-md-block {
        display: none !important;
    }

    /* Sidebar inner padding */
    #sidebar-result-document {
        padding: 0 14px 20px;
    }

    #searchDiv {
        margin-top: 16px;
    }

    /* ---- MAIN CONTENT: full width on mobile ---- */
    #main-content {
        padding: 8px 10px 32px;
        margin-top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* When sidebar is open, main content stays (overlay covers it) */

    /* ---- LANDING: hide background image, show search inline ---- */
    #textFinderImage {
        padding-top: 48px; /* space for the filter toggle btn */
        padding-bottom: 16px;
        background: linear-gradient(135deg, #1C1847 0%, #2d2b7a 100%);
        min-height: 220px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        #textFinderImage img {
            display: none;
        }

        #textFinderImage .position-absolute {
            position: static !important;
            transform: none !important;
            width: 92% !important;
            margin: 0 auto;
        }

    #match-word-checkbox-div {
        color: rgba(255,255,255,0.8);
        font-size: 0.73rem;
        text-align: center;
        text-shadow: none;
    }

    #search-input {
        height: 44px;
        font-size: 0.92rem;
    }

    #search-button {
        height: 44px;
        padding: 0 16px;
        font-size: 0.88rem;
    }

    /* ---- Results top bar ---- */
    .cloned-search-box {
        width: 100% !important;
        margin: 12px 0 4px;
    }

    .mainViewContentDiv {
        flex-direction: column;
        gap: 4px;
    }

    .mainViewContentInnerDiv {
        text-align: left;
    }

    /* ---- Parent result cards ---- */
    #results-container > .mb-4 {
        padding: 20px 12px 14px !important;
        margin-top: 40px !important;
    }

        #results-container > .mb-4 h4:first-of-type {
            font-size: 0.82rem !important;
            max-width: 65%;
        }

        #results-container > .mb-4 h4:last-of-type {
            width: 40px !important;
            height: 40px !important;
            font-size: 0.65rem !important;
        }

    /* ---- Document list items ---- */
    .list-group-item {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 30px !important;
        padding: 10px 10px;
    }

    /* ---- Document header: stack vertically on very small screens ---- */
    .document-div {
        flex-wrap: wrap;
        gap: 6px;
    }

        .document-div::after {
            display: none; /* hide dotted line when wrapping */
        }

        .document-div .text-primary {
            max-width: 100%;
            font-size: 0.82rem !important;
            word-break: break-word;
            padding: 0 !important;
        }

        .document-div > div {
            max-width: 100%;
            order: 2;
            justify-content: flex-start !important;
        }

    /* ---- Matching lines ---- */
    .list-group-item ol .list-group-item {
        font-size: 0.6rem !important;
        padding: 8px 10px;
        text-align: justify;
    }

    /* ---- Show more buttons ---- */
    #results-container .d-grid button {
        font-size: 0.76rem;
        padding: 7px 14px;
        width: 100% !important;
    }

    .btn-outline-danger {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* ---- Pagination ---- */
    .pagination {
        justify-content: center;
    }

        .pagination .btn {
            min-width: 30px;
            height: 30px;
            font-size: 0.72rem;
        }

    /* ---- Sidebar filter labels ---- */
    .filtered-label-textFinder_child {
        max-width: calc(100vw - 100px);
        white-space: normal;
    }

    .filtered-list-ul-textFinder {
        max-height: none; /* allow full scroll within sidebar */
    }

    /* ---- No result image ---- */
    #no-result-found img {
        max-width: 220px;
    }

    .view-more-wrapper {
        width: 100%;
        padding: 0 12px; /* small side padding */
    }

    #view-more-btn {
        width: 100%;
    }
}

/* ================================================================
   EXTRA SMALL (< 480px)
   ================================================================ */
@media (max-width: 479px) {
    #search-input {
        height: 42px;
        font-size: 0.9rem;
    }

    #search-button {
        height: 42px;
        padding: 0 12px;
        font-size: 0.85rem;
    }

    .cloned-search-box #search-button {
        min-width: 64px;
    }

    #results-container > .mb-4 {
        padding: 18px 10px 12px !important;
    }

        #results-container > .mb-4 h4:first-of-type {
            max-width: 58%;
            font-size: 0.78rem !important;
        }

    .list-group-item ol .list-group-item {
        font-size: 0.6rem !important;
        padding: 8px 10px;
        text-align: justify;
    }

    #results-container .d-grid button {
        font-size: 0.76rem;
        padding: 7px 14px;
        width: 100% !important;
    }
}

/* ================================================================
   PDF CANVAS VIEW
   ================================================================ */
#textFinderCanvas {
    width: 100%;
    overflow-x: auto;
}


.hidden {
    display: none !important;
}
