/* ==========================================================================
   App styles: Bootstrap 5.3 shell (dark sidebar + header + scrollable content)
   plus small app-level customizations. Loaded after bootstrap.min.css and the
   Kendo bundles in _Host.cshtml, so rules here win ties.
   ========================================================================== */

:root {
    --app-sidebar-width: 250px;
    --app-sidebar-bg: #1e1e2d;
    --app-sidebar-color: #9d9da6;
    --app-sidebar-muted-color: #6d6d80;
    --app-sidebar-hover-bg: #2a2a3c;
    --app-sidebar-active-bg: #2a2a3c;
    --app-sidebar-active-color: #ffffff;
    --app-header-height: 60px;
}

/* --------------------------------------------------------------------------
   Shell layout. The page itself never scrolls; .app-content is the scroll
   container (so the header/toolbar stay put and grids can own their height).
   -------------------------------------------------------------------------- */

html,
body {
    height: 100%;
    font-size: 12px;
}

.app-root {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar: static column >= lg, Bootstrap offcanvas drawer below lg.
   Bootstrap's .offcanvas-lg forces background-color transparent above the
   breakpoint, hence the !important here (app.css loads later, so it wins). */
.app-sidebar {
    --bs-offcanvas-width: var(--app-sidebar-width);
    background-color: var(--app-sidebar-bg) !important;
    color: var(--app-sidebar-color);
}

@media (min-width: 992px) {
    .app-sidebar {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        width: var(--app-sidebar-width);
        height: 100vh;
    }
}

.app-sidebar-logo {
    display: flex;
    align-items: center;
    min-height: var(--app-header-height);
    padding: 1rem 1.5rem;
}

/* Bootstrap's .nav wraps (flex-wrap: wrap), which turns a tall menu into a second column;
   keep it one column that scrolls. min-height: 0 lets it shrink below its content so
   overflow-y can take over, and its items keep their height instead of being squeezed. */
.app-sidebar-menu {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem;
}

.app-sidebar-menu > * {
    flex-shrink: 0;
}

.app-sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1.5rem 1.25rem;
    font-size: 0.85rem;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: 0.475rem;
    color: var(--app-sidebar-color);
    font-weight: 500;
}

.app-sidebar .nav-link:hover:not(.disabled),
.app-sidebar .nav-link:focus-visible {
    color: var(--app-sidebar-active-color);
    background-color: var(--app-sidebar-hover-bg);
}

.app-sidebar .nav-link.active {
    color: var(--app-sidebar-active-color);
    background-color: var(--app-sidebar-active-bg);
}

.app-sidebar .nav-link.disabled {
    color: var(--app-sidebar-muted-color);
}

.app-sidebar .nav-link .app-menu-icon {
    display: inline-flex;
    flex-shrink: 0;
    width: 1.25rem;
    justify-content: center;
}

/* Collapsible sidebar groups ("Dashboards", "Setup"). */
.app-sidebar .app-menu-group-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: start;
}

.app-menu-chevron {
    display: inline-flex;
    margin-left: auto;
    transition: transform 0.15s ease;
}

.app-menu-chevron.collapsed {
    transform: rotate(-90deg);
}

/* Collapsible card headers (CollapseChevron): Bootstrap marks the toggle "collapsed" when closed. */
.collapse-chevron {
    display: inline-flex;
    transition: transform 0.15s ease;
}

.collapsible.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

.app-submenu {
    padding-left: 1rem;
}

/* Main column (header + toolbar + scrollable content + footer). */
.app-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-height: var(--app-header-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
}

.app-toolbar {
    flex-shrink: 0;
    padding: 0.75rem 1.5rem;
}

.app-content {
    flex: 1 1 auto;
    height: 0;
    overflow-y: scroll;
    padding: 0 1.5rem;
}

.layout-footer {
    flex-shrink: 0;
    padding: 0.5rem 1.5rem;
    container-type: inline-size;
    container-name: layout-footer;
}

/* --------------------------------------------------------------------------
   Theme helpers. data-bs-theme lives on <html> (see app.js); these classes
   show/hide an element per effective theme (used for light/dark logo pairs
   and error illustrations).
   -------------------------------------------------------------------------- */

[data-bs-theme="dark"] .theme-light-show {
    display: none !important;
}

:root:not([data-bs-theme="dark"]) .theme-dark-show {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Full-screen page loader (shown until the Blazor circuit renders; see
   _Host.cshtml + appShell.hidePageLoader in app.js).
   -------------------------------------------------------------------------- */

#app-page-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background-color: var(--bs-body-bg);
    transition: opacity 0.2s ease-out;
}

#app-page-loader.app-page-loader-hidden {
    opacity: 0;
    visibility: hidden;
}

/* --------------------------------------------------------------------------
   Grid/Kendo tweaks (ported from the old style.scss customizations).
   -------------------------------------------------------------------------- */

.k-grid-header .k-header {
    white-space: normal !important;
    line-height: 1.2;
}

.k-header .k-column-title {
    white-space: normal !important;
    line-height: 1.2;
}

.vis-hidden {
    visibility: hidden;
}

.form-group {
    margin-bottom: 0.5rem !important;
}

.form-group > .k-switch {
    margin-left: 0.75rem !important;
}

.stacked-switch {
    display: flex !important;
    margin: 0.5rem;
}

/* Day/week toggles for a course's default recurrence: equal widths, and clearly "on" when selected */
.recurrence-toggle {
    min-width: 3.25rem;
}

/* The seven weekday toggles share one row evenly, down to phone width */
.recurrence-days .recurrence-toggle {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 0.25rem;
}

.recurrence-toggle.k-selected {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: #fff !important;
}

/* Over-enrollment warnings (informational only). The icon uses the theme's warning colour;
   the explanatory text uses its emphasis shade, which stays readable in light and dark. */
.enrollment-warning .k-svg-icon,
.enrollment-warning-text .k-svg-icon {
    color: var(--bs-warning);
}

.enrollment-warning-text {
    font-size: 0.8rem;
    color: var(--bs-warning-text-emphasis);
}

/* Events grid: the leader has checked in (when and how on hover) */
.leader-checked-in .k-svg-icon {
    color: var(--bs-success);
}

/* Course Calendar tab: one month calendar per grid cell, with room in each day for event items */
.course-calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}

/* Term Calendar page: items also carry the course title, so give each day more room */
.course-calendar-grid-wide {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
}

/* Equal day columns, so a long title is cut short (ellipsis) rather than widening its column */
.course-calendar-grid-wide .k-calendar-table {
    table-layout: fixed;
}

.course-calendar.k-calendar,
.course-calendar .k-calendar-view,
.course-calendar .k-calendar-table {
    width: 100%;
    box-sizing: border-box;     /* The view's padding would otherwise push Saturday past the edge */
}

.course-calendar .k-calendar-td {
    vertical-align: top;
}

/* A light frame around every day (the cells holding a .cc-day, so the blanks before the 1st and
   after the last stay unframed), spaced apart so neighbouring frames don't double up */
.course-calendar .k-calendar-table {
    border-collapse: separate !important;
    border-spacing: 2px !important;
}

.course-calendar .k-calendar-td:has(.cc-day) {
    border: 1px solid var(--bs-border-color) !important;
    border-radius: 4px;
}

/* Today: a heavier frame (the inset shadow thickens it without shifting the cell) */
.course-calendar .k-calendar-td:has(.cc-today) {
    border-color: var(--bs-primary) !important;
    box-shadow: inset 0 0 0 1px var(--bs-primary);
}

/* Each calendar is pinned to one month: no navigation, and the month name reads as a heading.
   !important: the Kendo bundles' rules are scoped under [data-bs-theme], which outranks these. */
.course-calendar .k-calendar-nav {
    display: none !important;
}

.course-calendar .k-calendar-title,
.course-calendar .k-calendar-title.k-disabled {
    color: var(--bs-body-color) !important;
    font-weight: 600;
    opacity: 1 !important;
}

.course-calendar .k-calendar-td .k-link {
    width: 100%;
    height: auto;
    min-height: 3.25rem;
    padding: 2px;
    display: block;
    border-radius: 4px;
}

/* Every day is the same height: the date line plus room for --cc-visible-items events (keep in
   step with VisibleItems in _EventCalendarView). A busier day's events scroll inside it. */
.course-calendar {
    --cc-visible-items: 5;
    --cc-item-height: calc(0.7rem * 1.35);  /* .cc-item font-size × line-height */
    --cc-item-gap: 1px;
}

.course-calendar .cc-day {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
}

.course-calendar .cc-day-head {
    display: flex;
    align-items: center;
    gap: 2px;
}

.course-calendar .cc-date {
    margin-left: auto;      /* Right-aligned; the count pills sit at the left */
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: right;
}

/* A busy day's event count, beside the date: says there's more than fits. Red/yellow pills after
   it count the day's warning events, so their colour shows even while they're scrolled away. */
.course-calendar .cc-count {
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.4;
    background-color: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    cursor: default;
}

.course-calendar .cc-count.cc-needs {
    background-color: var(--bs-danger);
    color: #fff;
}

.course-calendar .cc-count.cc-capacity {
    background-color: var(--bs-warning);
    color: #212529;
}

.course-calendar .cc-events {
    display: flex;
    flex-direction: column;
    gap: var(--cc-item-gap);
    height: calc(var(--cc-visible-items) * var(--cc-item-height) + (var(--cc-visible-items) - 1) * var(--cc-item-gap));
    overflow-y: auto;
    overscroll-behavior: contain;   /* Reaching a day's end doesn't start scrolling the page */
    scrollbar-width: thin;
}

.course-calendar .cc-events > .cc-item {
    flex-shrink: 0;
}

/* More than fits: the last line fades out to hint at the rest. The bottom padding lets the last
   event scroll clear of the fade. */
.course-calendar .cc-events.cc-overflow {
    padding-bottom: var(--cc-item-height);
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--cc-item-height)), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - var(--cc-item-height)), transparent);
}

.cc-item {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 3px;
    padding: 0 2px;
    font-size: 0.7rem;
    line-height: 1.35;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Solid, so it stands out on both the light and dark calendar backgrounds */
    background-color: var(--bs-primary);
    color: #fff;
    cursor: pointer;
}

.cc-item.cc-needs {
    background-color: var(--bs-danger);
    color: #fff;
}

/* Over-enrollment: yellow, one step below the red "needs a leader/sponsor" */
.cc-item.cc-capacity {
    background-color: var(--bs-warning);
    color: #212529;
}

.cc-item.cc-legend {
    display: inline-block;
    width: auto;
    cursor: default;
}

.course-calendar .cc-outside-term .cc-date {
    opacity: 0.5;
}

.activity-icon .svg-icon svg {
    width: 45px;
    height: 45px;
    margin-right: 1rem;
}

.activity-icon-small .svg-icon svg {
    width: 30px;
    height: 30px;
    margin-right: 1rem;
}

.activity-icon-small .k-avatar {
    width: 30px !important;
    height: 30px !important;
    margin-right: 1rem;
}

.activity-icon-xtra-small .svg-icon svg {
    width: 20px !important;
    height: 20px !important;
    margin-right: 0.5rem !important;
}

.activity-icon-xtra-small .k-avatar {
    width: 20px !important;
    height: 20px !important;
    margin-right: 0.5rem !important;
}

.activity-icon-xtra-small .k-avatar-text,
.activity-icon-xtra-small .k-avatar-initials {
    font-size: 0.75rem !important;
    line-height: 3 !important;
}

/* Avatars inside grid cells (e.g. the Users grid's Name column): small enough not to grow rows */
.grid-avatar .k-avatar {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;      /* k-avatar-lg sets a 48px flex-basis, which beats width in a flex row */
}

.grid-avatar .k-avatar-text,
.grid-avatar .k-avatar-initials {
    font-size: 0.8rem !important;
}

.activity-stream-card-title {
    display: flex;
    align-items: center;
}

.activity-stream-filter {
    margin-left: auto;
}

.activity-stream-card {
    container-type: inline-size;
    container-name: activity-stream;
}

@container activity-stream (max-width: 700px) {
    .activity-stream-filter-spread {
        display: none;
    }
}

@container activity-stream (min-width: 700px) {
    .activity-stream-filter-collapsed {
        display: none;
    }
}

@container activity-stream (max-width: 860px) {
    .activity-stream-filter-w-sales-spread {
        display: none;
    }
}

@container activity-stream (min-width: 860px) {
    .activity-stream-filter-w-sales-collapsed {
        display: none;
    }
}

.activity-body {
    min-width: 0;
}

.activity-body p {
    margin: 0 0 0.2rem !important;
}

.activity-reply {
    padding-top: 5px;
}

.cazecc-window {
    height: 50vh;
    width: 50vw;
}

.cazecc-window-tall {
    height: 75vh !important;
}

@media (max-width: 875px) {
    .cazecc-window {
        width: 60vw !important;
    }
}

@media (max-width: 675px) {
    .cazecc-window {
        width: 70vw !important;
    }
}

@media (max-width: 580px) {
    .cazecc-window {
        width: 90vw !important;
    }
}

/* Predefined Telerik dialogs (DialogFactory AlertAsync/ConfirmAsync/PromptAsync render with
   .k-alert and no width, so they size to their text). House rule: modals are 450px max so
   they fit a phone screen; the calc keeps a 16px gutter on each side below that. */
.k-dialog.k-alert {
    width: 450px;
}

/* Every dialog (including those with an explicit Width="450px") shrinks to fit screens
   narrower than its width, and never outgrows the viewport height (the content area
   scrolls instead). The 16px gutter each side matches the phone-width layout rule. */
.k-dialog {
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
}

.hide-upload-actions .k-actions {
    display: none;
}

.k-editor-content p {
    margin: 0 0 0.2rem !important;
}

div.k-card-body:has(> div.collapse:not(.show)) {
    display: none;
}

.text-suffix {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
    padding-right: 4px;
    font-size: 0.7em;
    margin-bottom: 0px;
}

.k-button:disabled,
.k-button.k-disabled {
    pointer-events: auto !important;
}
