@media screen and (width > 768px) { /* breakpoint “md” and above in Bootstrap */
    .modal-right-aside-panel-content {
        max-width: 260px !important;
    }

    .modal-left-aside-panel-content {
        max-width: 380px !important;
    }
}

/*------------------------
    MODAL HEADER
-------------------------*/
.modal-title {
    font-weight: bold;
    color: var(--contrast-theme-color);
}

/* A long title (also a word without spaces) wraps instead of pushing the close button out of the screen */
.modal-header .modal-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

/*------------------------
    WINDOW FRAME (docs/windows.md)
    Every <x-templates.modal_template> window (.mg-modal-frame) has the frame of the activity editor: no line under the
    header or over the footer; a light shadow appears only while the body scrolls under them (data-scrolled and
    data-more-below on .modal-content, set by MangofitScrollEdges in common/utils/scroll_edges.js). Placement stays
    Bootstrap's own (modal-dialog-centered, modal-dialog-scrollable, modal-fullscreen-*-down).
-------------------------*/
.modal.mg-modal-frame {
    --bs-modal-header-border-width: 0;
    --bs-modal-footer-border-width: 0;
    --mg-modal-edge-shadow-down: 0 10px 14px -12px rgba(0, 0, 0, 0.32);
    --mg-modal-edge-shadow-up: 0 -10px 14px -12px rgba(0, 0, 0, 0.32);
}

[data-bs-theme="dark"] .modal.mg-modal-frame {
    --mg-modal-edge-shadow-down: 0 12px 16px -10px rgba(0, 0, 0, 0.9);
    --mg-modal-edge-shadow-up: 0 -12px 16px -10px rgba(0, 0, 0, 0.9);
}

/* The header stays above the footer, so a menu opened from the header is never covered by it */
:where(.mg-modal-frame > .modal-dialog > .modal-content) > .modal-header {
    position: relative;
    z-index: 3;
    transition: box-shadow 0.2s ease;
}

:where(.mg-modal-frame > .modal-dialog > .modal-content) > .modal-footer {
    position: relative;
    z-index: 2;
    transition: box-shadow 0.2s ease;
}

/* Only when the body follows the header directly: content placed between them keeps its own edge */
:where(.mg-modal-frame > .modal-dialog > .modal-content)[data-scrolled] > .modal-header:has(+ .modal-body) {
    box-shadow: var(--mg-modal-edge-shadow-down);
}

:where(.mg-modal-frame > .modal-dialog > .modal-content)[data-more-below] > .modal-footer {
    box-shadow: var(--mg-modal-edge-shadow-up);
}

/* One title size in every window (the size of the activity editor's title); a title with its own feature class keeps
   its metrics (:where adds no weight) */
:where(.mg-modal-frame .modal-header) .modal-title {
    font-size: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
    :where(.mg-modal-frame > .modal-dialog > .modal-content) > .modal-header,
    :where(.mg-modal-frame > .modal-dialog > .modal-content) > .modal-footer {
        transition: none;
    }
}

/*------------------------
    WINDOWS FROM THE BOTTOM ON THE PHONE (docs/windows.md «Posizione delle finestre»)
    .modal_slide_effect_from_bottom_mobile, with modal-fullscreen-md-down and modal-dialog-centered on the dialog: under
    768 px the window rises from the bottom as a sheet (full width, as tall as its content up to 600 px, top corners
    rounded, never taller than the screen), with the frame above; from 768 px Bootstrap centres it. The body scrolls
    inside the sheet, so MangofitScrollEdges still draws the shadows. No safe-area insets: the app WebView already sits
    between the system bars (AGENTS.md «Pages inside the app WebView»).
-------------------------*/
@media (max-width: 767.98px) {
    .modal.modal_slide_effect_from_bottom_mobile .modal-header .circle-icon-button[data-bs-dismiss="modal"],
    #athleteInfoModal .modal-header .circle-icon-button[data-bs-dismiss="modal"] {
        min-width: 2.5rem;
        min-height: 2.5rem;
    }

    .bmi-window .modal-footer .mg-action-button,
    #athleteInfoModal .modal-footer .mg-action-button {
        min-height: 2.5rem;
    }

    .modal.modal_slide_effect_from_bottom_mobile .modal-dialog {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: auto;
        min-height: 0;
        margin: 0;
        -webkit-animation: fade-in-from-bottom 0.6s ease forwards;
        animation: fade-in-from-bottom 0.6s ease forwards;
    }

    .modal.modal_slide_effect_from_bottom_mobile .modal-dialog > .modal-content {
        height: auto;
        max-height: min(600px, calc(100vh - 1.5rem));
        max-height: min(600px, calc(100dvh - 1.5rem));
        border: 0;
        border-radius: 1.2rem 1.2rem 0 0 !important;
        box-shadow: 0 -0.5rem 1.5rem rgba(0, 0, 0, 0.16);
    }
}

@media (max-width: 767.98px) and (prefers-reduced-motion: reduce) {
    .modal.modal_slide_effect_from_bottom_mobile .modal-dialog {
        -webkit-animation: none;
        animation: none;
    }
}

/*------------------------
    COMMENTS WINDOW (training_comments.blade.php, PT and client)
    Without the line over the footer the text field needs a look of its own: the soft pill of the chat composer.
-------------------------*/
#training_comments_modal .training-comment-input {
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 1.25rem;
    background-color: var(--bs-secondary-bg);
}

#training_comments_modal .training-comment-input:focus {
    background-color: var(--bs-secondary-bg);
    box-shadow: 0 0 0 0.15rem rgba(var(--mangofit-color-rgb), 0.25) !important;
}

/*------------------------
    MODAL RIGHT ASIDE PANEL
-------------------------*/
.modal-right-aside-panel-content {
    min-width: 260px;
}

.modal-left-aside-panel-content {
    min-width: 380px;
}

.stacked-modal {
    backdrop-filter: brightness(0.6) !important;
}
