/* מודול הבוחן */
[ng\:cloak], [ng-cloak], .ng-cloak {
    display: none !important;
}

body {
    margin: 0;
    background-color: #fbf8f5;
}

.test-page {
    --brown: #87312c;
    --brown-dark: #6e2723;
    --brown-soft: #eedfd4;
    --ink: #2b2b2b;
    --muted: #7a7a7a;
    --line: #e4d8ce;
    --ok: #1e9e3a;
    --near: #e08a00;
    --far: #c62828;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Assistant, Arial, sans-serif;
    font-size: 15px;
    color: var(--ink);
    text-align: right;
}

/* ---------- כותרת ---------- */
.test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background-color: var(--brown);
    color: #fff;
}
.test-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: bold;
}
.test-header a {
    color: #fff;
    font-size: 14px;
    text-decoration: none;
    opacity: .85;
}
.test-header a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ---------- פריסה ---------- */
.test-layout {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 16px 24px;
}
.test-side {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}
.test-main {
    flex: 1;
    min-width: 0;
}

.test-box {
    background-color: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
}
.test-box h5 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: bold;
    color: var(--brown);
}
.test-box h5.test-categories-title {
    margin-top: 14px;
}

.test-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
}
.test-field > span {
    font-size: 13px;
    font-weight: bold;
    color: #666;
}
.test-field select {
    width: 100%;
    height: 28px;
    font-family: inherit;
}
.test-row {
    display: flex;
    gap: 8px;
}
.test-row .test-field {
    flex: 1;
}

/* ---------- כפתורים ---------- */
.test-btn {
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background-color: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 14px;
    cursor: pointer;
}
.test-btn:hover:not([disabled]) {
    border-color: var(--brown);
    color: var(--brown);
}
.test-btn.primary {
    width: 100%;
    padding: 7px 14px;
    background-color: var(--brown);
    border-color: var(--brown);
    color: #fff;
    font-weight: bold;
}
.test-btn.primary:hover:not([disabled]) {
    background-color: var(--brown-dark);
    color: #fff;
}
.test-btn[disabled] {
    opacity: .5;
    cursor: default;
}
.test-btn.link {
    border: none;
    background: none;
    padding: 6px 0 0;
    color: var(--brown);
    text-decoration: underline;
}

/* ---------- מסננים ---------- */
.test-search {
    position: relative;
    margin-bottom: 10px;
}
.test-search input {
    width: 100%;
    height: 28px;
    box-sizing: border-box;
    padding: 0 8px 0 26px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}
.test-search button {
    position: absolute;
    left: 4px;
    top: 4px;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.test-checks {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.test-checks > span {
    font-weight: bold;
    color: #666;
}
.test-checks label,
.test-categories label,
.memo-options label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    font-weight: normal;
    color: var(--ink);
    cursor: pointer;
}
.test-categories {
    max-height: 40vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.test-categories label.root {
    font-weight: bold;
}
.test-categories .count {
    font-size: 12px;
    color: var(--muted);
}

/* ---------- הודעות ---------- */
.test-empty {
    padding: 60px 20px;
    text-align: center;
    font-size: 17px;
    color: var(--muted);
}
.test-error {
    color: var(--far);
}
.test-spinner {
    padding: 60px;
    text-align: center;
}
.muted {
    color: var(--muted);
}

/* ---------- בחירת מצב ---------- */
.test-modes {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}
.test-modes button {
    font-family: inherit;
    font-size: 15px;
    padding: 6px 28px;
    background-color: #fff;
    color: var(--brown);
    border: 1px solid var(--brown);
    margin-left: -1px;
    cursor: pointer;
}
.test-modes button:first-child {
    border-radius: 0 6px 6px 0;
}
.test-modes button:last-child {
    border-radius: 6px 0 0 6px;
}
.test-modes button.active {
    background-color: var(--brown);
    color: #fff;
}

/* ---------- חזרה ---------- */
.rows-count {
    margin-bottom: 6px;
    color: var(--muted);
}
.test-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border: 1px solid var(--line);
}
.test-table th {
    position: sticky;
    top: 0;
    padding: 8px 12px;
    text-align: right;
    background-color: var(--brown-soft);
    cursor: pointer;
    user-select: none;
}
.test-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #f1ebe6;
    vertical-align: top;
}
.test-table .source {
    width: 110px;
    white-space: nowrap;
}
.test-table td.source {
    color: var(--muted);
}
.test-table tr.new-daf td {
    border-top: 2px solid var(--line);
}
.test-table .test-title {
    color: var(--muted);
}
.tag-mishnah {
    display: inline-block;
    margin-right: 6px;
    padding: 0 6px;
    font-size: 11px;
    line-height: 17px;
    color: #1d4f86;
    background-color: #e6eef7;
    border-radius: 4px;
    vertical-align: middle;
}

/* ---------- שאלה (שינון + מבחן) ---------- */
.quiz {
    max-width: 640px;
    margin: 0 auto;
}
.quiz-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.quiz-question {
    min-height: 24vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.subject-title {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: bold;
    color: var(--brown);
    text-align: center;
}
.subject-test-title {
    margin: 4px 0 10px;
    font-size: 20px;
    font-weight: normal;
}
.quiz-hint {
    min-height: 40px;
}
.quiz-hint .hint-text {
    margin: 0;
    font-size: 18px;
    font-weight: normal;
    color: #555;
}

.daf-buttons {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}
.daf-buttons li {
    width: 46px;
    height: 32px;
    line-height: 28px;
    text-align: center;
    font-weight: bold;
    background-color: #d9d9d9;
    border: 2px outset #eee;
    border-radius: 30%;
    cursor: pointer;
    user-select: none;
}
.daf-buttons li {
    -webkit-tap-highlight-color: transparent;
}
.daf-buttons li:hover {
    background-color: var(--brown-soft);
}
.daf-buttons li.disabled {
    pointer-events: none;
    opacity: .3;
}

.quiz-status,
.quiz-score {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.quiz-score {
    font-weight: bold;
    color: var(--far);
}
.quiz-feedback {
    height: 90px;
    font-size: 72px;
    line-height: 90px;
    text-align: center;
    font-family: Heebo, Arial, sans-serif;
}
.ok {
    color: var(--ok);
}
.near {
    color: var(--near);
}
.far {
    color: var(--far);
}
.quiz-finished {
    padding: 40px 20px;
    text-align: center;
    background-color: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.quiz-finished h2 {
    margin-top: 0;
    color: var(--brown);
}
.quiz-finished .test-btn.primary {
    width: auto;
    margin-top: 10px;
}

/* ---------- שינון ---------- */
.memo {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}
.memo .quiz {
    flex: 0 0 420px;
    margin: 0;
}
.memo-snapshot {
    flex: 1;
    height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
}
.memo-snapshot img {
    width: 100%;
}
.memo-slider {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}
.memo-slider input[type="range"] {
    flex: 1;
    direction: rtl;
    accent-color: var(--brown);
}
.memo-slider-label {
    min-width: 30px;
    font-weight: bold;
}
.memo-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.memo-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.memo-status {
    text-align: left;
}
.memo-grade {
    min-height: 22px;
    font-weight: bold;
}

/* הופעות נוספות של נושא */
.test-table .subject-name {
    cursor: pointer;
}
.test-table .subject-name:hover {
    color: var(--brown);
}
.subject-links {
    margin-top: 3px;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- רכיבים שמוצגים רק בנייד ---------- */
.test-side-toggle,
.memo-page-toggle {
    display: none;
}
.quiz-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.daf-back {
    margin-bottom: 8px;
}

/* ================= נייד ================= */
@media screen and (max-width: 960px) {
    .test-page:not(.test-manager) {
        font-size: 16px;
    }
    .test-page:not(.test-manager) .test-header {
        padding: 8px 12px;
    }
    .test-page:not(.test-manager) .test-header h1 {
        font-size: 19px;
    }
    .test-page:not(.test-manager) .test-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    /* פאנל בחירה וסינון מתקפל */
    .test-page:not(.test-manager) .test-side-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 14px;
        font-family: inherit;
        font-size: 15px;
        font-weight: bold;
        color: var(--brown);
        background-color: #fff;
        border: 1px solid var(--line);
        border-radius: 8px;
    }
    .test-page:not(.test-manager) .test-side {
        display: none;
        flex: none;
        position: static;
        max-height: none;
        overflow: visible;
    }
    .test-page:not(.test-manager) .test-side.open {
        display: flex;
    }
    .test-page:not(.test-manager) .test-field select,
    .test-page:not(.test-manager) .test-search input {
        height: 36px;
        font-size: 16px;
    }
    .test-page:not(.test-manager) .test-categories {
        max-height: 35vh;
    }

    /* בורר המצבים */
    .test-page:not(.test-manager) .test-modes {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 6px 0;
        margin-bottom: 10px;
        background-color: #fbf8f5;
    }
    .test-page:not(.test-manager) .test-modes button {
        flex: 1;
        padding: 9px 0;
    }

    /* חזרה - כרטיסים במקום טבלה */
    test-repeating .test-table,
    test-repeating .test-table tbody,
    test-repeating .test-table tr,
    test-repeating .test-table td {
        display: block;
        width: auto;
    }
    test-repeating .test-table thead {
        display: none;
    }
    test-repeating .test-table tr {
        padding: 8px 12px;
        border-bottom: 1px solid #f1ebe6;
    }
    test-repeating .test-table td {
        padding: 0;
        border: none;
    }
    test-repeating .test-table td.source {
        font-size: 13px;
    }
    test-repeating .test-table tr.new-daf {
        border-top: 2px solid var(--line);
    }
    test-repeating .test-table tr.new-daf td {
        border-top: none;
    }

    /* שאלה */
    .quiz-question {
        min-height: 0;
        padding: 6px 0;
    }
    .subject-title {
        font-size: 24px;
    }
    .subject-test-title {
        font-size: 17px;
    }
    .daf-buttons {
        gap: 6px;
    }
    .daf-buttons li {
        width: 54px;
        height: 44px;
        line-height: 40px;
        font-size: 17px;
    }
    .daf-buttons.daf-groups li {
        width: auto;
        min-width: 100px;
        padding: 0 10px;
        border-radius: 12px;
    }

    /* מבחן - משוב במרכז המסך וסרגל קבוע בתחתית */
    .quiz-feedback {
        position: fixed;
        top: 38%;
        left: 0;
        right: 0;
        height: auto;
        font-size: 120px;
        line-height: 1;
        pointer-events: none;
        z-index: 20;
        text-shadow: 0 0 12px #fff, 0 0 24px #fff;
    }
    test-exam .quiz-body {
        padding-bottom: 96px;
    }
    test-exam .quiz-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 10;
        gap: 6px;
        padding: 8px 14px;
        box-sizing: border-box;
        background-color: #fff;
        border-top: 1px solid var(--line);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, .06);
    }

    /* שינון - צילום הדף מוסתר עד לחיצה על "הצג דף" */
    .memo {
        flex-direction: column;
        align-items: stretch;
    }
    .memo .quiz {
        flex: none;
        width: 100%;
    }
    .memo-page-toggle {
        display: inline-block;
    }
    .memo-snapshot {
        display: none;
        flex: none;
        height: auto;
    }
    .memo-snapshot.show {
        display: block;
    }
    .memo-footer {
        flex-direction: column;
        gap: 8px;
    }
    .memo-options {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 14px;
    }
    .memo-status {
        text-align: right;
    }
}
