body {
    font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
    margin: 0;
    color: #1a1a1a;
    background: #f7f7f8;
    font-size: 14px;
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.15rem;
}

/* --- Sidebar shell ------------------------------------------------------ */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e9e9ea;
    display: flex;
    flex-direction: column;
}

.admin-brand {
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
}

.admin-brand-logo {
    max-width: 100%;
    height: 36px;
    width: auto;
    object-fit: contain;
}

.admin-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow-y: auto;
    padding: 0 0.5rem;
}

.admin-nav-link,
.admin-nav-group summary {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #3a3a3d;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    border-radius: 6px;
    list-style: none;
}

.admin-nav-group summary::-webkit-details-marker {
    display: none;
}

.admin-nav-group summary::after {
    content: "\276F";
    float: right;
    font-size: 0.65rem;
    color: #a1a1a6;
    transition: transform 0.15s ease;
}

.admin-nav-group[open] summary::after {
    transform: rotate(90deg);
}

.admin-nav-link:hover,
.admin-nav-group summary:hover {
    background: #f2f2f3;
}

/* Unread-messages count next to "Messages" in the sidebar — same blue
   square the trainer portal uses (see trainer_layout.php). */
.admin-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    margin-left: 0.35rem;
    background: #0091ad;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 4px;
    line-height: 1;
}

.admin-nav-link.is-current {
    background: #111;
    color: #fff;
    font-weight: 600;
}

.admin-nav-children {
    display: flex;
    flex-direction: column;
    padding-left: 0.75rem;
}

.admin-nav-children a {
    padding: 0.4rem 0.75rem;
    color: #57575c;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
}

.admin-nav-children a:hover {
    background: #f2f2f3;
}

.admin-nav-children a.is-current {
    background: #ececee;
    color: #111;
    font-weight: 600;
}

/* A group nested inside another group (a third-plus sidebar level) reads
   a shade lighter than a top-level group, and its own children indent
   one more step in on top of the padding already inherited. */
.admin-nav-children .admin-nav-group summary {
    color: #57575c;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

.admin-lang-switcher {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    padding: 0.75rem 1.25rem;
}

.admin-lang-flag {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #b5b5ba;
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.admin-lang-flag:hover {
    background: #f2f2f3;
}

.admin-lang-flag.is-current {
    border-color: #b5b5ba;
    background: #f2f2f3;
}

.admin-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e9e9ea;
    font-size: 0.85rem;
    /* always in view: sticks to the bottom of the screen while the page scrolls */
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: #fff;
    box-shadow: 0 -6px 14px rgba(16, 23, 34, 0.06);
}

.admin-user-roles {
    color: #8a8a8f;
    margin-bottom: 0.5rem;
}

/* who is logged in: first name only, big */
.admin-user-name {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: #1a1a1a;
    margin-bottom: 0.2rem;
    overflow-wrap: anywhere;
}

/* logo at the very top of the sidebar, above the language flags */
.admin-brand--top {
    justify-content: center;
    padding: 1rem 1.25rem 0.2rem;
}

/* Dashboard and Feedback side by side, a little smaller */
.admin-quick {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.75rem 0.9rem;
}
.admin-quick .fb-wrap { margin-top: 0; gap: 0.25rem; }
.admin-quick .dash-btn,
.admin-quick .fb-open { font-size: 0.7rem; padding: 0.22rem 0.6rem; }
.admin-quick .dash-btn svg { width: 12px; height: 12px; }
.admin-quick .fb-info { width: 0.95rem; height: 0.95rem; font-size: 0.62rem; }

.admin-user form {
    margin: 0;
}

.admin-user button {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Mobile nav toggle: hidden entirely on desktop. On narrow screens this
   becomes a fixed hamburger button, and checking it unfolds the sidebar as a
   full-screen overlay instead of the desktop's side-by-side layout — see the
   max-width:700px block below. */
.admin-mobile-menu-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.admin-mobile-menu-btn,
.admin-mobile-menu-close {
    display: none;
}

/* Narrow screens: the sidebar is NOT shown by default — only the hamburger
   button is, fixed to the top-right corner so it stays put above everything
   else (including a page's own fixed header) no matter how far the page has
   scrolled. Checking the toggle unfolds the sidebar full-screen. */
@media (max-width: 700px) {
    .admin-mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 0.6rem;
        right: 0.6rem;
        z-index: 500;
        width: 2.5rem;
        height: 2.5rem;
        background: #101722;
        color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        font-size: 1.3rem;
        line-height: 1;
        cursor: pointer;
    }

    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-mobile-menu-toggle:checked ~ .admin-shell .admin-sidebar {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 400;
        width: 100%;
        height: 100%;
        overflow-y: auto;
        border-right: none;
    }

    .admin-mobile-menu-toggle:checked ~ .admin-mobile-menu-btn {
        display: none;
    }

    .admin-mobile-menu-close {
        display: block;
        align-self: flex-end;
        margin: 0.5rem 0.75rem 0;
        background: none;
        border: none;
        font-size: 1.8rem;
        line-height: 1;
        color: #3a3a3d;
        cursor: pointer;
    }
}

/* --- Content area -------------------------------------------------------- */

.admin-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1300px;
}

.admin-content-loggedout {
    max-width: 420px;
    margin: 4rem auto;
    padding: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: #fff;
}

th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
}

form label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    display: block;
    width: 100%;
    max-width: 480px;
    padding: 0.5rem 0.6rem;
    margin-top: 0.3rem;
    box-sizing: border-box;
    border: 1px solid #d8d8db;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

textarea {
    max-width: none;
}

/* --- Buttons -------------------------------------------------------------- */

button,
.btn {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    border: none;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    background: #111;
    color: #fff;
    text-decoration: none;
    text-align: center;
}

button:hover,
.btn:hover {
    background: #333;
}

.btn-dark {
    background: #111;
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: #111;
    border: 1px solid #d8d8db;
}

.btn-secondary:hover {
    background: #f2f2f3;
}

.btn-danger {
    background: #fff;
    color: #b3261e;
    border: 1px solid #f2c6c2;
}

.btn-danger:hover {
    background: #fdecea;
}

.btn-icon {
    background: none;
    color: #8a8a8f;
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
}

.btn-icon:hover {
    background: #f2f2f3;
    color: #b3261e;
}

/* --- Badges / pills -------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-published {
    background: #e6f4ea;
    color: #1e7a34;
}

.badge-draft {
    background: #f0f0f1;
    color: #6b6b70;
}

/* --- Pages list ------------------------------------------------------------ */

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.list-header h1 {
    margin: 0;
}

.search-input {
    max-width: 320px;
    margin-bottom: 1rem;
}

.page-list {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
}

.page-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f2f2f3;
}

.page-row:last-child {
    border-bottom: none;
}

.page-row:hover {
    background: #fafafa;
}

.page-row-icon {
    font-size: 1.2rem;
}

.page-row-main {
    flex: 1;
    min-width: 0;
}

.page-row-title {
    font-weight: 600;
}

.page-row-meta {
    color: #8a8a8f;
    font-size: 0.8rem;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: #8a8a8f;
    background: #fff;
    border: 1px dashed #ddd;
    border-radius: 10px;
}

/* --- Page builder ----------------------------------------------------------- */

.builder-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.builder-topbar-main {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

/* Deliberately reads as a heading rather than a form field — but it IS an
   editable input, so it gets a visible border on hover/focus. Without that
   affordance it looks like static text and people don't realize the page
   title is editable right there. */
.builder-title-input {
    font-size: 1.1rem;
    font-weight: 700;
    border: 1px solid transparent !important;
    border-radius: 6px;
    padding: 0.2rem 0.4rem !important;
    max-width: 420px !important;
    margin-top: 0 !important;
    cursor: text;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.builder-title-input:hover {
    border-color: #d8d8dd !important;
    background: #fafafb;
}

.builder-title-input:focus {
    outline: none;
    box-shadow: none;
    border-color: #8a8a8f !important;
    background: #fff;
}

.builder-slug {
    color: #8a8a8f;
    font-size: 0.85rem;
    white-space: nowrap;
}

.builder-topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.publish-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.875rem;
    white-space: nowrap;
}

.builder-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.builder-blocks {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.builder-region {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 0.85rem;
}

.page-settings-panel {
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
}

.page-settings-panel label {
    max-width: 480px;
}

/* Header/Footer/Stylesheet — kept together on one line when there's room,
   wrapping onto their own lines below that (each label's own 480px max-width
   above still applies once wrapped). Smaller than the rest of this panel
   since these are picked far less often than URL/Content layout above. */
.page-settings-compact-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.25rem;
    font-size: 0.85rem;
}

.page-settings-compact-row label {
    flex: 1 1 180px;
    max-width: 260px;
}

.builder-region-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #8a8a8f;
    margin-bottom: 0.6rem;
}

.block-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.3rem;
    border-radius: 6px;
}

.block-order-input {
    width: 3.2rem;
    max-width: none;
    margin: 0;
    padding: 0.25rem 0.35rem;
    font-size: 0.8rem;
    text-align: center;
    flex-shrink: 0;
}

.builder-order-hint {
    font-size: 0.75rem;
    color: #8a8a8f;
    margin: 0 0 0.5rem;
}

.block-row:hover {
    background: #fafafa;
}

/* Per-block width bar (Kajabi-style): click a cell to set 1-12 columns. */
.block-width {
    padding: 0 0.3rem 0.7rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid #eee;
}
.block-width-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #8a8a8f;
    margin-bottom: 0.25rem;
}
.block-width-bar {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
}
.block-width-cell {
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: #e3e7ea;
    cursor: pointer;
}
.block-width-cell.is-on {
    background: #8fbef7;
}
.block-width-cell:focus-visible {
    outline: 2px solid #04696c;
    outline-offset: 1px;
}
.block-position {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.35rem;
    font-size: 0.75rem;
}
.block-position label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    font-weight: 400;
}
.block-position input {
    width: auto;
    margin: 0;
}

.block-type-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}

.block-type-standard {
    background: #eef0ff;
    color: #4650c9;
}

.block-type-html {
    background: #fff2e0;
    color: #a15c00;
}

.block-type-php {
    background: #e9f7ee;
    color: #1e7a34;
}

.block-type-shared {
    background: #fde8f3;
    color: #a3186d;
}

.block-name {
    flex: 1;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.block-delete-form {
    margin: 0;
}

.add-block-btn {
    width: 100%;
    margin-top: 0.5rem;
    background: none;
    color: #4650c9;
    border: 1px dashed #c7cbf5;
    border-radius: 8px;
    font-weight: 600;
    padding: 0.45rem;
}

.add-block-btn:hover {
    background: #f5f6ff;
}

.builder-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-frame {
    width: 100%;
    height: 70vh;
    border: 1px solid #eee;
    border-radius: 10px;
    background: #fff;
}

.preview-note {
    color: #8a8a8f;
    font-size: 0.8rem;
    margin: 0;
}

.add-block-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* Without this, the "hidden" attribute has no visual effect: an author
   rule (.add-block-overlay's own "display: flex") wins over the browser's
   built-in "[hidden] { display: none }" at equal specificity, so the panel
   stayed visible the whole time regardless of the hidden attribute. */
.add-block-overlay[hidden] {
    display: none;
}

.add-block-panel {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.add-block-panel h3 {
    margin-top: 0;
}

.add-block-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.builder-advanced {
    margin-top: 1.5rem;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
}

.builder-advanced summary {
    cursor: pointer;
    font-weight: 600;
    color: #57575c;
}

.builder-advanced form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f2f2f3;
}

.builder-advanced form:first-of-type {
    border-top: none;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

/* --- Alerts ----------------------------------------------------------------- */

.error {
    background: #fdecea;
    color: #611a15;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    white-space: pre-line;
    margin-bottom: 1rem;
}

.success {
    background: #eaf6ec;
    color: #1e4620;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.warning {
    background: #fff4e5;
    color: #663c00;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #ffb74d;
}

/* --- Media library ------------------------------------------------------- */

.media-category-columns {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.media-category-columns > div {
    flex: 1;
    min-width: 280px;
}

.media-filter {
    margin-bottom: 1rem;
}

.media-filter select {
    max-width: 280px;
}

.media-upload-form {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

/* Scrolls independently of the page, so paging through a long list of
   images never scrolls the "Upload an image" form above it out of view. */
.media-image-grid-fold {
    max-height: 65vh;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 1rem;
    background: #fafafa;
}

.media-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 0;
}

.media-image-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-image-card img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
}

.media-image-meta {
    padding: 0.6rem 0.75rem 0;
    font-size: 0.8rem;
    color: #8a8a8f;
}

.media-image-alt {
    color: #3a3a3d;
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-image-card form {
    padding: 0.6rem 0.75rem 0.75rem;
    margin: 0;
}

.media-image-url {
    width: 100%;
    max-width: none;
    margin: 0.35rem 0 0;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    font-family: monospace;
    color: #57575c;
    background: #f7f7f8;
    border: 1px solid #eee;
    border-radius: 4px;
    box-sizing: border-box;
}

/* --- Block directory filters (Admin -> Blocks) ----------------------------- */
/* A plain GET form, so the selects sit on one row and stay usable when the
   list is long. Also reused on the block edit form for the same two fields. */
.block-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin: 0 0 1.25rem;
}

.block-filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    min-width: 12rem;
}

.block-filters .btn {
    margin-bottom: 0.1rem;
}

/* A softer, pill-shaped search box — used on Admin -> Blocks, reusable
   anywhere else a plain text-search input wants a friendlier look than
   the default boxy <input>. */
.search-pill {
    display: flex;
    align-items: center;
    background: #f5f5f7;
    border: 1px solid #e3e6ea;
    border-radius: 999px;
    padding: 0.2rem 0.2rem 0.2rem 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.search-pill:focus-within {
    background: #fff;
    border-color: #b8c9e0;
    box-shadow: 0 0 0 3px rgba(74, 130, 200, 0.15);
}

.search-pill input[type="search"] {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    min-width: 200px;
    color: #1a1a1a;
}

.search-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
    border: none;
    background: none;
    color: #1a1a1a;
    font-size: 1.05rem;
    cursor: pointer;
}

/* --- Day Grid (Admin -> Scheduler -> Day Grid) -------------------------- */

.dg-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.dg-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 1rem;
    position: sticky;
    top: 1rem;
}

.dg-sidebar h3 {
    margin: 0.75rem 0 0.4rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b6b70;
}

.dg-sidebar h3:first-child {
    margin-top: 0;
}

.dg-sidebar-check {
    display: block;
    font-size: 0.85rem;
    padding: 0.2rem 0;
}

.dg-main {
    flex: 1;
    min-width: 0;
}

/* the fold-away button for the trainer list, shown on phones only */
.dg-sidebar-toggle {
    display: none;
}

@media (max-width: 800px) {
    /* phone: trainer list above the grid, folded away until tapped */
    .dg-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .dg-sidebar-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0.65rem 0.9rem;
        background: #fff;
        border: 1px solid #e3e6ea;
        border-radius: 8px;
        font: inherit;
        font-weight: 600;
        color: #1a1a1a;
        cursor: pointer;
    }

    .dg-sidebar {
        display: none;
        width: auto;
        position: static;
    }

    .dg-sidebar.is-open {
        display: block;
    }

    /* names in two columns, so the list stays short */
    .dg-sidebar-check {
        display: inline-block;
        width: 49%;
        vertical-align: top;
    }
}

.dg-scroll {
    overflow-x: auto;
    margin: 1rem 0;
}

.dg-grid {
    /* Cell size lives here, not in the template, so the admin Day Grid and the
       trainer-portal one stay identical and there is one place to tune it.
       Narrow columns with a taller row let a booking wrap onto three or four
       lines instead of stretching the grid sideways. */
    --dg-col-min: 96px;
    --dg-row-h: 80px;

    /* There is no global border-box rule in this stylesheet, so min-width:100%
       plus the 1px borders below overflowed the scroller by exactly 2px and
       produced a permanent horizontal scrollbar. */
    box-sizing: border-box;
    display: grid;
    position: relative;
    /* Was max-content, which refused to shrink below the longest client name
       plus "10:00-11:00 - Location" on one line, so four trainers already
       pushed the grid off-screen. 100% lets the columns collapse to
       --dg-col-min and the text wrap; with enough trainers to genuinely
       overflow, .dg-scroll still scrolls. */
    min-width: 100%;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
}

.dg-corner,
.dg-header,
.dg-hour-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border-bottom: 1px solid #e9e9ea;
    border-right: 1px solid #e9e9ea;
    font-size: 0.85rem;
    font-weight: 600;
    /* A long trainer name must wrap rather than set the column width. */
    flex-wrap: wrap;
    text-align: center;
    overflow-wrap: anywhere;
    line-height: 1.2;
    padding: 0 0.15rem;
}

.dg-hour-label {
    font-weight: 400;
    color: #6b6b70;
    font-size: 0.8rem;
}

.dg-header--blocked {
    background: #4a4a4f;
    color: #fff;
    flex-direction: column;
    line-height: 1.3;
}

.dg-header--blocked small {
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75);
}

.dg-cell {
    border-bottom: 1px solid #f0f0f1;
    border-right: 1px solid #f0f0f1;
    transition: background-color 0.1s;
}

/* Per-hour availability shading, for every trainer, from
   TrainerAvailability::colorGrid() — matches Trainer Availability /
   Trainer Blockouts. White (the plain .dg-cell background) is
   "available"; already-booked hours are left unshaded here since the
   booking's own dg-block, drawn on top, carries that trainer's color. */
.dg-cell--conditional {
    background: #c9c9ce;
}

.dg-cell--unavailable {
    background: #1a1a1a;
}

/* A trainer away/off the whole day (dg-header--blocked) still has a
   cursor cue, but its hours are shaded the same red/black as anyone
   else's unavailable hours (below) rather than forced white — see the JS
   guard that excludes these from dropzone candidates regardless of color. */
.dg-cell--blocked {
    cursor: not-allowed;
}

.dg-cell--dropzone {
    background: #f2f7ff;
}

.dg-cell--dropzone-over {
    background: #cfe3ff;
}

.dg-block {
    margin: 2px;
    padding: 0.25rem 0.35rem;
    border-radius: 6px;
    background: #111;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    cursor: grab;
    z-index: 1;
    font-size: 0.75rem;
    /* Wrap onto three or four short lines in a narrow column instead of
       demanding the width for one long line. anywhere (not break-word) so a
       single long surname cannot widen the column on its own. */
    line-height: 1.2;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* A one-hour block is the tight case: --dg-row-h less its margin and padding
   is all the room there is. Give the client name up to three lines and the
   time/location exactly one, so the worst case is four lines and always fits.
   Without these clamps a long name simply ran out of the bottom of the block. */
.dg-block strong {
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dg-block small {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.68rem;
    line-height: 1.15;
    /* Secondary detail, so this is what gets cut rather than the name. The
       hour comes first and survives; the full text is in the booking dialog. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dg-block--noshow {
    background: #8a8a8f;
    cursor: default;
}

/* A booking whose trainer is blocked out for this exact hour with no
   automatic replacement found (see DayGridController::index()'s
   needsReassignmentBookingIds) — displaying it as an ordinary booked
   block would misleadingly suggest this trainer can actually train this
   client, so it gets a hazard-striped background instead of the usual
   flat client color, regardless of that client's own color. */
.dg-block--needs-reassignment {
    background: repeating-linear-gradient(45deg, #b3392f, #b3392f 8px, #7a251e 8px, #7a251e 16px) !important;
    border: 1px solid #5c1a15;
}

/* --- Generic admin confirmation modal (native <dialog>) ------------------ */

.adm-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, 92vw);
    max-height: 85vh;
    overflow-y: auto;
    border: none;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.adm-modal::backdrop {
    background: rgba(20, 20, 22, 0.5);
}

.dg-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: #8a8a8f;
    cursor: pointer;
}

.dg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.85rem;
    color: #57575c;
    margin: 0 0 1rem;
}

.dg-legend-swatch {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    margin-right: 0.35rem;
    vertical-align: middle;
}

/* --- Date navigation tiles ------------------------------------------------ */

.dg-date-nav {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.dg-date-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.5rem 0.85rem;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    text-decoration: none;
    color: #1a1a1a;
    min-width: 6rem;
}

a.dg-date-tile:hover {
    border-color: #b5b5ba;
    background: #fafafa;
}

a.dg-date-tile.is-active {
    border-color: #111;
    background: #111;
    color: #fff;
}

a.dg-date-tile.is-active .dg-date-tile-label {
    color: rgba(255, 255, 255, 0.75);
}

.dg-date-tile-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b6b70;
}

.dg-date-tile-date {
    font-size: 0.9rem;
    font-weight: 600;
}

/* The currently-viewed date — same font as the page's own <h1> (see the
   body/h1 rules at the top of this file), just sized to sit comfortably
   in a tile — so it reads as the visual anchor of the row, not just
   another button. */
.dg-date-tile--current {
    background: #f2f4f7;
    border-color: #d7dbe0;
    min-width: 14rem;
    flex: 1 1 auto;
    align-items: center;
    text-align: center;
}

.dg-date-tile-big {
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 700;
}

.dg-override-warning {
    background: #fff8e6;
    border: 1px solid #f0d88c;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.dg-override-warning p {
    margin-top: 0;
}

/* --- Booking List panel (above the Day Grid) ----------------------------- */

.dg-booking-list {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.dg-chip-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dg-chip-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dg-chip {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
}

.dg-chip--assigned {
    background: #f2f4f7;
    color: #4a4a4f;
}

/* Same trigger as .dg-block--needs-reassignment (see DayGridController::
   index()'s needsReassignmentBookingIds) — a chip naming a trainer who's
   actually blocked out for that exact hour, with no automatic
   replacement found. */
.dg-chip--needs-reassignment {
    background: #fdecea;
    color: #7a251e;
    border: 1px solid #e8a49c;
}

.dg-chip--unassigned {
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f2c6c2;
    cursor: grab;
}

.dg-chip--unassigned:hover {
    background: #f9d9d5;
}

/* --- Client Schedule (Admin -> Training -> Client Schedule) -------------- */

.cs-chip {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.cs-chip--unassigned {
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f2c6c2;
    text-shadow: none;
}

/* Tap-to-select feedback (the touch-friendly alternative to dragging —
   see day_grid.php's wireSource()/clearSelection()) on both a chip and an
   already-placed block. */
.dg-chip.is-selected,
.dg-block.is-selected {
    outline: 3px solid #111;
    outline-offset: 1px;
}
