/* Shared page-layout primitives.
 *
 * These classes (page-header, content-card, flash-message, …) were historically
 * redefined in nearly every package stylesheet. They are promoted here so any
 * page gets consistent styling for free. Values use the global tokens from
 * style.css. Loaded globally in _header.html immediately after style.css, so a
 * package stylesheet (loaded later) can still override any of these locally.
 */

/* Page Header */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.page-title-section {
    /* Grow/shrink to fill the row; min-width:0 lets the title wrap instead of
       forcing the actions to squish. */
    flex: 1 1 auto;
    min-width: 0;
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-strong);
    margin: 0 0 var(--spacing-sm) 0;
    line-height: var(--leading-tight);
}

.page-subtitle {
    font-size: var(--text-md);
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
    /* Keep buttons at their natural size; when the row is too narrow the whole
       group wraps to its own line rather than squishing the buttons. */
    flex-shrink: 0;
}

/* Content Card */
.content-card {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* .content-card is a surface only. Opt into an inset with .content-card-padded; a child that
   must run edge to edge (a table wrapper, a divided list) opts back out with .content-card-bleed.
   See doc/design.md → Cards & panels. */
.content-card-padded {
    --card-padding: var(--spacing-lg);
    padding: var(--card-padding);
}

.content-card-padded > :first-child {
    margin-top: 0;
}

.content-card-padded > :last-child {
    margin-bottom: 0;
}

.content-card-bleed {
    margin-inline: calc(-1 * var(--card-padding, 0px));
}

/* 0,3,0 — must outrank the 0,2,0 first/last-child trims above. */
.content-card-padded > .content-card-bleed:first-child {
    margin-top: calc(-1 * var(--card-padding));
}

.content-card-padded > .content-card-bleed:last-child {
    margin-bottom: calc(-1 * var(--card-padding));
}

/* The outer cells take the card's inset so column text lines up with the padded content. */
.content-card-bleed > table :is(th, td):first-child {
    padding-left: var(--card-padding, 0px);
}

.content-card-bleed > table :is(th, td):last-child {
    padding-right: var(--card-padding, 0px);
}

/* The card's own border closes the table; a last-row divider would double it. */
.content-card-padded
    > .content-card-bleed:last-child
    > table
    > tbody:last-child
    > tr:last-child
    > :is(th, td) {
    border-bottom: none;
}

@media (max-width: 768px) {
    .content-card-padded {
        --card-padding: var(--spacing-md);
    }
}

/* Flash Messages */
.flash-message {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-lg);
    font-weight: 500;
    border-left: 4px solid;
}

/* The `display: flex` above outranks the UA's `[hidden] { display: none }`, so a
   placeholder banner renders as an empty coloured strip until this rule wins it back. */
.flash-message[hidden] {
    display: none;
}

.flash-message.error {
    background: var(--error-light-bg);
    color: var(--error-color);
    border-left-color: var(--error-color);
}

.flash-message.success {
    background: var(--success-light-bg);
    color: var(--success-color);
    border-left-color: var(--success-color);
}

.flash-message.warning {
    background: var(--warning-amber-bg);
    color: var(--warning-amber-text);
    border-left-color: var(--warning-amber);
}

.flash-message.info {
    background: var(--info-light-bg);
    color: var(--info-text-color);
    border-left-color: var(--info-color);
}

.flash-icon {
    font-size: var(--text-lg);
}

/* At-capacity banner for provider booking/availability surfaces. Matches the amber flash
   treatment but is toggled client-side (via [hidden]) rather than rendered from page data. */
.capacity-warning {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-lg);
    font-weight: 500;
    border-left: 4px solid var(--warning-amber);
    background: var(--warning-amber-bg);
    color: var(--warning-amber-text);
}

.capacity-warning[hidden] {
    display: none;
}
