:root {
    --color-proposed:  #f59e0b;
    --color-planned:   #3b82f6;
    --color-confirmed: #10b981;
    --color-cancelled: #9ca3af;
    --color-blocked:   #6b7280;
    --color-conflict:  #ef4444;

    --color-bg:     #ffffff;
    --color-text:   #1f2937;
    --color-muted:  #6b7280;
    --color-border: #e5e7eb;
    --color-hover:  #f3f4f6;
    --color-link:   #1d4ed8;

    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-stack);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.45;
    font-size: 14px;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }

.site-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    background: #fafafa;
}
.site-header .brand { font-weight: 600; font-size: 18px; }
.site-header .subtitle { color: var(--color-muted); font-size: 13px; margin-top: 4px; }

.site-footer {
    margin-top: 32px; padding: 16px 24px;
    color: var(--color-muted); font-size: 12px; text-align: center;
    border-top: 1px solid var(--color-border);
}

/* Flashes */
.flash-list { margin-bottom: 16px; }
.flash {
    padding: 10px 14px; border-radius: 6px; margin-bottom: 8px;
    border-left: 4px solid var(--color-muted);
    background: #f9fafb;
}
.flash-success { border-left-color: var(--color-confirmed); }
.flash-error   { border-left-color: var(--color-conflict); background: #fef2f2; }
.flash-warn    { border-left-color: var(--color-proposed); }
.flash-info    { border-left-color: var(--color-planned); }

/* View toggle */
.view-toggle, .nav-toggle {
    display: inline-flex; gap: 4px; margin: 0 8px 16px 0;
    border: 1px solid var(--color-border); border-radius: 6px; overflow: hidden;
}
.view-toggle-btn, .nav-toggle a {
    padding: 6px 12px; background: #fff; color: var(--color-text);
    border-right: 1px solid var(--color-border);
}
.view-toggle-btn:last-child, .nav-toggle a:last-child { border-right: none; }
.view-toggle-btn.active { background: var(--color-link); color: #fff; }
.view-toggle-btn:hover, .nav-toggle a:hover { background: var(--color-hover); text-decoration: none; }

/* Calendar */
.calendar { margin-bottom: 32px; }
.cal-title { margin: 12px 0; font-size: 18px; }

.month-grid, .week-grid {
    width: 100%; border-collapse: collapse; table-layout: fixed;
}
.month-grid th { text-align: left; padding: 6px; font-size: 12px; color: var(--color-muted); border-bottom: 1px solid var(--color-border); }
.month-grid td.day {
    border: 1px solid var(--color-border);
    min-height: 110px; vertical-align: top; padding: 4px;
    background: #fff;
}
.month-grid td.day-out { background: #f9fafb; color: var(--color-muted); }
.month-grid td.day-today { box-shadow: inset 0 0 0 2px var(--color-link); }
.month-grid td.day-blocked { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f3f4f6 6px, #f3f4f6 12px); }
.month-grid td.day-conflict { background: #fef2f2; }
.day-num { font-weight: 600; font-size: 12px; margin-bottom: 4px; }

.week-grid th.day-cell {
    width: 80px; vertical-align: top; padding: 8px;
    border-bottom: 1px solid var(--color-border);
}
.week-grid td.day-events {
    border-bottom: 1px solid var(--color-border);
    padding: 8px;
}
.week-grid .dow { display: block; font-size: 12px; color: var(--color-muted); }
.week-grid .dom { display: block; font-size: 22px; font-weight: 600; }
.week-grid .mon { display: block; font-size: 12px; color: var(--color-muted); }

/* Session blocks */
.session-block {
    display: block; padding: 3px 6px; margin-bottom: 3px;
    border-radius: 4px; font-size: 11px; line-height: 1.3;
    background: #eef2ff; color: #1e1e1e; border-left: 3px solid var(--color-planned);
    white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}
.session-block .label { display: inline; }
.session-block.status-proposed  { border-left-color: var(--color-proposed);  background: #fef3c7; }
.session-block.status-planned   { border-left-color: var(--color-planned);   background: #dbeafe; }
.session-block.status-confirmed { border-left-color: var(--color-confirmed); background: #d1fae5; }
.session-block.status-cancelled { border-left-color: var(--color-cancelled); background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.session-block.status-blocked   { border-left-color: var(--color-blocked);   background: #f3f4f6; color: #4b5563; font-style: italic; }

/* Customer-coloured override: when --event-color is set inline (only on
   full-visibility, non-cancelled rows), the per-customer colour takes
   precedence over the status palette. Status is conveyed by the pill
   inside the block, so the border stays solid for a clean continuous
   edge regardless of how many lines the event wraps to. */
.session-block[style*="--event-color"] {
    border-left-color: var(--event-color);
    background: color-mix(in srgb, var(--event-color) 18%, white);
}

.session-block.is-blocked       { font-style: italic; opacity: 0.85; }
.session-block.is-conflict      { box-shadow: 0 0 0 2px var(--color-conflict); }
/* Admin-only red treatment for unconfirmed trainings whose customer hold
   period has elapsed — pushes past the customer-colour override at the
   [style*="--event-color"] selector below. */
.session-block.is-hold-expired,
.session-block.is-hold-expired[style*="--event-color"] {
    border-left-color: var(--color-conflict);
    background: #fee2e2;
}
.session-block .time { font-weight: 600; margin-right: 4px; }
.session-block .icon { margin-right: 4px; opacity: 0.65; }
.conflict-flag { color: var(--color-conflict); font-weight: 700; }
.session-block .conflict-flag { margin-left: 4px; }
.hold-expired-flag { color: var(--color-conflict); font-weight: 700; margin-left: 4px; }

/* Trainings list view: tint the row + show a small inline badge so
   hold-expired entries are findable without opening each one. */
.admin-table tr.row-hold-expired td { background: #fef2f2; }
.hold-expired-badge {
    display: inline-block; margin-left: 6px;
    padding: 0 6px; border-radius: 999px;
    font-size: 10px; font-weight: 700;
    color: #fff; background: var(--color-conflict);
    text-transform: uppercase; letter-spacing: 0.05em;
    vertical-align: middle;
}

/* Status pill — small tag inside each session block showing status name +
   colour, since the block's main colour now reflects the customer rather
   than the status. */
.status-pill {
    display: inline-block;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    text-decoration: none;
    vertical-align: middle;
}
.status-pill.status-proposed  { background: var(--color-proposed); }
.status-pill.status-planned   { background: var(--color-planned); }
.status-pill.status-confirmed { background: var(--color-confirmed); }
.status-pill.status-cancelled { background: var(--color-cancelled); }
/* Don't carry the cancelled strikethrough into the pill itself. */
.session-block.status-cancelled .status-pill { text-decoration: none; }

/* Admin-only: the pill is rendered as a <select>. Strip native chrome and
   paint a small ▾ chevron via SVG data-URL so it reads as a menu. The
   surrounding <a>'s click is suppressed in JS so opening the dropdown
   doesn't open the training edit modal.

   Specificity note: the status colour rules above use `.status-pill.status-*`
   (0,2,0) and write `background:` shorthand, which clobbers
   `background-image`. We match their specificity with `.status-pill.status-pill-select`
   and rely on source order so the chevron wins. */
.status-pill.status-pill-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    cursor: pointer;
    height: auto;
    line-height: 1.5;
    padding-right: 16px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4.5l4 4 4-4' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
    background-position: right 3px center;
    background-size: 9px 9px;
    background-repeat: no-repeat;
}
/* Re-apply status backgrounds *after* the chevron rule's background-image
   so the colour stays solid and the chevron stays on top. */
.status-pill.status-pill-select.status-proposed  { background-color: var(--color-proposed); }
.status-pill.status-pill-select.status-planned   { background-color: var(--color-planned); }
.status-pill.status-pill-select.status-confirmed { background-color: var(--color-confirmed); }
.status-pill.status-pill-select.status-cancelled { background-color: var(--color-cancelled); }
.status-pill.status-pill-select:focus { outline: 1px solid #fff; outline-offset: -2px; }
.status-pill.status-pill-select option { color: #1f2937; background: #fff; }

/* Delivery-mode pill — surfaced on the anonymous public view for
   open-enrollment events so visitors know up-front whether the session
   is virtual, in-person, or hybrid. Neutral grey to differentiate from
   the status-pill colour scheme. */
.mode-pill {
    display: inline-block;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1f2937;
    background: #e5e7eb;
    text-decoration: none;
    vertical-align: middle;
}

/* List view */
.list-days { list-style: none; padding: 0; }
.list-day { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.list-day h3 { margin: 0 0 8px 0; font-size: 14px; }
.list-day.day-conflict { background: #fef2f2; padding-left: 8px; border-radius: 4px; }
.list-day .session-block { white-space: normal; font-size: 12px; padding: 6px 8px; }

/* Training detail */
.training-detail dl.meta { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; margin: 16px 0; }
.training-detail dl.meta dt { color: var(--color-muted); }
.training-detail .sessions { width: 100%; border-collapse: collapse; margin-top: 12px; }
.training-detail .sessions th, .training-detail .sessions td {
    text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--color-border); font-size: 13px;
}

/* Public — invalid key */
.invalid-key { max-width: 480px; margin: 80px auto; text-align: center; padding: 32px; border: 1px solid var(--color-border); border-radius: 8px; }
.invalid-key h1 { font-size: 20px; margin: 0 0 12px; }
.invalid-key p { color: var(--color-muted); }

/* Empty state */
.empty { color: var(--color-muted); font-style: italic; }

@media (max-width: 720px) {
    .month-grid td.day { min-height: 70px; font-size: 11px; }
    .training-detail dl.meta { grid-template-columns: 1fr; }
}
