/*----------------------------
    SELECTION WINDOWS (docs/workout-builder.md «Grafica della libreria e delle finestre di scelta»)
    «Aggiungi allenamento» and «Aggiungi programma» of the client's calendar, «Aggiungi allenamento» of a program day and
    «Importa template»: <x-modals.calendar_assignment_selector_layout> with the list on the left and the preview on the
    right. The panes are separated by space instead of lines, the list is a soft surface with soft rounded rows, the
    group labels are calm and on a phone the shared segmented control switches between the list and the preview.
-----------------------------*/
.calendar-assignment-layout {
    --calendar-selection-soft: rgba(var(--contrast-theme-color-rgb), 0.045);
    --calendar-selection-softer: rgba(var(--contrast-theme-color-rgb), 0.08);
    --calendar-selection-active: rgba(var(--mangofit-color-rgb), 0.1);
    --calendar-selection-active-line: rgba(var(--mangofit-color-rgb), 0.38);
    height: min(78vh, 760px);
    min-height: 520px;
}

[data-bs-theme="dark"] .calendar-assignment-layout {
    --calendar-selection-soft: rgba(var(--contrast-theme-color-rgb), 0.06);
    --calendar-selection-softer: rgba(var(--contrast-theme-color-rgb), 0.11);
    --calendar-selection-active: rgba(var(--mangofit-color-rgb), 0.16);
}

/* From 768 px the windows are centred (modal-dialog-centered), so the body has no fixed height and the h-100 of the
   layout would follow its content: the whole window scrolled and the search went away with it. A height of its own
   keeps the search in place and lets the list and the preview scroll each on its own, as before the restyle */
@media (min-width: 768px) {
    .calendar-assignment-layout.h-100 {
        height: min(78vh, 760px) !important;
        max-height: 100%;
    }
}

.calendar-assignment-grid {
    min-height: 0;
    padding: 0 1rem 1rem;
}

.calendar-assignment-pane {
    min-height: 0;
}

.calendar-assignment-pane-list,
.calendar-assignment-pane-detail {
    height: 100%;
}

.calendar-assignment-search {
    padding: 0.25rem 1rem 0.75rem;
}

.calendar-assignment-search .calendar-assignment-search-field .mf-search-input-control {
    min-height: 2.75rem;
    font-size: 0.95rem;
    border-color: rgba(var(--contrast-theme-color-rgb), 0.14);
    border-radius: 0.75rem;
    background-color: var(--calendar-selection-soft) !important;
}

.calendar-assignment-search .calendar-assignment-search-field .mf-search-input-control::placeholder {
    color: var(--bs-secondary-color);
}

/* The list: one soft surface, the rows inside separated by a little space. As tall as its rows (up to the pane,
   then it scrolls): a short list no longer leaves a grey panel half empty down to the bottom of the screen */
.calendar-assignment-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 100%;
    padding: 0.4rem;
    border-radius: 1rem;
    background-color: var(--calendar-selection-soft);
    overscroll-behavior: contain;
}

.calendar-assignment-layout .calendar-assignment-list.h-100 {
    height: auto !important;
}

/* The preview: on the body colour, next to the list with space between them; its cards keep a little room from the
   scroll bar on the right. Two classes: the .row > * gutter of Bootstrap (g-0) arrives later through Vite and set the
   space back to 0, so the program days touched the list (owner, 1 December 2026) */
.calendar-assignment-grid > .calendar-assignment-pane-detail {
    padding-inline-start: 1.5rem;
}

.calendar-assignment-detail {
    padding: 0.25rem 0.5rem 0.5rem 0.25rem;
    overscroll-behavior: contain;
}

/* Group of the list («I tuoi allenamenti», «Template Mangofit»): a calm label with its chevron, no band or lines */
.calendar-selection-group + .calendar-selection-group {
    margin-top: 0.5rem;
}

.calendar-selection-group-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.calendar-selection-group-toggle {
    width: 100%;
    min-height: 2.5rem;
    border: 0;
    border-radius: 0.65rem;
    margin: 0;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    background-color: transparent;
    color: var(--bs-secondary-color);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.calendar-selection-group-toggle:hover {
    background-color: var(--calendar-selection-softer);
    color: var(--bs-body-color);
}

.calendar-selection-group-toggle:focus-visible {
    outline: 2px solid var(--mangofit-color);
    outline-offset: 1px;
}

.calendar-selection-group-label {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: inherit;
}

.calendar-selection-group-chevron {
    font-size: 0.78rem;
    color: inherit;
    transition: transform 0.2s ease;
}

.calendar-selection-group-toggle.is-collapsed .calendar-selection-group-chevron {
    transform: rotate(-90deg);
}

/* A workout or a program of the list: a soft rounded row; the chosen one has the soft brand tint and a thin ring.
   (.hoverable-item of utils.css paints its hover with !important: the rows keep their own tones.) */
.calendar-assignment-layout .calendar-selection-item.hoverable-item {
    position: relative;
    min-height: 3.25rem;
    padding: 0.65rem 0.8rem;
    border: 0;
    border-radius: 0.75rem;
    background-color: transparent !important;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.calendar-assignment-layout .calendar-selection-item.hoverable-item:hover {
    background-color: var(--bs-body-bg) !important;
    box-shadow: 0 1px 2px rgba(var(--contrast-theme-color-rgb), 0.08);
}

.calendar-assignment-layout .calendar-selection-item.hoverable-item.hoverable-active {
    background-color: var(--calendar-selection-active) !important;
    box-shadow: inset 0 0 0 1px var(--calendar-selection-active-line);
}

.calendar-selection-item-title {
    min-width: 0;
    color: var(--bs-heading-color);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.calendar-selection-item-meta {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

.calendar-selection-item-badges {
    flex-shrink: 0;
}

/* «Template Mangofit»: a calm brand chip */
.calendar-selection-template-chip {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    background: rgba(var(--mangofit-color-rgb), 0.12);
    color: color-mix(in srgb, var(--mangofit-color) 78%, var(--bs-body-color));
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.calendar-selection-empty-state {
    margin: 0 auto;
    max-width: 420px;
    width: min(100%, 420px);
}

/* The heading of a preview: the tile of the library section, the name as a calm title, the chip on the right */
.calendar-selection-detail-heading {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
    margin-bottom: 0.9rem;
}

.calendar-selection-detail-heading .calendar-selection-template-chip {
    margin-inline-start: auto;
}

.calendar-selection-detail-title {
    min-width: 0;
    margin: 0;
    color: var(--bs-heading-color);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* The days of a program: a calm title and the workouts as soft rows, separated by space */
.calendar-selection-days {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.25rem;
}

.calendar-selection-day-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.calendar-selection-day-title {
    margin-bottom: 0.1rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
}

.calendar-selection-day-workout-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.8rem;
    border-radius: 0.75rem;
    background: var(--calendar-selection-soft);
    overflow-wrap: anywhere;
}

.calendar-selection-day-workout-icon {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: color-mix(in srgb, rgb(99, 91, 222) 78%, var(--bs-body-color));
}

/* The phone switch between the list and the preview: the shared segmented control, 40 px targets */
.calendar-assignment-mobile-switch {
    padding: 0 1rem 0.75rem;
}

.calendar-assignment-mobile-switch .mg-segmented-action-group > .btn {
    min-height: 2.5rem;
    font-size: 0.88rem;
}

/* The pane on screen is filled with the brand colour, as before the restyle: the white of the shared control was hard
   to tell from the other pane in light and almost the same in dark (the shared component is not touched) */
.calendar-assignment-mobile-switch .mg-segmented-action-group > .btn.active,
.calendar-assignment-mobile-switch .mg-segmented-action-group > .btn[aria-pressed="true"] {
    border-color: var(--mangofit-color) !important;
    background: var(--mangofit-color) !important;
    box-shadow: 0 0.15rem 0.45rem rgba(var(--mangofit-color-rgb), 0.28) !important;
    color: #fff !important;
}

@media (max-width: 767.98px) {
    .calendar-assignment-grid {
        padding: 0 0.75rem 0.75rem;
    }

    .calendar-assignment-search,
    .calendar-assignment-mobile-switch {
        padding-inline: 0.75rem;
    }

    .calendar-assignment-grid > .calendar-assignment-pane-detail {
        padding-inline-start: 0;
    }
}

/* The equipment of a preview: a calm group title and soft chips, as in «Riepilogo allenamento» */
.calendar-assignment-detail .workout-card-equipment-summary {
    margin: 0 0 1rem;
}

.calendar-assignment-detail .workout-card-equipment-summary__label {
    gap: 0.45rem;
    margin-bottom: 0.5rem;
    color: var(--bs-heading-color);
    font-size: 0.9rem;
    letter-spacing: 0;
    text-transform: none;
}

.calendar-assignment-detail .workout-card-equipment-summary__label i {
    color: var(--bs-secondary-color);
}

.calendar-assignment-detail .workout-card-equipment-chip {
    min-height: 2rem;
    border-color: transparent;
    background: var(--calendar-selection-soft);
    color: var(--bs-body-color);
}

/*----------------------------
    WORKOUT PREVIEW OF THE SELECTION WINDOWS (owner, 1 December 2026: «diamo anche qui un tocco di novità»): the light
    language of the builder. Exercises are white cards with a soft edge, a superset a soft grey surface with a calm
    brand «SUPERSERIE» chip (the brand tint stays the mark of the sections), a section a soft frame with its band tinted in the brand colour and its format and targets as
    chips. In these windows and in the client's preview before starting (.workout-preview-light, below, since 2
    December 2026); the summary and the player keep their cards (getGroupedExercisesTemplate is shared), and the
    preview of «Aggiungi programma» has none of these elements
-----------------------------*/
:is(.calendar-assignment-detail, .workout-preview-light) {
    --calendar-preview-line: rgba(var(--contrast-theme-color-rgb), 0.1);
    --calendar-preview-surface: rgba(var(--contrast-theme-color-rgb), 0.028);
    --calendar-preview-chip: rgba(var(--contrast-theme-color-rgb), 0.07);
    --calendar-preview-band: rgba(var(--mangofit-color-rgb), 0.085);
    --calendar-preview-superset: rgba(var(--contrast-theme-color-rgb), 0.045);
    --calendar-preview-brand-text: color-mix(in srgb, var(--mangofit-color) 72%, var(--bs-body-color));
}

[data-bs-theme="dark"] :is(.calendar-assignment-detail, .workout-preview-light) {
    --calendar-preview-line: rgba(var(--contrast-theme-color-rgb), 0.13);
    --calendar-preview-surface: rgba(var(--contrast-theme-color-rgb), 0.035);
    --calendar-preview-chip: rgba(var(--contrast-theme-color-rgb), 0.1);
    --calendar-preview-band: rgba(var(--mangofit-color-rgb), 0.14);
    --calendar-preview-superset: rgba(var(--contrast-theme-color-rgb), 0.065);
}

/* An exercise: a white card with a soft edge and no shadow, the image as a rounded tile, the name a little bolder,
   the category as a soft chip */
:is(.calendar-assignment-detail, .workout-preview-light) .workout-sorting-exercise-wrapper-element.card {
    --bs-card-border-radius: 0.9rem;
    --bs-box-shadow-sm: none;
    border-color: var(--calendar-preview-line) !important;
    background-color: var(--bs-body-bg);
}

:is(.calendar-assignment-detail, .workout-preview-light) .workout-sorting-exercise-wrapper-element img.rounded {
    border: 0 !important;
    border-radius: 0.7rem !important;
    background-color: #fff;
}

:is(.calendar-assignment-detail, .workout-preview-light) .workout-sorting-exercise-wrapper-element .bg-contrast-theme-color.rounded {
    border-radius: 0.7rem !important;
}

:is(.calendar-assignment-detail, .workout-preview-light) .exercise-card-copy h6 {
    color: var(--bs-heading-color);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.3;
}

:is(.calendar-assignment-detail, .workout-preview-light) .exercise-card-copy small.text-muted {
    font-size: 0.8rem;
    line-height: 1.5;
}

:is(.calendar-assignment-detail, .workout-preview-light) .exercise-card-copy .badge.text-bg-secondary {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background-color: var(--calendar-preview-chip) !important;
    color: var(--bs-body-color) !important;
    font-size: 0.72rem;
    font-weight: 600;
}

/* A superset: its exercises on a soft surface under a calm brand chip, instead of the orange badge and bracket line */
:is(.calendar-assignment-detail, .workout-preview-light) [data-group-type="superset"] {
    padding: 0.5rem;
    border-radius: 1rem;
    background-color: var(--calendar-preview-superset);
}

:is(.calendar-assignment-detail, .workout-preview-light) [data-group-type="superset"] .badge.bg-mangofit-color {
    --bs-bg-opacity: 0.14;
    --bs-badge-color: var(--calendar-preview-brand-text);
    --bs-badge-padding-x: 0.6rem;
    --bs-badge-padding-y: 0.35rem;
    margin: 0.1rem 0 0.5rem 0.1rem !important;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

:is(.calendar-assignment-detail, .workout-preview-light) [data-group-type="superset"] .exercise-group-list {
    gap: 0.5rem;
    padding-left: 0;
    border-left: 0;
}

:is(.calendar-assignment-detail, .workout-preview-light) [data-group-type="superset"] .exercise-group-list .exercise-inner-wrapper::before {
    display: none;
}

/* A section: a soft frame, the band tinted in the brand colour with the name, the format chip in the brand colour and
   the targets as calm chips; its exercises on a soft surface */
:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) {
    --bs-card-border-radius: 1rem;
    --bs-card-inner-border-radius: calc(1rem - 1px);
    --bs-card-bg: var(--calendar-preview-surface);
    --bs-box-shadow-sm: none;
    border-color: var(--calendar-preview-line) !important;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-header {
    gap: 0.5rem !important;
    padding: 0.6rem 0.85rem;
    border-bottom: 0;
    background-color: var(--calendar-preview-band) !important;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-header > small.fw-bold {
    color: var(--bs-heading-color);
    font-size: 0.9rem;
    line-height: 1.3;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-header .badge {
    padding: 0.3rem 0.6rem;
    border: 0 !important;
    border-radius: 999px;
    background-color: var(--bs-body-bg) !important;
    color: var(--bs-secondary-color) !important;
    font-size: 0.72rem;
    font-weight: 600;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-header .badge.bg-mangofit-color {
    color: var(--calendar-preview-brand-text) !important;
    font-weight: 700;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-body {
    padding: 0.6rem !important;
}

:is(.calendar-assignment-detail, .workout-preview-light) .card:has(> .card-header) > .card-body > .flex-vertical-list {
    gap: 0.6rem;
}

/*----------------------------
    THE CLIENT'S PREVIEW BEFORE STARTING (#exercises_details_container of view_workout_card_details_modal; owner,
    2 December 2026: every set ran on one line and broke anywhere). With the light language above, each exercise card
    puts the image beside the name and the category, and the sets under them at the full width of the card, one soft
    row each. A value never breaks inside: a long set wraps between its values. The card keeps its markup
    (getExerciseDisplayTemplate is shared): its copy only lends name, sets and category to the grid
-----------------------------*/
.workout-preview-light .workout-sorting-exercise-wrapper-element.card :has(> .exercise-card-copy) {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "thumb name"
        "thumb category"
        "sets sets";
    column-gap: 0.85rem;
    align-items: center;
}

.workout-preview-light .workout-sorting-exercise-wrapper-element.card :has(> .exercise-card-copy) > :first-child {
    grid-area: thumb;
}

.workout-preview-light .exercise-card-copy,
.workout-preview-light .exercise-card-copy > .d-flex,
.workout-preview-light .exercise-card-copy > .d-flex > .flex-grow-1 {
    display: contents !important;
}

.workout-preview-light .exercise-card-copy h6 {
    grid-area: name;
    align-self: end;
    margin-bottom: 0.3rem !important;
}

.workout-preview-light .exercise-card-copy > .d-flex > .flex-shrink-0 {
    grid-area: category;
    align-self: start;
}

.workout-preview-light .exercise-card-copy small.text-muted {
    grid-area: sets;
    margin-top: 0.75rem;
}

.workout-preview-light .exercise-card-copy small.text-muted > div {
    display: grid;
    gap: 0.3rem;
}

.workout-preview-light .exercise-card-copy small.text-muted > div > div {
    padding: 0.35rem 0.65rem;
    border-radius: 0.6rem;
    background-color: var(--calendar-preview-superset);
    color: var(--bs-body-color);
    font-variant-numeric: tabular-nums;
}

.workout-preview-light .exercise-card-copy small.text-muted > div > div span {
    white-space: nowrap;
}

/* The yellow letter of a regular set reads on the soft row, as in the player */
.workout-preview-light .exercise-card-copy small.text-muted .text-warning[title] {
    color: var(--bs-warning-text-emphasis) !important;
}

/* The ▶ on the image of an exercise with a video opens it (openExerciseVideoTutorialPreview): the whole image is the
   button, with the focus ring of the app */
.workout-preview-light .exercise-video-tutorial-button {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    border-radius: 0.7rem;
    background: transparent;
    cursor: pointer;
}

.workout-preview-light .exercise-video-tutorial-button:focus-visible {
    outline: 2px solid rgba(var(--mangofit-color-rgb), 0.6);
    outline-offset: 2px;
}
