/*
 * US-068: loaded after /lib/bootstrap/css/bootstrap.min.css (Bootstrap 5.3, default light theme, OD-002 a).
 * The first part is shared word for word with the Control Plane's site.css (spec FR-010.1); the rest is this host's.
 */

/* ---- Shared: page frame (FR-004) ---- */

body { overflow-wrap: break-word; }

.page-header { padding-top: 0.5rem; }

.page { padding-top: 0.5rem; padding-bottom: 2rem; font-size: 0.9375rem; }

/* FR-004.2: everything but tables stays in one readable column inside the wide container, with one right edge. */
:root { --content-width: 48rem; }

.page h1,
.page p,
.page ul,
.page .form-control,
.page .form-select,
.page dl,
.page .notice,
.page .form-message,
.page .note { max-width: var(--content-width); }

.page form { margin-bottom: 1rem; }

.page label.form-label { display: block; margin-bottom: 0.25rem; }

/* AC-007 look check: compact titles and fields, more room for data. */
.page h1 { font-size: 1.375rem; }

/* A section title sits closer to its own content than to the section above. */
.page h2 { font-size: 1.1rem; margin-top: 0.75rem; margin-bottom: 0.25rem; }

.page p { margin-bottom: 0.5rem; }

.page form p { margin-bottom: 0.5rem; }

/* Every fieldset title: the size of the body text, bold. */
.page legend { font-size: inherit; font-weight: 700; margin-bottom: 0.25rem; }

/* A submit button right under the last field stands a little apart from it. */
.page form > label.form-label ~ button[type=submit],
.page form > .form-control ~ button[type=submit],
.page form > .form-select ~ button[type=submit] { margin-top: 0.5rem; }

/* ---- Shared: language switcher (FR-004.1, FR-005.3) ---- */

.language-switcher {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.language-switcher form { margin: 0; }

/* AC-007 look check: the switcher sits on the page title row instead of taking a row of its own, ending at the right
   edge of the content column. The title (or, in the installation, the data-health banner) leaves room for it so they
   never overlap. */
.page-header { position: relative; }

.page-header .language-switcher {
    position: absolute;
    top: 0.75rem;
    left: calc(var(--bs-gutter-x) * 0.5 + min(var(--content-width), 100% - var(--bs-gutter-x)));
    width: max-content;
    transform: translateX(-100%);
}

.page-header:has(.language-switcher):not(:has(.data-health-banner)) + .page h1 { padding-right: 11rem; }

.page-header:has(.language-switcher) .data-health-banner { max-width: calc(var(--content-width) - 11rem); margin-right: 11rem; }

/* ---- Shared: tables (FR-005.1) ---- */

.table { width: auto; max-width: 100%; }

.table th,
.table td { vertical-align: top; }

/* Compact rows (as Bootstrap's table-sm): more data on the screen. */
.table { font-size: 0.875rem; line-height: 1.2; }

.table > :not(caption) > * > * { padding: 0.0625rem 0.3rem; }

/* ---- Shared: messages (FR-005.4) — a quiet bordered box, no icon, no close button ---- */

.notice,
.form-message {
    padding: 0.5rem 1rem;
    border: 1px solid var(--bs-secondary-border-subtle);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-light-bg-subtle);
    color: var(--bs-body-color);
}

/* Lines inside a message box are evenly spaced. */
.notice h2 { margin-top: 0; }

.notice > * { margin-bottom: 0.25rem; }

.notice > :last-child { margin-bottom: 0; }

.form-error,
.field-error { color: var(--bs-danger-text-emphasis); }

.field-error { margin: 0.25rem 0 0.5rem; }

.note {
    font-size: 0.875em;
    color: var(--bs-secondary-color);
}

/* ---- Shared: show-password control (US-069 FR-006, FR-008) — icon chosen by aria-pressed, room on the right only when ready ---- */

.password-field { position: relative; display: block; max-width: var(--content-width); }

.password-field--ready input { padding-right: 2.25rem; }

.password-field--ready input::-ms-reveal { display: none; }

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2.25rem;
    padding: 0;
    border: 0;
    background-color: transparent;
    background-image: url("/img/password/eye.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.125rem;
}

.password-toggle[aria-pressed="true"] { background-image: url("/img/password/eye-off.svg"); }

/* ---- Shared: disabled buttons (US-071 FR-012, I-15) — grey with readable text, whatever the button's colour when enabled ---- */

.btn:disabled {
    --bs-btn-disabled-bg: var(--bs-gray-300);
    --bs-btn-disabled-border-color: var(--bs-gray-300);
    --bs-btn-disabled-color: var(--bs-gray-700);
    --bs-btn-disabled-opacity: 1;
}

/* ---- Installation: header search field and results (US-071 FR-001) ---- */

/* The field shares the top row with the language switcher, leaving it the room the title used to leave. */
.header-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: calc(var(--content-width) - 11rem);
    margin: 0 11rem 0.5rem 0;
}

.header-search .form-label { margin: 0; }

.header-search .form-control { flex: 1 1 8rem; width: auto; min-width: 0; }

/* Phone width: the switcher keeps the top row and the field takes the full width under it. */
@media (max-width: 575.98px) {
    .header-search { max-width: none; margin: 2.75rem 0 0.5rem; }
}

.search-rows { list-style: none; padding-left: 0; }

.search-rows > li { margin-bottom: 0.5rem; }

.search-row-detail { color: var(--bs-secondary-color); margin-left: 0.5rem; }

.search-student-courses { margin-bottom: 0; }

.search-group-whole-list { display: inline-block; margin-bottom: 0.5rem; }

/* ---- Installation: landing page (AC-007 look check) ---- */

#signed-in-role { font-size: 1.125rem; }

#synchronization-request-form,
form[action="/sign-out"] { margin-top: 1.5rem; }

#workspace-section a { margin-right: 0.5rem; }

/* A link moves to the next line whole rather than breaking in the middle of its words. */
#workspace-section a,
#course-card-links a { white-space: nowrap; }

/* A date range («З … По …») sits on one line; on a narrow screen it wraps. */
.page form p:has(> input[type=date]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.25rem;
}

.page form p:has(> input[type=date]) label.form-label { margin: 0; }

.page form p:has(> input[type=date]) input[type=date] { width: auto; margin-right: 0.5rem; }

/* On a phone each label stays with its own date: «З …» on one line, «По …» on the next. */
@media (max-width: 575.98px) {
    .page form p:has(> input[type=date]) {
        display: grid;
        grid-template-columns: auto 1fr;
        justify-items: start;
    }
}

/* The submit button of a form with a date range sits at the end of the date line, aligned with the right edge of
   the fields above (the form keeps the fields' readable width); the date line leaves room for it. */
.page form:has(> p > input[type=date]) { position: relative; max-width: var(--content-width); }

.page form:has(> p > input[type=date]) > p:has(> input[type=date]) { margin-bottom: 0; padding-right: 8rem; }

.page form:has(> p > input[type=date]) > button[type=submit]:last-child { position: absolute; right: 0; bottom: 0; }

/* Course and teacher lists: «Показати» at the right end of the Status line, the Status field shortened to make room;
   the form keeps the fields' readable width. */
#course-list-form,
#teacher-list-form {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 1rem;
    max-width: var(--content-width);
}

#course-list-form > *,
#teacher-list-form > * { grid-column: 1 / -1; }

#course-list-form > p:first-child,
#teacher-list-form > p:first-child { grid-column: 1; grid-row: 1; }

#course-list-form > button[type=submit],
#teacher-list-form > button[type=submit] { grid-column: 2; grid-row: 1; align-self: end; margin-bottom: 0.5rem; }

/* The export block of a report stands a step apart from what is above it. */
#report-export,
#meet-export { margin-top: 0.75rem; }

/* ---- Installation: course card (AC-007 look check) ---- */

#course-card-links a { margin-right: 0.75rem; }

/* The section titles match the field titles of the card («Статус»). */
#course-card-teachers h3,
#course-card-students h3,
#course-card-leavers h3 { font-size: inherit; font-weight: 700; margin-top: 0.75rem; margin-bottom: 0.25rem; }

/* ---- Installation: data health (AC-007 look check) — a course name reads like the section title ---- */

.page .data-health-course h3 { font-size: 1.1rem; margin-top: 0.75rem; margin-bottom: 0.25rem; }

/* ---- Installation: database page (AC-007 look check) — the counters as compact tables, side by side when they fit ---- */

main.page:has(#database-counters) {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    column-gap: 1.5rem;
}

main.page:has(#database-counters) > * { grid-column: 1 / -1; }

main.page:has(#database-counters) > #database-counters { grid-column: 1; }

main.page:has(#database-counters) > #database-synchronization { grid-column: 2; }

@media (max-width: 767.98px) {
    main.page:has(#database-counters) { grid-template-columns: minmax(0, 1fr); }

    main.page:has(#database-counters) > #database-counters,
    main.page:has(#database-counters) > #database-synchronization { grid-column: 1; }
}

#database-counters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 1.5rem;
}

#database-counters dl,
#database-synchronization dl {
    display: grid;
    grid-template-columns: auto auto;
    width: max-content;
    max-width: 100%;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.2;
    border-top: var(--bs-border-width) solid var(--bs-border-color);
    border-left: var(--bs-border-width) solid var(--bs-border-color);
}

#database-counters dt,
#database-counters dd,
#database-synchronization dt,
#database-synchronization dd {
    margin: 0;
    padding: 0.0625rem 0.3rem;
    font-weight: 400;
    border-right: var(--bs-border-width) solid var(--bs-border-color);
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

#database-counters dd,
#database-synchronization dd { text-align: right; }

/* A failure hint under the block wraps to the block's width instead of widening it. */
#database-synchronization > p { width: 0; min-width: 100%; }

/* ---- Installation: Meet codes (AC-007 look check) ---- */

#meet-codes-lists a { margin-right: 1rem; }

/* The row's actions read as links on one line; a state change stays a POST form button (Owner's decision over FR-005.3). */
#meet-codes-table td:last-child form { display: inline; margin: 0; }

#meet-codes-table td:last-child > * + * { margin-left: 0.75rem; }

#meet-codes-table td:last-child .btn {
    --bs-btn-padding-x: 0;
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: inherit;
    --bs-btn-line-height: inherit;
    --bs-btn-border-width: 0;
    --bs-btn-color: var(--bs-link-color);
    --bs-btn-bg: transparent;
    --bs-btn-hover-color: var(--bs-link-hover-color);
    --bs-btn-hover-bg: transparent;
    --bs-btn-active-color: var(--bs-link-hover-color);
    --bs-btn-active-bg: transparent;
    vertical-align: baseline;
    text-decoration: underline;
}

/* ---- Installation: Dean accounts (AC-007 look check) ---- */

/* The notice and the message box are exactly as wide as the table; they do not widen the column themselves. */
main.page:has(#dean-accounts) {
    display: grid;
    grid-template-columns: minmax(0, max-content);
}

main.page:has(#dean-accounts) > .notice,
main.page:has(#dean-accounts) > .form-message { width: 0; min-width: 100%; max-width: none; }

/* The last-sign-in date at the right edge of its cell. These cells are located by class, so the rule lives here. */
#dean-accounts th:nth-child(4),
#dean-accounts .dean-last-sign-in { text-align: right; }

/* Three lines per dean: the state button, the password, the login. Labels of one width line the fields and buttons up
   across all deans; on a narrow screen a label stands above its field. */
#dean-accounts td:last-child form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin: 0 0 0.125rem;
}

#dean-accounts td:last-child label.form-label {
    display: grid;
    grid-template-columns: 12rem 10rem;
    align-items: center;
    column-gap: 0.25rem;
    margin: 0;
}

#dean-accounts td:last-child .form-control {
    width: 100%;
    min-height: 0;
    padding: 0.125rem 0.375rem;
    font-size: inherit;
}

/* US-069 FR-008.3: this row's compact padding above would otherwise put the text under the eye control. */
#dean-accounts td:last-child .password-field--ready .form-control { padding-right: 2.25rem; }

#dean-accounts td:last-child button[type=submit] { margin-top: 0; }

@media (max-width: 767.98px) {
    #dean-accounts td:last-child label.form-label { grid-template-columns: minmax(0, 1fr); }

    /* NFR-070: on a phone the table scrolls inside its own area rather than widening the page. */
    #dean-accounts { display: block; overflow-x: auto; }

    #dean-accounts td:last-child { min-width: 14rem; }
}

/* A count line right above a table sits close to it. */
.page p:has(+ .table-scroll) { margin-bottom: 0.5rem; }

/* Grades, marks and their columns at the right edge of the cell, as every other number and date; the student's name
   stays at the left. These cells carry a conditional class, so the rule lives here rather than in the markup. */
#journal-table td,
#journal-table thead th:not(:first-child),
#report-grading-table td,
#report-grading-table thead th:not(:first-child),
#meet-report-people td { text-align: right; }

/* ---- Installation: wide tables scroll inside their own area (US-025, NFR-070, FR-008) ---- */

.table-scroll { overflow-x: auto; max-width: 100%; }

.table-scroll .table { margin-bottom: 0; }

/* One line per row: cells do not wrap, the table scrolls sideways in its own area instead. */
.table-scroll .table th,
.table-scroll .table td { white-space: nowrap; }

/* US-043 report-template scale: rows the page script adds carry no classes, so every row of the table is styled here
   alike (FR-009.2: the script is not changed). Same look as a small form-control and an outline-secondary button. */
#scale-rows input {
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--bs-body-color);
    background-color: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
}

#scale-rows button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
    background-color: transparent;
    border: var(--bs-border-width) solid var(--bs-secondary-border-subtle);
    border-radius: var(--bs-border-radius-sm);
}

/* US-021 spec FR-002, NFR-070: the course description keeps its line breaks as text and wraps. */
.course-card-description { white-space: pre-line; overflow-wrap: anywhere; }

/* US-046 spec FR-002, I-3: the page-search hint is one small, unobtrusive line under the title. */
.page-search-hint {
    font-size: 0.875em;
    color: var(--bs-secondary-color);
    margin: 0 0 1rem;
}

/* US-076 spec FR-002, FR-004, FR-007: the «?» stands on the title's line; the opened text falls under the title, before
   the page-search hint. A quiet ring, no colour alert, no animation; the whole 2.75rem square is the touch target. */
.page-title {
    display: flow-root;
    max-width: var(--content-width);
    margin-bottom: 0.5rem;
}

.page-title h1 {
    float: left;
    margin: 0 0.25rem 0 0;
    padding-block: 0.55rem;
}

.page-header:has(.language-switcher):not(:has(.data-health-banner)) + .page .page-title { padding-right: 11rem; }

.page-header:has(.language-switcher):not(:has(.data-health-banner)) + .page .page-title h1 { padding-right: 0; }

/* The opened text sits below the switcher's row, so it takes the whole content column back. */
.page-header:has(.language-switcher):not(:has(.data-health-banner)) + .page .page-help-body { margin-right: -11rem; }

.page-help > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    list-style: none;
    cursor: pointer;
    border-radius: 50%;
    font-weight: 600;
    color: var(--bs-secondary-color);
    box-shadow: inset 0 0 0 0.45rem var(--bs-body-bg), inset 0 0 0 calc(0.45rem + 1px) var(--bs-border-color);
}

.page-help > summary::-webkit-details-marker { display: none; }

.page-help > summary:hover,
.page-help[open] > summary { color: var(--bs-body-color); }

.page-help > summary:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; }

.page-help-body {
    clear: left;
    padding-top: 0.25rem;
    font-size: 0.875rem;
}

.page-help-body p:last-child { margin-bottom: 0; }

/* ---- Installation: data-state marks (FR-006) — amber tint, no icon, animation or dismiss control ---- */

/* US-062 FR-003.3: the data-health banner — a quiet coloured strip. */
.data-health-banner {
    margin: 0.5rem 0 0;
    padding: 0.25rem 0.75rem;
    border-left: 0.25rem solid var(--bs-warning);
    background-color: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}

.data-health-banner a { color: inherit; }

/* US-075 FR-001.4: a banner part moves to the next line whole; it never breaks inside itself. */
.data-health-banner-part { white-space: nowrap; }

/* US-075 R-1 (HUMAN_PR_APPROVAL): the first part and the separator's comma move together; the comma never starts a line. */
.data-health-banner-lead { white-space: nowrap; }

/* US-075 R-2 (HUMAN_PR_APPROVAL): on a phone the language switcher sits on the row above the header search field, so the
   banner drops the right reserve left for it and both parts fit inside its fill. */
@media (max-width: 575.98px) {
    .page-header:has(.language-switcher) .data-health-banner { max-width: none; margin-right: 0; }
}

/* US-075 FR-009.1: the hint under a kind of data problem — restrained secondary text, no banner or icon. */
.data-health-hint {
    color: var(--bs-secondary-color);
    margin: 0 0 0.5rem;
}

/* US-060 spec FR-004.2, BR-047: a light highlight of a grade above the maximum; the label is always shown too. */
.mark-above-maximum {
    background-color: var(--bs-warning-bg-subtle);
    color: var(--bs-body-color);
}

/* ---- Installation: same-host images instead of Bootstrap's embedded data: images (FR-007, SC-15) ---- */

.form-select { --bs-form-select-bg-img: url("/img/bootstrap/select-arrow.svg"); }

.form-check-input:checked[type=checkbox] { --bs-form-check-bg-image: url("/img/bootstrap/checkbox-checked.svg"); }

.form-check-input:checked[type=radio] { --bs-form-check-bg-image: url("/img/bootstrap/radio-checked.svg"); }

.form-check-input[type=checkbox]:indeterminate { --bs-form-check-bg-image: url("/img/bootstrap/checkbox-indeterminate.svg"); }
