/* RE Network — reusable "Availability & Schedule" widget (mock, no backend).
   Include with: <link rel="stylesheet" href="availability.css"> + <script src="availability.js" defer></script>
   Container: <div class="avail" data-availability data-config='{...}'></div> */
.side:has(.avail) { position: static !important; }   /* tall widget: don't trap it in a sticky sidebar */
.avail {
  --av-blue: var(--primary, #377DFF); --av-blue-d: #2563eb; --av-blue-l: #eaf1ff;
  --av-ink: var(--ink, #1a1d1f); --av-muted: var(--muted, #6b7280); --av-border: var(--border, #e5e7eb);
  --av-green: #16a34a;
  background: #fff; border: 1px solid var(--av-border); border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04); color: var(--av-ink);
  font-family: var(--sans, "Segoe UI", system-ui, -apple-system, Arial, sans-serif); font-size: 14px;
  width: 100%; min-width: 0;
}
.avail *, .avail *::before, .avail *::after { box-sizing: border-box; }
.avail button, .avail input, .avail textarea, .avail select { font: inherit; color: inherit; }
.avail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.avail-head h3 { font-size: 16px; font-weight: 750; margin: 0; }
.avail-book { font-size: 12px; font-weight: 650; color: var(--av-blue); }
.avail-tz { font-size: 12px; color: var(--av-muted); margin-top: 2px; }

.avail-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0 10px; }
.avail-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: #e8f7ee; color: #166534;
}
.avail-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--av-green); }
.avail-chip.next { background: var(--av-blue-l); color: var(--av-blue-d); }
.avail-chip.next::before { background: var(--av-blue); }
.avail-chip.none { background: #f3f4f6; color: var(--av-muted); }
.avail-chip.none::before { background: #9ca3af; }
.avail-nextline { font-size: 12px; color: var(--av-muted); }
.avail-nextline strong { color: var(--av-ink); }

.avail-hours { border: 1px solid var(--av-border); border-radius: 10px; margin-bottom: 12px; background: #fafafa; }
.avail-hours summary {
  cursor: pointer; list-style: none; padding: 8px 10px; font-size: 12px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; color: #374151;
}
.avail-hours summary::-webkit-details-marker { display: none; }
.avail-hours summary::after { content: "▾"; color: var(--av-muted); }
.avail-hours:not([open]) summary::after { content: "▸"; }
.avail-hours-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; padding: 0 10px 8px; }
.avail-hours-row { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed #eceff3; }
.avail-hours-row b { font-weight: 700; }
.avail-hours-row span { color: #374151; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avail-hours-row.off span { color: #9ca3af; }
.avail-hours-row.today b { color: var(--av-blue-d); }

.avail-type { display: block; margin-bottom: 12px; }
.avail-type span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--av-muted); margin-bottom: 4px; }
.avail-type select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--av-border); border-radius: 10px; background: #fff; cursor: pointer;
}
.avail-type select:focus, .avail-form input:focus, .avail-form textarea:focus { outline: 2px solid var(--av-blue); outline-offset: 1px; border-color: var(--av-blue); }

.avail-cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.avail-month { font-weight: 750; font-size: 14px; }
.avail-nav-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--av-blue); font-weight: 700;
}
.avail-nav-btn:hover:not(:disabled) { background: var(--av-blue-l); }
.avail-nav-btn:disabled { color: #d1d5db; cursor: default; }
.avail-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.avail-dow { font-size: 10.5px; font-weight: 700; color: var(--av-muted); padding: 4px 0; letter-spacing: .04em; }
.avail-day {
  position: relative; aspect-ratio: 1 / 1; max-width: 42px; width: 100%; margin: 0 auto; border: 0; border-radius: 50%;
  background: transparent; font-size: 13px; font-weight: 500; color: #c3c8d0; cursor: default; padding: 0;
}
.avail-day.pad { visibility: hidden; }
.avail-day.open { background: var(--av-blue-l); color: var(--av-blue-d); font-weight: 700; cursor: pointer; }
.avail-day.open:hover { background: #d3e3ff; }
.avail-day.sel, .avail-day.open.sel { background: var(--av-blue); color: #fff; }
.avail-day.today::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor;
}
.avail-day.today:not(.open) { color: #6b7280; font-weight: 700; }
.avail-day:focus-visible, .avail-slot:focus-visible, .avail-nav-btn:focus-visible { outline: 2px solid var(--av-blue); outline-offset: 2px; }
.avail-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--av-muted); }
.avail-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; background: var(--av-blue-l); border: 1px solid var(--av-blue); }
.avail-legend i.un { background: #f3f4f6; border-color: #d1d5db; }
.avail-legend i.td { background: #fff; border: 0; position: relative; }
.avail-legend i.td::after { content: ""; position: absolute; left: 3px; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: #6b7280; }

.avail-slots { margin-top: 14px; border-top: 1px solid var(--av-border); padding-top: 12px; }
.avail-slots-title { font-size: 13px; font-weight: 750; margin-bottom: 8px; }
.avail-slots-title small { font-weight: 500; color: var(--av-muted); }
.avail-slot-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 280px; overflow: auto; padding: 2px; }
.avail-slot {
  padding: 9px 6px; border-radius: 10px; border: 1px solid var(--av-blue); background: #fff; color: var(--av-blue-d);
  font-weight: 700; font-size: 13px; cursor: pointer; text-align: center;
}
.avail-slot:hover:not(:disabled) { background: var(--av-blue-l); }
.avail-slot.booked, .avail-slot:disabled {
  border-color: var(--av-border); background: #f3f4f6; color: #9ca3af; text-decoration: line-through; cursor: not-allowed; font-weight: 500;
}
.avail-slot.picked { grid-column: 1 / -1; background: var(--av-blue); color: #fff; border-color: var(--av-blue); }
.avail-slot.picked:hover { background: var(--av-blue-d); }
.avail-empty { font-size: 13px; color: var(--av-muted); padding: 6px 0; }

.avail-form { margin-top: 12px; padding: 12px; border: 1px solid var(--av-border); border-radius: 12px; background: #f8fafc; }
.avail-form h4 { font-size: 13px; font-weight: 750; margin: 0 0 2px; }
.avail-form .when { font-size: 12px; color: var(--av-muted); margin-bottom: 8px; }
.avail-form label { display: block; font-size: 12px; font-weight: 650; margin: 8px 0 3px; }
.avail-form input, .avail-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--av-border); border-radius: 8px; background: #fff;
}
.avail-form textarea { min-height: 58px; resize: vertical; }
.avail-form .err { color: #b91c1c; font-size: 12px; margin-top: 6px; min-height: 0; }
.avail-form .actions { display: flex; gap: 8px; margin-top: 10px; }
.avail-btn {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--av-blue); background: var(--av-blue);
  color: #fff; font-weight: 700; cursor: pointer;
}
.avail-btn:hover { background: var(--av-blue-d); }
.avail-btn.ghost { flex: 0 0 auto; background: #fff; color: #374151; border-color: var(--av-border); }
.avail-btn.ghost:hover { background: #f3f4f6; }
.avail-note { font-size: 11px; color: var(--av-muted); margin-top: 8px; }

.avail-success { text-align: center; padding: 18px 8px 6px; }
.avail-success .tick {
  width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; background: #e8f7ee; color: var(--av-green);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.avail-success h4 { font-size: 15px; margin: 0 0 6px; }
.avail-success p { font-size: 13px; color: #4b5563; margin: 0 0 4px; line-height: 1.45; }
.avail-success .avail-btn { margin-top: 12px; width: 100%; background: #fff; color: var(--av-blue-d); }
.avail-success .avail-btn:hover { background: var(--av-blue-l); }

@media (max-width: 960px) { .avail { max-width: 520px; } }
@media (max-width: 420px) { .avail { padding: 12px; } .avail-hours-grid { grid-template-columns: 1fr; } }
