@import url('b1-listening-test.css');

body.reading-test-mode.b1-reading-mode {
    margin: 0;
    background: #fff;
    overflow: hidden;
    height: 100vh;
}

body.reading-test-mode.b1-reading-mode .reading-test-wrap {
    padding: 0;
    max-width: none;
    height: 100vh;
    overflow: hidden;
}

.b1-reading-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    background: #fff;
    color: #1a2b3c;
    font-family: Arial, Helvetica, sans-serif;
}

.b1-reading-page .b1-main {
    background: #fff;
    scrollbar-color: #41b6e6 #f5f5f5;
}

.b1-reading-page .b1-main::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.b1-reading-page .b1-main::-webkit-scrollbar-thumb {
    border-color: #f5f5f5;
}

/* Footer palette: chỉ hiện số câu của Part đang chọn */
.b1-reading-page .b1-palette {
    gap: 0.35rem;
}

.b1-reading-page .b1-palette-part {
    padding-right: 0.35rem;
    border-right: 1px solid #e8eef2;
}

.b1-reading-page .b1-palette-part:last-child {
    border-right: 0;
    padding-right: 0;
}

.b1-reading-page .b1-palette-part.is-active {
    gap: 0.4rem;
    padding-right: 0.65rem;
}

.b1-reading-page .b1-palette-part__tab {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0 0.45rem;
    min-height: 30px;
}

.b1-reading-page .b1-palette-part.is-active .b1-palette-part__tab {
    background: #eef6fb;
    border-color: #41b6e6;
    color: #0077a8;
}

.b1-reading-page .b1-palette-part__nums {
    margin-left: 0.1rem;
}

/* Bootstrap modals — global style.css sets .modal z-index:999, below backdrop (1050) */
body.reading-test-mode.b1-reading-mode .modal-backdrop {
    z-index: 10040 !important;
}

body.reading-test-mode.b1-reading-mode .modal {
    z-index: 10050 !important;
    background: transparent;
}

body.reading-test-mode.b1-reading-mode .modal.show {
    display: block !important;
}

body.reading-test-mode.b1-reading-mode .modal-dialog {
    pointer-events: auto;
}

.b1-reading-page .b1-screen-host {
    max-width: 960px;
}

.b1-reading-page .b1-screen-host.b1-screen-host--wide {
    max-width: 1240px;
}

.b1-sign-notice {
    padding: 1.25rem 1rem;
    background: linear-gradient(180deg, #fffef8 0%, #fff9e6 100%);
    border: 2px solid #e8d48a;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    min-height: 180px;
}

.b1-sign-notice__label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #8b6914;
    margin-bottom: 0.5rem;
}

.b1-sign-notice__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a2b3c;
    line-height: 1.45;
    margin-bottom: 0.65rem;
}

.b1-sign-notice__hint {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
}

.b1-match-hint {
    font-size: 0.82rem;
    color: #475569;
    background: #fff;
    border: 1px solid #e8eef2;
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    margin: 0 0 0.65rem;
    line-height: 1.4;
}

.b1-reading-page.is-picking-token .b1-match-gap.is-pickable {
    border-color: #0077a8;
    background: #fff8dc;
    animation: b1-gap-pulse 1.2s ease-in-out infinite;
}

@keyframes b1-gap-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(65, 182, 230, 0.35); }
    50% { box-shadow: 0 0 0 4px rgba(65, 182, 230, 0.2); }
}

.b1-token__label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.b1-cloze-select option[value=""] {
    color: #0077a8;
    font-weight: 700;
}

.b1-reading-page .b1-note-passage {
    line-height: 2;
    font-size: 1rem;
}

.b1-reading-page .b1-note-passage .b1-gap-input {
    min-width: 120px;
    max-width: 200px;
}

.b1-sign-layout {
    display: grid;
    grid-template-columns: minmax(200px, 320px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

.b1-sign-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #d9e8f2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.b1-reading-page .b1-screen-host.b1-screen-host--split {
    max-width: none;
    width: 100%;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    min-height: 0;
}

.b1-reading-page .b1-rubric.b1-rubric--wide {
    max-width: none;
}

.b1-split-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.b1-split-view--part3 {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    height: calc(100vh - 13.5rem);
    max-height: calc(100vh - 13.5rem);
    min-height: 0;
    border: 1px solid #d9e8f2;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.b1-reading-page.b1-reading-page--part3-split .b1-main {
    overflow: hidden;
    padding-bottom: 1rem;
}

.b1-split-view--part3 .b1-split-view__passage,
.b1-split-view--part3 .b1-split-view__questions {
    flex: 1 1 calc(50% - 5px);
    width: calc(50% - 5px);
    max-width: calc(50% - 5px);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.b1-split-view--part3 .b1-split-view__passage {
    background: #fff;
}

.b1-split-view--part3 .b1-split-view__questions {
    padding: 0;
}

.b1-split-view__divider {
    flex: 0 0 10px;
    width: 10px;
    align-self: stretch;
    background: linear-gradient(180deg, #dce8f0 0%, #41b6e6 45%, #0077a8 55%, #dce8f0 100%);
    position: relative;
    z-index: 2;
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.5), inset -1px 0 0 rgba(0, 95, 135, 0.15);
}

.b1-split-view__divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 56px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(0, 119, 168, 0.2);
}

.b1-split-view__col-head {
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #0077a8;
    padding: 0.65rem 1rem;
    background: #fff;
    border-bottom: 1px solid #d9e8f2;
}

.b1-split-view--part3 .b1-split-view__col-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem 1.15rem;
    scrollbar-width: thin;
    scrollbar-color: #41b6e6 #f5f5f5;
    scrollbar-gutter: stable;
}

.b1-split-view--part3 .b1-split-view__col-body::-webkit-scrollbar {
    width: 11px;
}

.b1-split-view--part3 .b1-split-view__col-body::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 999px;
    margin: 4px 0;
}

.b1-split-view--part3 .b1-split-view__col-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #41b6e6 0%, #0077a8 100%);
    border-radius: 999px;
    border: 2px solid #f5f5f5;
}

.b1-split-view--part3 .b1-split-view__col-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #2a9fd4 0%, #005f87 100%);
}

.b1-split-view__col-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.15rem;
}

.b1-split-view__passage {
    max-height: min(65vh, 560px);
    overflow-y: auto;
    padding: 1rem;
    background: #fff;
    border: 1px solid #d9e8f2;
    border-radius: 8px;
    font-size: 0.98rem;
    line-height: 1.55;
    min-width: 0;
}

.b1-split-view--part3 .b1-split-view__passage {
    max-height: none;
    overflow: hidden;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.b1-split-view__passage h2 {
    font-size: 1.05rem;
    margin: 0 0 0.75rem;
}

.b1-split-view__passage p {
    margin: 0 0 0.85rem;
}

.b1-split-view__questions {
    max-height: min(65vh, 560px);
    overflow-y: auto;
    min-width: 0;
}

.b1-split-view--part3 .b1-split-view__questions {
    max-height: none;
    overflow: hidden;
    padding: 0;
}

.b1-match-layout {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 320px);
    gap: 1rem;
    align-items: start;
}

.b1-match-passage {
    line-height: 1.65;
    font-size: 0.98rem;
}

.b1-match-passage p {
    margin: 0 0 0.85rem;
}

.b1-match-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    min-height: 1.75rem;
    padding: 0.1rem 0.45rem;
    margin: 0 0.15rem;
    border: 2px dashed #41b6e6;
    border-radius: 4px;
    background: #fff;
    vertical-align: middle;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    color: #0077a8;
}

.b1-match-gap.is-filled {
    border-style: solid;
    background: #fff;
    align-items: flex-start;
    text-align: left;
    font-weight: 400;
    color: #1a2b3c;
    cursor: pointer;
}

.b1-match-gap__key {
    flex: 0 0 auto;
    min-width: 1.25rem;
    font-weight: 700;
    color: #0077a8;
}

.b1-match-gap__label {
    flex: 1 1 auto;
    display: block;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
}

.b1-match-gap.is-active {
    border-color: #005f87;
    box-shadow: 0 0 0 2px rgba(65, 182, 230, 0.35);
}

.b1-match-gap--extended {
    min-width: 3.5rem;
    min-height: 2.5rem;
    padding: 0.35rem 0.55rem;
    margin: 0.15rem 0.25rem;
    border: 1px dashed #c5c5c5;
    border-radius: 5px;
    background: #fff;
    font-size: 1rem;
    line-height: 1.2;
    box-shadow: inset 0 0 0 1px rgba(0, 119, 168, 0.08);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.b1-match-gap--extended.is-filled {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.45rem;
    border-color: #0077a8;
    background: #fff;
    font-size: 0.92rem;
    min-width: min(100%, 18rem);
    max-width: 100%;
    width: auto;
    min-height: auto;
    padding: 0.55rem 0.65rem;
    vertical-align: top;
    margin: 0.35rem 0;
}

.b1-match-people .b1-match-gap--extended.is-filled {
    display: flex;
    width: 100%;
    margin: 0.5rem 0 0.85rem;
}

.b1-reading-page.b1-reading-page--part4-split .b1-main {
    overflow: hidden;
    padding-bottom: 1rem;
}

.b1-gap-match-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: calc(100vh - 13.5rem);
    border: 1px solid #d9e8f2;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.b1-gap-match-layout__text,
.b1-gap-match-layout__tokens {
    flex: 1 1 calc(50% - 5px);
    width: calc(50% - 5px);
    max-width: calc(50% - 5px);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 13.5rem);
    max-height: calc(100vh - 13.5rem);
    min-width: 0;
}

.b1-gap-match-layout__text {
    background: #fff;
}

.b1-gap-match-layout__divider {
    flex: 0 0 10px;
    width: 10px;
    align-self: stretch;
    background: linear-gradient(180deg, #dce8f0 0%, #41b6e6 45%, #0077a8 55%, #dce8f0 100%);
    position: relative;
    z-index: 2;
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.5), inset -1px 0 0 rgba(0, 95, 135, 0.15);
}

.b1-gap-match-layout__divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 56px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(0, 119, 168, 0.2);
}

.b1-gap-match-layout__col-head {
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #0077a8;
    padding: 0.65rem 1rem;
    background: #fff;
    border-bottom: 1px solid #d9e8f2;
}

.b1-gap-match-layout__col-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    padding: 1rem 1.15rem;
    scrollbar-width: thin;
    scrollbar-color: #41b6e6 #f5f5f5;
}

.b1-gap-match-layout__col-body::-webkit-scrollbar {
    width: 11px;
}

.b1-gap-match-layout__col-body::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 999px;
    margin: 4px 0;
}

.b1-gap-match-layout__col-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #41b6e6 0%, #0077a8 100%);
    border-radius: 999px;
    border: 2px solid #f5f5f5;
}

.b1-gap-match-passage {
    line-height: 2;
    font-size: 0.98rem;
}

.b1-gap-match-passage h2 {
    font-size: 1.08rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: #1a2b3c;
}

.b1-gap-match-passage p {
    margin: 0 0 1rem;
}

.b1-match-people img,
.b1-match-people .qti-image {
    display: block;
    width: 126px;
    max-width: 100%;
    height: auto;
    margin: 0 0 0.5rem;
    border-radius: 6px;
}

.b1-match-people h2 {
    font-size: 1.08rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: #1a2b3c;
}

.b1-match-people p {
    line-height: 1.55;
}

.b1-token-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.b1-token--sentence {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    width: 100%;
    text-align: left;
    border: 1px solid #c5d9e8;
    background: #fff;
    border-radius: 5px;
    padding: 0.75rem 0.85rem;
    font-size: 0.92rem;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.b1-token--draggable {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

.b1-token--draggable.is-dragging {
    opacity: 0.55;
    cursor: grabbing;
    border-color: #0077a8;
    box-shadow: 0 4px 14px rgba(0, 119, 168, 0.2);
}

.b1-token--draggable.is-used {
    opacity: 0.42;
    cursor: not-allowed;
    pointer-events: none;
}

.b1-token__drag-hint {
    flex: 0 0 auto;
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.4;
    padding-top: 0.05rem;
}

.b1-reading-page.is-dragging-gap-match .b1-match-gap.is-drop-target {
    border-color: #41b6e6;
    background: #fffdf5;
}

.b1-match-gap.is-drag-over {
    border-color: #0077a8 !important;
    background: #fff8dc !important;
    box-shadow: 0 0 0 3px rgba(65, 182, 230, 0.35);
    transform: scale(1.04);
}

.b1-token--sentence .b1-token__key {
    flex: 0 0 auto;
    min-width: 1.4rem;
    font-weight: 700;
    color: #0077a8;
}

.b1-token--sentence .b1-token__label {
    flex: 1 1 auto;
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

.b1-token--sentence:hover {
    border-color: #41b6e6;
    background: #fff;
}

.b1-token--sentence.is-selected {
    border-color: #0077a8;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(65, 182, 230, 0.25);
}

.b1-token-bank {
    position: sticky;
    top: 0;
    max-height: min(65vh, 560px);
    overflow-y: auto;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #d9e8f2;
    border-radius: 8px;
}

.b1-token-bank__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0077a8;
    margin: 0 0 0.65rem;
}

.b1-token {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid #c5d9e8;
    background: #fff;
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.45rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
}

.b1-token:hover {
    border-color: #41b6e6;
}

.b1-token.is-selected {
    border-color: #0077a8;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(65, 182, 230, 0.25);
}

.b1-token.is-used {
    opacity: 0.45;
    pointer-events: none;
}

.b1-token__key {
    font-weight: 700;
    color: #0077a8;
    margin-right: 0.35rem;
}

.b1-cloze-passage {
    line-height: 2;
    font-size: 1rem;
}

.b1-cloze-select {
    display: inline-block;
    min-width: 120px;
    max-width: 180px;
    border: 1px solid #0077a8;
    border-radius: 4px;
    background: #fff;
    padding: 0.2rem 0.35rem;
    font-size: 0.95rem;
    vertical-align: baseline;
    margin: 0 0.15rem;
}

.b1-cloze-select:focus {
    outline: none;
    border-color: #41b6e6;
    box-shadow: 0 0 0 2px rgba(65, 182, 230, 0.3);
}

@media (max-width: 900px) {
    .b1-sign-layout,
    .b1-match-layout {
        grid-template-columns: 1fr;
    }

    .b1-split-view:not(.b1-split-view--part3) {
        grid-template-columns: 1fr;
    }

    .b1-split-view:not(.b1-split-view--part3) .b1-split-view__passage,
    .b1-split-view:not(.b1-split-view--part3) .b1-split-view__questions,
    .b1-token-bank {
        max-height: none;
    }
}

@media (max-width: 720px) {
    .b1-split-view--part3 {
        flex-direction: column;
        min-height: 0;
    }

    .b1-split-view--part3 .b1-split-view__passage,
    .b1-split-view--part3 .b1-split-view__questions {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        min-height: auto;
        max-height: none;
        overflow: hidden;
    }

    .b1-split-view__divider {
        flex: 0 0 auto;
        width: 100%;
        height: 10px;
        background: linear-gradient(90deg, #dce8f0 0%, #41b6e6 45%, #0077a8 55%, #dce8f0 100%);
    }

    .b1-split-view__divider::before {
        width: 56px;
        height: 4px;
    }

    .b1-split-view--part3 .b1-split-view__passage {
        border-bottom: none;
    }

    .b1-split-view--part3 .b1-split-view__col-body {
        max-height: min(50vh, 420px);
        overflow-y: auto;
        scrollbar-gutter: stable;
    }

    .b1-reading-page.b1-reading-page--part3-split .b1-main {
        overflow-y: auto;
    }

    .b1-reading-page.b1-reading-page--part4-split .b1-main {
        overflow-y: auto;
    }

    .b1-gap-match-layout {
        flex-direction: column;
        min-height: 0;
    }

    .b1-gap-match-layout__text,
    .b1-gap-match-layout__tokens {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        min-height: auto;
        max-height: none;
    }

    .b1-gap-match-layout__divider {
        flex: 0 0 auto;
        width: 100%;
        height: 10px;
        background: linear-gradient(90deg, #dce8f0 0%, #41b6e6 45%, #0077a8 55%, #dce8f0 100%);
    }

    .b1-gap-match-layout__divider::before {
        width: 56px;
        height: 4px;
    }

    .b1-gap-match-layout__col-body {
        max-height: min(50vh, 420px);
    }
}
