/*
  Dashboard for hosts (/dashboard/), in the "soft" design of the booking pages.
  Values come from shared/design-tokens.css; booking.css provides buttons,
  inputs, flash messages and avatars.
*/

.dash {
  min-height: 100vh;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Top bar ------------------------------------------------------------------------- */
.dash-top {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dash-top__inner {
  max-width: 76rem;
  margin-inline: auto;
  padding: 0.7rem clamp(1rem, 4vw, 2rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.dash-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  flex: 1;
}

.dash-nav a,
.dash-me__link {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.dash-nav a:hover,
.dash-me__link:hover {
  background: var(--accent-soft);
}

.dash-nav a[aria-current="page"],
.dash-me__link[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Phones: the menu becomes one swipeable row below logo and account. */
@media (max-width: 56rem) {
  .dash-top {
    position: static; /* keep the small screen free for the form */
  }

  .dash-nav {
    order: 3;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .dash-nav a {
    white-space: nowrap;
  }

  .dash-me {
    margin-left: auto;
  }
}

.dash-me {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dash-me__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar--tiny {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.7rem;
  box-shadow: none;
}

/* --- Page --------------------------------------------------------------------------- */
.dash-main {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding: var(--space-4) clamp(1rem, 4vw, 2rem) var(--space-6);
}

.dash-main--narrow {
  max-width: 28rem;
  padding-top: clamp(2rem, 10vh, 6rem);
}

.dash-main h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 0.25rem;
}

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.dash-head p {
  margin: 0;
  max-width: 46rem;
}

.dash-back {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  text-decoration: none;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: var(--space-4);
}

.dash-card h2 {
  font-size: 1.15rem;
  margin: 0 0 var(--space-3);
}

.dash-card h3 {
  font-size: 1rem;
  margin: var(--space-4) 0 var(--space-2);
}

.dash-card--auth h1 {
  margin-bottom: var(--space-2);
}

.dash-card--highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dash-warn {
  border: 1px solid #f3c58a;
  background: #fff7ec;
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}

.dash-warn ul {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.dash-empty {
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  list-style: none;
}

.dash-split {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 60rem) {
  .dash-split {
    grid-template-columns: 1fr 1fr;
  }
}

.dash-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.dash-list li.is-current {
  font-weight: 600;
}

.dash-danger {
  margin-top: var(--space-4);
}

.dash-save {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: linear-gradient(transparent, var(--bg) 35%);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

/* On/off switch (a real button, so it works without JavaScript) */
.switch {
  position: relative;
  width: 2.6rem;
  height: 1.5rem;
  flex: none;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--disabled);
  cursor: pointer;
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s var(--ease);
}

.switch.is-on {
  background: var(--accent);
}

.switch.is-on::after {
  transform: translateX(1.1rem);
}

/* --- Forms ----------------------------------------------------------------------------- */
.dash-form .field,
.dash-card .field {
  margin-bottom: var(--space-3);
}

.form--wide {
  max-width: none;
}

.form .field {
  margin-bottom: 0;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 0 var(--space-4);
}

@media (min-width: 48rem) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.check-label {
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500 !important;
  cursor: pointer;
  margin: 0 !important;
}

.check-label input,
.dash-table input[type="checkbox"],
.chip input {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
}

.field--check {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chips .chip {
  display: inline-flex !important;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem !important;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-weight: 500 !important;
  cursor: pointer;
  margin: 0 !important;
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.prefix-input {
  display: flex;
  align-items: stretch;
}

.prefix-input span {
  display: flex;
  align-items: center;
  padding: 0 0.7rem;
  border: 1.5px solid var(--line);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.prefix-input input {
  border-radius: 0 10px 10px 0 !important;
  min-width: 0;
}

/* "Advanced Settings": closed by default, everything inside has a default. */
.dash-advanced > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}

.dash-advanced[open] > summary {
  margin-bottom: var(--space-3);
}

.dash-advanced h3:first-of-type {
  margin-top: 0;
}

.dash-more {
  margin-top: var(--space-2);
}

.dash-more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.copy-row {
  display: flex;
  gap: var(--space-2);
}

/* --- Question editor (two columns) ------------------------------------------------------ */
.field-editor {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

@media (min-width: 48rem) {
  .field-editor {
    grid-template-columns: 1fr 1fr;
  }
}

.field-editor__col {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.field-editor__col--chosen {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.field-editor h3 {
  margin: 0 0 var(--space-2);
  font-size: 0.95rem;
}

.field-list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 500;
}

.field-row--fixed {
  opacity: 0.75;
}

.field-row__tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn--small {
  width: 2rem;
  height: 2rem;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.icon-btn--small:disabled {
  opacity: 0.35;
  cursor: default;
}

/* --- Availability ---------------------------------------------------------------------- */
.week {
  display: grid;
  gap: 0.6rem;
  margin-top: var(--space-2);
}

.week__day {
  display: grid;
  gap: 0.3rem;
  align-items: center;
}

@media (min-width: 40rem) {
  .week__day {
    grid-template-columns: 9rem 1fr;
  }

  .week__day .field__error {
    grid-column: 2;
  }
}

.week__day label {
  font-weight: 600;
}

/* --- Tables ------------------------------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.dash-table th,
.dash-table td {
  padding: 0.65rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.dash-table th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.dash-table tr.is-off td {
  color: var(--muted);
}

.dash-table__actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  .switch,
  .switch::after {
    transition: none;
  }
}

/* --- Appointment type editor: form + live preview ------------------------------------------- */
.editor {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 70rem) {
  .editor {
    grid-template-columns: minmax(0, 1fr) 25rem;
  }

  .editor__preview {
    position: sticky;
    top: var(--space-4);
  }
}

.editor__preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--space-2);
}

.preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.preview .info {
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.preview .info__title {
  font-size: 1.4rem;
  margin-bottom: var(--space-3);
  overflow-wrap: anywhere;
}

.preview__pane {
  padding: var(--space-3) clamp(1.25rem, 3vw, 2rem) var(--space-4);
}

.preview__heading {
  font-weight: 700;
  margin: 0 0 var(--space-1);
}

.preview__month {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 var(--space-2);
}

.preview__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
  font-size: 0.8rem;
}

.preview__dow {
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 0.2rem;
}

.preview__day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
}

.preview__day.is-free {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* .meta li / .info__text set their own display, which would beat the hidden attribute */
.preview [hidden] {
  display: none;
}

/* --- Appointment type list (like cal.com's event types) ----------------------------------- */
.type-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.type-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) clamp(1rem, 3vw, 1.5rem);
  transition: background-color 0.15s;
}

.type-row + .type-row {
  border-top: 1px solid var(--line);
}

.type-row:hover {
  background: var(--bg);
}

.type-row__main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.45rem;
  color: var(--text);
  text-decoration: none;
}

.type-row__title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
}

.type-row__name {
  font-weight: 700;
  font-size: 1.02rem;
}

.type-row__main:hover .type-row__name {
  color: var(--accent);
}

.type-row__slug {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.type-row__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.type-row.is-off .type-row__name,
.type-row.is-off .type-row__slug {
  color: var(--muted);
}

.chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip-badge .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.chip-badge--accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.chip-badge--off {
  background: transparent;
  border-style: dashed;
}

.type-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
}

/* Joined icon buttons: open, copy link, duplicate */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.btn-group form {
  display: contents;
}

.btn-group__item {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.3rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.btn-group__item + .btn-group__item,
.btn-group form .btn-group__item {
  border-left: 1px solid var(--line);
}

.btn-group__item:hover,
.btn-group__item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 40rem) {
  .type-row {
    flex-direction: column;
    align-items: stretch;
  }

  .type-row__actions {
    justify-content: space-between;
  }
}

/* --- Admin tab: section nav, status tabs, filters, pager -------------------------------------- */
.subnav,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.subnav a,
.tabs__item {
  padding: 0.55rem 0.9rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.subnav a:hover,
.tabs__item:hover {
  color: var(--text);
}

.subnav a[aria-current="page"],
.tabs__item[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tabs {
  border-bottom: 0;
  margin-bottom: var(--space-3);
}

.tabs__item {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  margin: 0;
  padding: 0.3rem 0.85rem;
  font-size: 0.9rem;
  background: var(--surface);
}

.tabs__item[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.tabs__count {
  margin-left: 0.25rem;
  font-weight: 500;
  opacity: 0.75;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.filters input[type="search"] {
  flex: 1 1 14rem;
  max-width: 22rem;
}

.filters select {
  flex: 0 1 14rem;
}

.filters__reset {
  font-size: 0.9rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.subnav + p.muted {
  margin-top: calc(-1 * var(--space-2));
}

.dash-table .status {
  white-space: nowrap;
  font-size: 0.82rem;
  padding: 0.2rem 0.65rem;
}

.dash-card--narrow {
  max-width: 44rem;
}

/* --- Bookings: open requests first ---------------------------------------------------------- */
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

[aria-current="page"] .count-badge {
  background: var(--accent-ink);
  color: var(--accent);
}

.requests {
  border-color: var(--accent);
  margin-bottom: var(--space-4);
}

.requests h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.request-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
}

.request {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
}

.request__when {
  display: grid;
}

.request__day {
  font-weight: 700;
}

.request__who {
  overflow-wrap: anywhere;
}

.request__actions {
  display: flex;
  gap: var(--space-2);
}

.dash-subhead {
  font-size: 1.15rem;
  margin: 0 0 var(--space-2);
}

@media (max-width: 40rem) {
  .request {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* --- Info icon with tooltip (help texts) ------------------------------------------------------ */
.field__label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.field__label > label {
  margin: 0;
}

legend.field__label {
  padding: 0;
}

.tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

.tip__btn {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: help;
}

.tip__btn svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.tip__btn:hover,
.tip__btn:focus-visible {
  color: var(--accent);
}

.tip__bubble {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  width: max-content;
  max-width: min(18rem, 80vw);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  box-shadow: var(--shadow-card);
  transform: translate(-50%, 0.25rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.tip:hover .tip__bubble,
.tip:focus-within .tip__bubble {
  opacity: 1;
  visibility: visible;
  pointer-events: auto; /* the pointer may move onto the bubble (WCAG 1.4.13) */
  transform: translate(-50%, 0);
}

.tip.is-dismissed .tip__bubble {
  opacity: 0;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .tip__bubble {
    transition: none;
  }
}

/* Table headers: open downwards and start at the icon instead of centring, so the
   bubble is not cut off at the left edge of the scroll box. */
.tip--below .tip__bubble,
.tip--below:hover .tip__bubble,
.tip--below:focus-within .tip__bubble {
  bottom: auto;
  top: calc(100% + 0.5rem);
  left: 0;
  transform: none;
}

.tip--end .tip__bubble,
.tip--end:hover .tip__bubble,
.tip--end:focus-within .tip__bubble {
  left: auto;
  right: 0;
}

/* Wide screens: the table fits, so let the bubbles overflow the box instead of
   being clipped by it (the box only scrolls on narrow screens). */
@media (min-width: 48rem) {
  .table-wrap--tips {
    overflow: visible;
  }
}

.th-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.editor__preview-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.type-row__note {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
  overflow-wrap: anywhere;
}
