/* appointments.css — see components.css for the shared system; this file is owned by one module. */

/* ---- The book: toolbar, layout ------------------------------------------- */

.apt-toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.apt-toolbar__date { display: flex; align-items: center; gap: var(--s-1); }
.apt-toolbar__date .input { width: 150px; }
.apt-toolbar__label { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--ink); white-space: nowrap; margin-left: var(--s-1); }
.apt-toolbar__label small { font-weight: var(--fw-normal); color: var(--muted); margin-left: var(--s-2); }

.apt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: var(--s-4); align-items: start; }
@media (max-width: 1100px) { .apt-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---- Day view ------------------------------------------------------------ */

.apt-day { overflow: auto; max-height: calc(100vh - var(--topbar-h) - 190px); min-height: 300px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); position: relative; }
.apt-grid { --slot-h: 34px; display: grid; grid-template-columns: 54px repeat(var(--cols, 1), minmax(150px, 1fr)); min-width: max-content; }
.apt-grid__corner, .apt-grid__head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--ink-2); white-space: nowrap; }
.apt-grid__corner { left: 0; z-index: 4; border-right: 1px solid var(--border); }
.apt-grid__head { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; border-left: 1px solid var(--border-subtle); }
.apt-grid__head small { font-weight: var(--fw-normal); color: var(--muted); }
.apt-grid__head .badge { flex: 0 0 auto; }

.apt-times { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border); height: calc(var(--slots) * var(--slot-h)); }
.apt-times span { display: block; height: var(--slot-h); font-size: var(--fs-2xs); color: var(--faint); text-align: right; padding-right: var(--s-2); line-height: 1; padding-top: 3px; box-sizing: border-box; font-variant-numeric: tabular-nums; }
.apt-times span.is-hour { color: var(--muted); font-weight: var(--fw-semi); }

.apt-col { position: relative; height: calc(var(--slots) * var(--slot-h)); border-left: 1px solid var(--border-subtle);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--slot-h) - 1px), var(--border-subtle) calc(var(--slot-h) - 1px), var(--border-subtle) var(--slot-h)); }
.apt-col.is-closed { background-color: var(--bg-sunken); }
.apt-col.is-nobay { background-color: var(--surface-2); }
.apt-col__slot { position: absolute; left: 0; right: 0; height: var(--slot-h); cursor: pointer; }
.apt-col__slot:hover { background: var(--accent-soft); }
.apt-col__slot:hover::after { content: '+'; position: absolute; right: 8px; top: 6px; font-size: var(--fs-lg); color: var(--accent); line-height: 1; }

.apt-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 1; pointer-events: none; }
.apt-now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 99px; background: var(--danger); }

/* ---- An appointment block ------------------------------------------------ */

.apt-block { position: absolute; left: 3px; right: 3px; box-sizing: border-box; border-radius: var(--r-sm); border: 1px solid var(--apt-line, var(--border-strong)); border-left-width: 4px; background: var(--apt-bg, var(--surface-2)); color: var(--ink); padding: 3px 6px; overflow: hidden; cursor: pointer; z-index: 1; display: flex; flex-direction: column; gap: 1px; text-decoration: none; font-size: var(--fs-xs); line-height: 1.25; box-shadow: var(--shadow-xs); transition: box-shadow var(--t-fast) var(--ease); }
.apt-block:hover { box-shadow: var(--shadow-md); z-index: 2; text-decoration: none; }
.apt-block__top { display: flex; align-items: center; gap: 4px; min-width: 0; }
.apt-block__time { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: var(--fw-semi); flex: 0 0 auto; }
.apt-block__type { color: var(--apt-line); flex: 0 0 auto; display: inline-flex; }
.apt-block__type svg { width: 12px; height: 12px; }
.apt-block__menu { margin-left: auto; flex: 0 0 auto; width: 20px; height: 20px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-xs); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.apt-block__menu:hover { background: rgba(0, 0, 0, .08); color: var(--ink); }
.apt-block__menu svg { width: 13px; height: 13px; }
.apt-block__name { font-weight: var(--fw-semi); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-block__sub { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-block__sub .mono { font-weight: var(--fw-medium); }
.apt-block__actions { margin-top: auto; display: flex; gap: 4px; flex-wrap: wrap; padding-top: 2px; }
.apt-block__actions .btn { height: 22px; padding: 0 7px; font-size: var(--fs-2xs); }
.apt-block.is-short .apt-block__actions, .apt-block.is-short .apt-block__sub, .apt-block.is-narrow .apt-block__actions { display: none; }
.apt-block.is-tiny .apt-block__name { display: none; }

.apt-block[data-status="booked"]    { --apt-line: var(--info);    --apt-bg: var(--info-soft); }
.apt-block[data-status="confirmed"] { --apt-line: var(--accent);  --apt-bg: var(--accent-soft); }
.apt-block[data-status="arrived"]   { --apt-line: var(--purple);  --apt-bg: var(--purple-soft); }
.apt-block[data-status="in_shop"]   { --apt-line: var(--warning); --apt-bg: var(--warning-soft); }
.apt-block[data-status="done"]      { --apt-line: var(--success); --apt-bg: var(--success-soft); }
.apt-block[data-status="no_show"]   { --apt-line: var(--danger);  --apt-bg: var(--danger-soft); }
.apt-block[data-status="cancelled"] { --apt-line: var(--faint);   --apt-bg: var(--neutral-soft); opacity: .65; }
.apt-block[data-status="cancelled"] .apt-block__name, .apt-block[data-status="no_show"] .apt-block__name { text-decoration: line-through; }
.apt-block.is-late { --apt-line: var(--danger); }

/* ---- The « today » strip ------------------------------------------------- */

.apt-strip { display: flex; flex-direction: column; gap: var(--s-3); }
.apt-strip__tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.apt-tile { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border-subtle); min-width: 0; text-decoration: none; color: inherit; }
.apt-tile:hover { border-color: var(--border-strong); text-decoration: none; }
.apt-tile__v { font-size: var(--fs-2xl); font-weight: var(--fw-semi); line-height: 1; letter-spacing: -.02em; }
.apt-tile__l { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-tile[data-tone="info"] .apt-tile__v { color: var(--info); }
.apt-tile[data-tone="purple"] .apt-tile__v { color: var(--purple); }
.apt-tile[data-tone="warning"] .apt-tile__v { color: var(--warning); }
.apt-tile[data-tone="success"] .apt-tile__v { color: var(--success); }
.apt-tile[data-tone="danger"] .apt-tile__v { color: var(--danger); }
.apt-tile--wide { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
.apt-tile--wide .apt-tile__v { font-size: var(--fs-lg); }

.apt-next { display: flex; flex-direction: column; }
.apt-next__row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--s-2); align-items: center; padding: var(--s-2) 0; border-top: 1px solid var(--border-subtle); text-decoration: none; color: inherit; }
.apt-next__row:first-child { border-top: 0; }
.apt-next__row:hover { text-decoration: none; }
.apt-next__time { font-variant-numeric: tabular-nums; font-weight: var(--fw-semi); font-size: var(--fs-sm); }
.apt-next__who { min-width: 0; display: flex; flex-direction: column; }
.apt-next__who b { font-weight: var(--fw-medium); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-next__who small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .apt-strip { order: -1; }
  .apt-strip__tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .apt-tile--wide { grid-column: 1 / -1; }
  .apt-strip .apt-strip__next { display: none; }
}
@media (max-width: 700px) {
  .apt-strip__tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .apt-tile { padding: var(--s-2); }
  .apt-tile__v { font-size: var(--fs-xl); }
  .apt-day { max-height: calc(100vh - var(--topbar-h) - 120px); }
  .apt-toolbar__label { flex-basis: 100%; }
}

/* ---- Week view ----------------------------------------------------------- */

.apt-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.apt-week__day { background: var(--surface); min-height: 160px; display: flex; flex-direction: column; min-width: 0; }
.apt-week__day.is-closed { background: var(--bg-sunken); }
.apt-week__day.is-today .apt-week__head { color: var(--accent); }
.apt-week__head { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border-subtle); display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); font-weight: var(--fw-semi); cursor: pointer; }
.apt-week__head small { font-weight: var(--fw-normal); color: var(--muted); white-space: nowrap; }
.apt-week__body { padding: var(--s-2); display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; }
.apt-week__empty { font-size: var(--fs-xs); color: var(--faint); padding: var(--s-2); text-align: center; }
.apt-mini { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 6px; align-items: center; padding: 3px 6px 3px 8px; border-radius: var(--r-xs); background: var(--apt-bg, var(--surface-2)); border-left: 3px solid var(--apt-line, var(--border-strong)); font-size: var(--fs-xs); color: var(--ink); text-decoration: none; min-width: 0; }
.apt-mini:hover { filter: brightness(.97); text-decoration: none; }
.apt-mini b { font-variant-numeric: tabular-nums; font-weight: var(--fw-semi); color: var(--ink-3); }
.apt-mini span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-mini small { grid-column: 2; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-mini[data-status="booked"]    { --apt-line: var(--info);    --apt-bg: var(--info-soft); }
.apt-mini[data-status="confirmed"] { --apt-line: var(--accent);  --apt-bg: var(--accent-soft); }
.apt-mini[data-status="arrived"]   { --apt-line: var(--purple);  --apt-bg: var(--purple-soft); }
.apt-mini[data-status="in_shop"]   { --apt-line: var(--warning); --apt-bg: var(--warning-soft); }
.apt-mini[data-status="done"]      { --apt-line: var(--success); --apt-bg: var(--success-soft); }
.apt-mini[data-status="no_show"]   { --apt-line: var(--danger);  --apt-bg: var(--danger-soft); }
.apt-mini[data-status="cancelled"] { --apt-line: var(--faint);   --apt-bg: var(--neutral-soft); opacity: .65; }
@media (max-width: 900px) { .apt-week { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .apt-week { grid-template-columns: minmax(0, 1fr); } .apt-week__day { min-height: 0; } }

/* ---- List view ----------------------------------------------------------- */

.apt-range { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; }
.apt-range .input { width: 140px; }

/* ---- The form ------------------------------------------------------------ */

.apt-services { display: flex; flex-direction: column; gap: var(--s-2); }
.apt-services__row { display: flex; align-items: center; gap: var(--s-2); }
.apt-services__row .input, .apt-services__row .select { flex: 1 1 auto; min-width: 0; }
.apt-services__list { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.apt-services__list:empty::before { content: attr(data-empty); font-size: var(--fs-sm); color: var(--faint); }
.apt-conflict { margin-top: var(--s-3); }
.apt-conflict:empty { display: none; }
.apt-pick { display: flex; gap: var(--s-2); align-items: flex-end; }
.apt-pick .field { flex: 1 1 auto; min-width: 0; }
.apt-pick .btn { flex: 0 0 auto; margin-bottom: 1px; }

/* ---- The detail ---------------------------------------------------------- */

.apt-when { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s-3); }
.apt-when__item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.apt-when__item small { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.apt-when__item b { font-size: var(--fs-md); font-weight: var(--fw-semi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-steps { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.apt-contact { display: flex; flex-direction: column; gap: 4px; }
.apt-contact a { display: inline-flex; align-items: center; gap: 6px; }

/* ---- The printed sheet --------------------------------------------------- */

.apt-sheet { display: none; }
@media print {
  .apt-page > :not(.apt-sheet) { display: none !important; }
  .apt-sheet { display: block; font-size: 12pt; color: #000; }
  .apt-sheet h1 { font-size: 20pt; margin: 0 0 4pt; }
  .apt-sheet .apt-sheet__head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8pt; margin-bottom: 12pt; }
  .apt-sheet table { width: 100%; border-collapse: collapse; margin-bottom: 12pt; }
  .apt-sheet th { text-align: left; width: 32%; padding: 4pt 6pt; border-bottom: 1px solid #999; color: #444; font-weight: 600; vertical-align: top; }
  .apt-sheet td { padding: 4pt 6pt; border-bottom: 1px solid #999; vertical-align: top; }
  .apt-sheet .apt-sheet__lines { margin-top: 18pt; }
  .apt-sheet .apt-sheet__lines div { border-bottom: 1px solid #000; height: 22pt; }
  .apt-sheet .apt-sheet__sign { margin-top: 24pt; display: flex; gap: 24pt; }
  .apt-sheet .apt-sheet__sign div { flex: 1; border-top: 1px solid #000; padding-top: 4pt; font-size: 10pt; }
}
