/* Neues Design (Vorschau): Klassenarbeiten (/tests, preview/tests.js).
   One panel: the header (month, class menu, today, back and forth,
   »Eintragen«), the month as a grid, a quiet footer (legend, »Kalender
   verwalten«). Phones: the month as an agenda instead of the grid.

   FullCalendar measures its grid: no padding, margins or offsets on the
   rows, cells or harnesses inside it (doc/Gestaltung.md, Stundenplan) –
   only colours, lines, radii and the day's minimum height. Air belongs
   around the calendar, in the panel. */

.ui-preview.pv-tests-page #main_container > .container-fluid {
    padding-top: 12px !important;
}

.pv-tests {
    max-width: 1600px;
    margin: 0 auto 24px;
    padding: 18px 20px 14px;
    background: var(--pv-surface);
    color: var(--pv-ink);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* ---------- header ---------- */
.pv-tests-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 16px;
    margin-bottom: 14px;
}

.pv-tests-title {
    flex: 1 1 auto;
    min-width: 0;
}

.pv-tests-title h2 {
    margin: 0;
    font: 800 1.6rem/1.15 var(--pv-display);
    letter-spacing: -0.01em;
    color: var(--pv-ink);
}

.pv-tests-sub {
    margin-top: 3px;
    font-size: 0.92rem;
    color: var(--pv-muted);
}

.pv-tests-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.pv-tests-btn,
.pv-tests-seg button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--pv-line);
    border-radius: 10px;
    background: var(--pv-surface);
    color: var(--pv-ink);
    font: 600 0.92rem/1.2 var(--pv-text);
    cursor: pointer;
}

.pv-tests-btn i,
.pv-tests-seg button i {
    font-size: 1.05rem;
    color: var(--pv-muted);
}

.pv-tests-btn:hover:not(:disabled),
.pv-tests-seg button:hover {
    background: var(--pv-hover);
}

.pv-tests-btn:disabled {
    color: var(--pv-muted);
    cursor: default;
}

.pv-tests-btn:focus-visible,
.pv-tests-seg button:focus-visible,
.pv-tests-manage:focus-visible,
.pv-ta-row:focus-visible,
.pv-tests-menu-klasse:focus-visible {
    outline: 2px solid var(--acc-text);
    outline-offset: 2px;
}

.pv-tests-btn:focus:not(:focus-visible),
.pv-tests-seg button:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

.pv-tests-seg {
    display: inline-flex;
}

.pv-tests-seg button {
    padding: 8px 10px;
}

.pv-tests-seg button:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.pv-tests-seg button + button {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.ui-preview #main_container .pv-tests-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    line-height: 1.2;
}

.pv-tests-add-short {
    display: none;
}

.pv-tests-klasse-wrap {
    position: relative;
}

/* ---------- the class menu (a popover; a sheet on phones, .pv-plan-menu) ---------- */
.pv-tests-menu {
    width: 300px;
}

.pv-tests-menu-title {
    display: none;
    margin: 0 2px 8px;
    font: 700 1.05rem/1.2 var(--pv-display);
}

.pv-tests-menu-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0;
}

.pv-tests-menu-row + .pv-tests-menu-row {
    border-top: 1px solid var(--pv-line);
}

.pv-tests-menu-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 2px;
}

.ui-preview .pv-tests-menu-klasse {
    display: block;
    padding: 6px 4px;
    border-radius: 8px;
    color: var(--pv-ink) !important;
    font-weight: 600;
    text-align: center;
    text-decoration: none !important;
}

.ui-preview .pv-tests-menu-klasse:hover {
    background: var(--pv-hover);
}

.ui-preview .pv-tests-menu-klasse.active {
    background: var(--acc);
    color: var(--acc-ink) !important;
}

/* ---------- the month grid ---------- */
.ui-preview .pv-tests .fc .fc-view-harness {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.ui-preview .pv-tests .fc-scrollgrid {
    border-radius: 12px;
}

.ui-preview .pv-tests .fc .fc-col-header-cell-cushion {
    color: var(--pv-muted);
    font: 600 0.85rem/1.2 var(--pv-text);
}

.ui-preview .pv-tests .fc-daygrid-day-frame {
    min-height: 6.25rem;
}

/* desktop: the six weeks fill the window's height (up to a point), so the
   month keeps its height from one to the next; the panel in the middle of
   the window */
@media (min-width: 992px) {
    .ui-preview .pv-tests .fc-dayGridMonth-view .fc-daygrid-day-frame {
        min-height: clamp(6.25rem, calc((100dvh - 300px) / 6), 9.5rem);
    }

    .ui-preview.pv-tests-page #main_container > .container-fluid {
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 100dvh;
        padding-bottom: 12px !important;
    }

    .ui-preview.pv-tests-page .pv-tests {
        width: 100%;
        margin-bottom: 0;
    }
}

.ui-preview .pv-tests .fc-day-sat,
.ui-preview .pv-tests .fc-day-sun {
    background: color-mix(in srgb, var(--pv-hover) 60%, transparent);
}

.ui-preview .pv-tests .fc .fc-daygrid-day.fc-day-today {
    background-color: transparent !important;
}

/* a day to click on: a neutral tint – in the accent the school's dates
   (on the accent's soft colour) blended into it */
.ui-preview.pv-tests-can-add .pv-tests .fc-daygrid-day:hover {
    background-color: color-mix(in srgb, var(--pv-hover) 75%, transparent) !important;
}

/* an entry under the pointer: a fine outline, its colours stay */
.ui-preview .pv-tests .fc-h-event:hover {
    outline: 1px solid color-mix(in srgb, var(--pv-ink) 35%, transparent);
    outline-offset: -1px;
}

.ui-preview .pv-tests .fc .fc-daygrid-day-number {
    min-width: 1.9em;
    height: 1.9em;
    margin: 4px;
    padding: 0 0.45em;
    border-radius: 999px;
    color: var(--pv-ink);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.9em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ui-preview .pv-tests .fc .fc-day-today .fc-daygrid-day-number {
    background: var(--acc);
    color: var(--acc-ink);
}

.ui-preview .pv-tests .fc .fc-day-other .fc-daygrid-day-top {
    opacity: 0.45;
}

/* entries: readable text on a calm ground, the kind at a glance */
.ui-preview .pv-tests .fc-h-event {
    border: 0;
    border-radius: 6px;
    background: var(--pv-hover);
    cursor: pointer;
}

.ui-preview .pv-tests .fc-h-event .fc-event-main {
    color: var(--pv-ink);
    font: 600 0.82rem/1.35 var(--pv-text);
}

.ui-preview .pv-tests .fc-daygrid-event .fc-event-title {
    color: inherit;
}

/* up to two lines, then »…« (FullCalendar measures the entries as they are) */
.ui-preview .pv-tests .fc-daygrid-block-event .fc-event-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.ui-preview .pv-tests .fc-h-event.pv-t-exam {
    background: var(--c, var(--acc));
}

.ui-preview .pv-tests .fc-h-event.pv-t-exam .fc-event-main {
    color: var(--ci, var(--acc-ink));
}

.ui-preview .pv-tests .fc-h-event.pv-t-other {
    background: var(--pv-surface);
    box-shadow: inset 3px 0 0 var(--c, var(--acc)), inset 0 0 0 1px var(--pv-line);
}

.ui-preview .pv-tests .fc-h-event.pv-t-school {
    background: var(--acc-soft);
}

.ui-preview .pv-tests .fc-h-event.pv-t-school .fc-event-main {
    color: var(--acc-text);
}

.ui-preview .pv-tests .fc-h-event.pv-t-holiday .fc-event-main {
    color: var(--pv-muted);
}

.ui-preview .pv-tests .fc-h-event.pv-t-week {
    background: transparent;
}

.ui-preview .pv-tests .fc-h-event.pv-t-week .fc-event-main {
    color: var(--pv-muted);
    font-weight: 500;
    font-size: 0.76rem;
}

.ui-preview .pv-tests .fc-h-event:focus-visible {
    outline: 2px solid var(--acc-text);
    outline-offset: 1px;
}

/* FullCalendar's popover (»+2 weitere«) */
.ui-preview .pv-tests .fc .fc-popover {
    background: var(--pv-surface);
    border: 1px solid var(--pv-line);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* ---------- footer ---------- */
.pv-tests-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin-top: 12px;
    font-size: 0.86rem;
    color: var(--pv-muted);
}

.pv-tests-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.pv-tests-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pv-tests-swatch {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: var(--pv-hover);
}

.pv-tl-exam .pv-tests-swatch {
    background: linear-gradient(90deg, var(--subj-de) 0 33%, var(--subj-ma) 33% 66%, var(--subj-ge) 66%);
}

.pv-tl-other .pv-tests-swatch {
    background: var(--pv-surface);
    box-shadow: inset 3px 0 0 var(--acc), inset 0 0 0 1px var(--pv-line);
}

.pv-tl-school .pv-tests-swatch {
    background: var(--acc-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc-text) 30%, transparent);
}

.pv-tests-hint {
    flex: 1 1 auto;
}

.ui-preview #main_container a.pv-tests-manage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--pv-ink);
    font-weight: 600;
    text-decoration: none;
}

.ui-preview #main_container a.pv-tests-manage:hover {
    background: var(--pv-hover);
}

.pv-tests-manage i {
    color: var(--pv-muted);
}

/* ---------- phones: the week as an agenda ---------- */
.pv-tests-agenda {
    display: none;
}

.pv-ta-week {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin: 18px 0 2px;
    font-size: 0.8rem;
    color: var(--pv-muted);
}

.pv-ta-week:first-child {
    margin-top: 4px;
}

.pv-ta-week b {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pv-ta-day {
    margin: 10px 0 2px;
    font: 700 1rem/1.25 var(--pv-display);
    color: var(--pv-ink);
}

.pv-ta-day:first-child {
    margin-top: 4px;
}

.pv-ta-day.pv-ta-today {
    color: var(--acc-text);
}

.pv-ta-list {
    display: flex;
    flex-direction: column;
}

.pv-ta-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 2px;
    border: 0;
    background: none;
    color: var(--pv-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.pv-ta-row + .pv-ta-row {
    border-top: 1px solid var(--pv-line);
}

.pv-ta-row:active {
    background: var(--pv-hover);
}

.pv-ta-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    height: 1.6rem;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--pv-hover);
    color: var(--pv-muted);
    font: 700 0.82rem/1 var(--pv-text);
}

.pv-ta-exam .pv-ta-mark {
    background: var(--c, var(--acc));
    color: var(--ci, var(--acc-ink));
}

.pv-ta-other .pv-ta-mark {
    background: var(--pv-surface);
    box-shadow: inset 0 0 0 2px var(--c, var(--acc));
    color: var(--pv-ink);
}

.pv-ta-school .pv-ta-mark {
    background: var(--acc-soft);
    color: var(--acc-text);
}

.pv-ta-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
}

.pv-ta-text b {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.pv-ta-text small {
    font-size: 0.86rem;
    color: var(--pv-muted);
    overflow-wrap: anywhere;
}

.pv-ta-row > .ti-chevron-right {
    flex: none;
    margin-top: 5px;
    color: var(--pv-muted);
}

.pv-ta-empty {
    padding: 6px 2px;
    font-size: 0.92rem;
    color: var(--pv-muted);
}

.pv-ta-none {
    margin: 2px 0 6px;
    color: var(--pv-muted);
}

@media (max-width: 767px) {
    .ui-preview.pv-tests-page #main_container > .container-fluid {
        padding-top: 8px !important;
    }

    .pv-tests {
        padding: 14px 14px 10px;
    }

    .ui-preview .pv-tests .fc-view-harness {
        display: none;
    }

    .pv-tests-agenda {
        display: block;
    }

    /* the week slides out at the panel's edge, the neighbour comes in */
    .pv-tests-agenda-frame {
        position: relative;
        margin: 0 -14px;
        padding: 0 14px;
        overflow-x: clip;
    }

    .pv-tests-agenda-ghost {
        position: absolute;
        top: 0;
        left: 14px;
        right: 14px;
        pointer-events: none;
    }

    /* the month and »Neu« in the first line, the controls below */
    .pv-tests-head {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 10px;
    }

    .pv-tests-title h2 {
        font-size: 1.4rem;
    }

    .pv-tests-tools {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-wrap: nowrap;
    }

    .pv-tests-klasse-wrap {
        flex: 1 1 auto;
        min-width: 0;
    }

    .pv-tests-klasse {
        width: 100%;
        justify-content: space-between;
    }

    .pv-tests-btn,
    .pv-tests-seg button {
        padding: 9px 12px;
    }

    .pv-tests-add-long,
    .pv-tests-legend,
    .pv-tests-hint {
        display: none;
    }

    .pv-tests-add-short {
        display: inline;
    }

    .pv-tests-foot:not(:has(.pv-tests-manage)) {
        display: none;
    }

    .pv-tests-menu {
        width: auto;
    }

    .pv-tests-menu-title {
        display: block;
    }

    .ui-preview .pv-tests-menu-klasse {
        padding: 10px 4px;
        font-size: 1rem;
    }

    .pv-tests-menu-list {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    }
}

/* ---------- dialogs ---------- */
.pv-tests-facts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pv-tests-fact {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    overflow-wrap: anywhere;
}

.pv-tests-fact i {
    flex: none;
    width: 1.25em;
    margin-top: 2px;
    font-size: 1.1em;
    text-align: center;
    color: var(--pv-muted);
}

/* the details of an entry one cannot edit (show_details): a band in the
   subject's colour like the lesson dialog, class and date below the title,
   the facts in quiet rows, the note (the teacher's words) in the ink */
.ui-preview #showTestModal .modal-header {
    border-top: 6px solid var(--c, var(--acc));
}

.ui-preview #showTestModal .modal-title {
    font-family: var(--pv-display);
    font-weight: 800;
    line-height: 1.25;
}

.pv-tests-show-sub {
    margin-top: 4px;
    color: var(--pv-muted);
}

.ui-preview #showTestModal .pv-tests-fact {
    color: var(--pv-muted);
}

.ui-preview #showTestModal .pv-tests-fact.pv-tests-fact-note {
    color: var(--pv-ink);
}

@media (min-width: 768px) {
    .ui-preview #showTestModal .modal-dialog {
        max-width: 460px;
    }
}

/* »Löschen« calm, at the start; »Speichern« at the end */
.ui-preview.pv-tests-page #testModal .modal-footer #bu_delete_test {
    margin-right: auto;
    background-color: var(--pv-surface);
    border: 1px solid var(--pv-line);
    color: #b42318;
}

.ui-preview.dark.pv-tests-page #testModal .modal-footer #bu_delete_test {
    color: #ff8f8f;
}

.ui-preview.pv-tests-page #testModal .modal-footer #bu_save_test {
    order: 3;
}

.ui-preview.pv-tests-page #testModal .modal-footer #bu_save_test.btn-outline-secondary:disabled {
    background-color: var(--pv-hover);
    border-color: var(--pv-line);
    color: var(--pv-muted);
}

/* »im Stundenplan der Klasse anzeigen« as a checkbox, not a red/green button
   (styles.css places the button and its icon absolutely in .button-with-label) */
.ui-preview.pv-tests-page #testModal .button-with-label {
    padding-left: 0;
    min-height: 0;
}

.ui-preview.pv-tests-page #ti_publish_for_klasse {
    position: relative;
    display: block;
    width: auto;
    padding: 4px 0 4px 30px;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    color: var(--pv-ink) !important;
    font-weight: 400;
    text-align: left;
    white-space: normal;
}

.ui-preview.pv-tests-page #ti_publish_for_klasse strong {
    font-family: inherit;
}

.ui-preview.pv-tests-page #ti_publish_for_klasse i {
    position: absolute;
    left: 0;
    top: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--pv-muted);
    border-radius: 6px;
    color: transparent;
    font-size: 14px;
}

.ui-preview.pv-tests-page #ti_publish_for_klasse.btn-success i {
    background: var(--acc);
    border-color: var(--acc);
    color: var(--acc-ink);
}

.ui-preview.pv-tests-page #ti_publish_for_klasse:focus-visible {
    outline: 2px solid var(--acc-text);
    outline-offset: 2px;
}

/* phones: »Speichern« as the sheet's main action across the width, the rest above */
@media (max-width: 767px) {
    .ui-preview.pv-tests-page #testModal .modal-footer {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 8px;
    }

    .ui-preview.pv-tests-page #testModal .modal-footer > .btn {
        margin: 0;
    }

    .ui-preview.pv-tests-page #testModal .modal-footer #bu_save_test {
        flex: 1 1 100%;
        justify-content: center;
        padding: 10px;
        font-size: 1rem;
    }
}
