/* Availability timeline: a row per unit, a column per day.
   Colours are custom properties, so a site template can restyle them. */

.av {
	--av-free: #cfe8c8;
	--av-booked: #c9a99a;
	--av-option: #ecd9a2;
	--av-closed: #d6d6d0;
	--av-line: rgba(0, 0, 0, .08);
	--av-cell: 36px;
	--av-unit: 230px;
	--av-row: 64px;
	--av-today: #c0392b;
	--av-text: #2c3633;
	--av-muted: #9aa09c;
	position: relative;
	color: var(--av-text);
}

.av__scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scroll-behavior: smooth; }
.av__table { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.av__table th, .av__table td { padding: 0; }

/* Sticky column with the units */
.av__corner, .av__unit { position: sticky; left: 0; z-index: 2; width: var(--av-unit); min-width: var(--av-unit); background: var(--av-bg, #fff); }
.av__unit { display: flex; align-items: center; gap: .8rem; height: var(--av-row); padding: 0 1rem 0 .5rem; border-bottom: 1px solid var(--av-line); box-shadow: 8px 0 12px -10px rgba(0, 0, 0, .25); font-weight: 500; text-align: left; }
.av__unit img { width: 46px; height: 46px; flex: none; object-fit: cover; border-radius: 10px; }
.av__unit span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Month and day headers */
.av__months th { height: 2.2rem; text-align: left; vertical-align: bottom; font-weight: 400; font-size: 1.05rem; white-space: nowrap; }
.av__months th span { position: sticky; left: calc(var(--av-unit) + .5rem); padding-left: .3rem; }
.av__days th { width: var(--av-cell); min-width: var(--av-cell); height: 2rem; text-align: center; font-weight: 400; font-size: .85rem; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--av-line); }
.av__days th.is-weekend { color: var(--av-muted); }
.av__days th.is-today { position: relative; color: var(--av-today); font-weight: 700; }
.av__days th.is-today::after { content: ""; position: absolute; left: 50%; bottom: -5px; z-index: 1; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--av-today); }
.av__days th.is-first, .av__d.is-first { border-left: 1px solid rgba(0, 0, 0, .18); }

/* Day cells: morning half and afternoon half, split on the diagonal */
.am-free { --am: var(--av-free); } .pm-free { --pm: var(--av-free); }
.am-booked { --am: var(--av-booked); } .pm-booked { --pm: var(--av-booked); }
.am-option { --am: var(--av-option); } .pm-option { --pm: var(--av-option); }
.am-closed { --am: var(--av-closed); } .pm-closed { --pm: var(--av-closed); }
.av__d { width: var(--av-cell); height: var(--av-row); border-right: 1px solid rgba(255, 255, 255, .55); border-bottom: 1px solid var(--av-line); background: linear-gradient(120deg, var(--am) 0 50%, var(--pm) 50% 100%); }
.pm-option, .am-option { background-image: linear-gradient(120deg, var(--am) 0 50%, var(--pm) 50% 100%); }
.av__d.is-past { opacity: .45; }
.av__d.is-today { box-shadow: inset 2px 0 0 var(--av-today); }

/* Legend and navigation */
.av__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; margin-top: 1rem; }
.av__legend { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; margin: 0; padding: 0; list-style: none; font-size: .88rem; }
.av__legend li { display: flex; align-items: center; gap: .5rem; }
.av__swatch { display: inline-block; width: 22px; height: 16px; border-radius: 3px; background: linear-gradient(120deg, var(--am) 0 50%, var(--pm) 50% 100%); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.av__nav { display: flex; gap: .4rem; }
.av__nav button { min-width: 40px; height: 40px; padding: 0 1rem; border: 1px solid rgba(0, 0, 0, .15); border-radius: 999px; background: #fff; color: inherit; font: inherit; font-size: .9rem; cursor: pointer; }
.av__nav button:hover { border-color: currentColor; }
.av__nav button[data-av-step] { padding: 0; font-size: 1.3rem; line-height: 1; }

@media (max-width: 600px) {
	.av { --av-unit: 120px; --av-row: 56px; --av-cell: 32px; }
	.av__unit img { display: none; }
	.av__unit { font-size: .9rem; }
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */

.av--admin .av__d { cursor: pointer; }
.av--admin .av__d:hover { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .45); }
.av--admin .av__d.is-picked { box-shadow: inset 0 0 0 3px #1c64d1; }
.av--admin .av__d.is-range { filter: brightness(.88); }
.av-admin__help { padding: .9rem 1.1rem; border-radius: 6px; background: #f2f6fb; }
.av-admin__help.is-picking { background: #fff6d6; }
.av-dialog { width: min(560px, 94vw); padding: 1.6rem; border: 0; border-radius: 10px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4); }
.av-dialog::backdrop { background: rgba(20, 28, 26, .45); }
.av-dialog h2 { margin: 0 0 1rem; font-size: 1.3rem; }
.av-dialog label { display: block; font-weight: 500; }
.av-dialog__grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.av-dialog__grid label:first-child { grid-column: 1 / -1; }
.av-dialog__status { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: 1rem 0; padding: 0; border: 0; }
.av-dialog__status legend { width: 100%; margin-bottom: .4rem; font-size: 1rem; font-weight: 500; }
.av-dialog__status label { display: flex; align-items: center; gap: .45rem; font-weight: 400; }
.av-dialog__note { margin-bottom: 1rem; }
.av-dialog__error { padding: .7rem 1rem; border-radius: 6px; background: #fbe4e4; color: #8a1f1f; }
.av-dialog__buttons { display: flex; gap: .5rem; }
.av-dialog__buttons span { flex: 1; }
.av-units { margin-top: 3rem; }
.av-units h2 { font-size: 1.3rem; }
