/* ==========================================================================
   Admin list and form pages (surveys, questions, capabilities, universities,
   departments, scales, answers, settings, participants).
   --------------------------------------------------------------------------
   Builds on app.css: only the pieces those pages need and app.css lacks.
   Logical properties throughout, so the rules hold in the right-to-left layout.
   ========================================================================== */

/* 0. The template has no [hidden] rule of its own, so blocks that set their own
      display must be told to honour the attribute. */
.form-grid[hidden],
.field-note[hidden],
.callout[hidden],
.ai-thinking[hidden],
.empty-state[hidden],
.value-preview[hidden] {
    display: none !important;
}

/* 1. Form pages ------------------------------------------------------------ */

/* a form is one card of readable width */
.content-wrapper .form-card {
    max-width: 54rem;
}

.form-card > .card-body {
    display: grid;
    gap: 1.75rem;
}

/* a group of related fields under a short title */
.form-section {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.form-section + .form-section {
    padding-top: 1.75rem;
    border-top: 1px solid var(--ink-100);
}

.form-section__title {
    float: none;
    width: auto;
    margin: 0 0 0.125rem;
    padding: 0;
    color: var(--ink-900);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.5;
}

.form-section__hint {
    margin: 0 0 1rem;
    color: var(--ink-500);
    font-size: 0.8125rem;
}

.form-section__title + .form-grid,
.form-section__title + .field {
    margin-top: 0.875rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.125rem 1.25rem;
}

.form-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid > .span-full {
    grid-column: 1 / -1;
}

.field {
    min-width: 0;
}

.field > .form-label {
    display: block;
}

.field > .form-text,
.field > .invalid-feedback {
    margin-bottom: 0;
}

/* required and optional markers next to a label */
.req {
    margin-inline-start: 0.125rem;
    color: var(--danger);
    font-weight: 700;
}

.optional {
    margin-inline-start: 0.25rem;
    color: var(--ink-400);
    font-weight: 500;
}

/* the footer of a form card: secondary action, then the primary one at the end */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.form-actions__note {
    margin-inline-end: auto;
    color: var(--ink-500);
    font-size: 0.8125rem;
}

/* a checkbox with its explanation, the size of an input */
.check-tile {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    height: 100%;
    margin: 0;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.check-tile:hover {
    border-color: var(--ink-300);
}

.check-tile:has(.form-check-input:checked) {
    border-color: var(--brand-200);
    background: var(--brand-50);
}

.check-tile .form-check-input {
    float: none;
    flex: 0 0 auto;
    margin: 0.1875rem 0 0;
}

.check-tile__title {
    display: block;
    color: var(--ink-900);
    font-size: 0.875rem;
    font-weight: 600;
}

.check-tile__hint {
    display: block;
    margin-top: 0.125rem;
    color: var(--ink-500);
    font-size: 0.8125rem;
    font-weight: 400;
}

/* the field the date inputs collapse into when a survey is always open */
.field-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: var(--ink-500);
    font-size: 0.8125rem;
}

.field-note .bx {
    font-size: 1.125rem;
    color: var(--ink-400);
}

/* a list of values computed from the choices (a scale's answers) */
.value-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.value-preview li {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border: 1px solid var(--ink-200);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-700);
    font-size: 0.8125rem;
}

.value-preview strong {
    color: var(--brand-700);
    font-variant-numeric: tabular-nums;
}

/* 2. Lists ----------------------------------------------------------------- */

/* the id, the main name, secondary text */
.cell-id {
    color: var(--ink-500);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.cell-title {
    color: var(--ink-900);
    font-weight: 600;
}

a.cell-title:hover,
a.cell-title:focus-visible {
    color: var(--brand-700);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cell-sub {
    display: block;
    margin-top: 0.0625rem;
    color: var(--ink-500);
    font-size: 0.78125rem;
    font-weight: 400;
}

/* long text (question wording) wraps instead of widening the table */
.list-card .dt-container table.dataTable td.cell-wrap,
.table td.cell-wrap {
    min-width: 16rem;
    max-width: 36rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* short values stay on one line in the list pages (those cards carry .list-card) */
.list-card .dt-container table.dataTable th,
.list-card .dt-container table.dataTable td {
    white-space: nowrap;
}

.tabular {
    font-variant-numeric: tabular-nums;
}

/* row actions: one quiet line of icon buttons, delete set apart at the end */
.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    vertical-align: middle;
}

.row-actions__sep {
    align-self: stretch;
    width: 1px;
    margin-inline: 0.125rem;
    background: var(--ink-200);
}

.dt-container table.dataTable > thead > tr > th.col-actions,
.dt-container table.dataTable > tbody > tr > td.col-actions {
    width: 1%;
    text-align: end;
}

.col-check {
    width: 2.5rem;
}

.col-check .form-check-input {
    margin: 0;
}

/* the empty state sits inside the table's own empty row */
.dt-container td.dt-empty {
    white-space: normal;
}

.dt-container .dt-empty .empty-state {
    padding: 1.25rem 1rem;
}

.list-card .empty-state p {
    margin: 0;
}

.list-card .empty-state .btn {
    margin-top: 0.5rem;
}

/* a card that holds a list of choices (questions, answers, capabilities) */
.choice-summary {
    color: var(--ink-600);
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* back link above a page title */
.page-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.375rem;
    color: var(--ink-500);
    font-size: 0.8125rem;
    font-weight: 600;
}

.page-back:hover {
    color: var(--brand-700);
}

.page-back .bx {
    font-size: 1.125rem;
}

/* 3. Dialogs --------------------------------------------------------------- */

/* destructive confirmations: the confirm button is red */
.swal2-styled.swal2-confirm.swal-confirm--danger {
    background: var(--danger) !important;
}

.swal2-styled.swal2-confirm.swal-confirm--danger:hover {
    background: #991b1b !important;
}

.swal2-styled.swal2-confirm.swal-confirm--danger:focus-visible {
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.25) !important;
}

/* progress of a long request (export, grouping) */
.progress-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
    color: var(--ink-600);
    font-size: 0.8125rem;
    font-weight: 600;
}

.progress-note span:last-child {
    font-variant-numeric: tabular-nums;
}

/* a short list of choices inside a dialog */
.table-framed.choice-list {
    max-height: 20rem;
    overflow-y: auto;
}

.choice-list .dt-container > .row {
    padding: 0;
}

.choice-list table.dataTable > thead > tr > th {
    border-top: 0;
}

/* 4. Small screens --------------------------------------------------------- */
@media (max-width: 767.98px) {
    .form-grid,
    .form-grid--3 {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-actions > .btn {
        flex: 1 1 auto;
    }

    .form-actions__note {
        flex-basis: 100%;
    }

    .page-header__actions {
        width: 100%;
    }

    .page-header__actions > .btn {
        flex: 1 1 auto;
    }
}
