/*
 * Nilo public widget branding.
 *
 * The widget renders its documented light-DOM classes. This integration keeps
 * Caimito's visual language while following the Nilo scheduler structure.
 */
nilo-scheduler {
  --nilo-widget-font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
  --nilo-widget-surface: var(--color-bg);
  --nilo-widget-surface-muted: var(--color-bg-muted);
  --nilo-widget-border: var(--color-border-subtle);
  --nilo-widget-border-strong: var(--color-border);
  --nilo-widget-text: var(--color-text-body);
  --nilo-widget-text-muted: var(--color-text-muted);
  --nilo-widget-title: var(--color-text-strong);
  --nilo-widget-accent: var(--primary-color);
  --nilo-widget-accent-strong: color-mix(in srgb, var(--primary-color) 78%, black);
  --nilo-widget-accent-soft: color-mix(in srgb, var(--primary-color) 11%, var(--color-bg) 89%);
  --nilo-widget-success: var(--secondary-color);
  --nilo-widget-success-soft: color-mix(in srgb, var(--secondary-color) 12%, var(--color-bg) 88%);
  --nilo-widget-error: #9f3a2d;
  --nilo-widget-shadow: 0 10px 30px var(--color-shadow-card);
  --nilo-widget-radius: 18px;
  --nilo-widget-radius-sm: 12px;
  display: block;
  max-width: 52rem;
  margin: 1.5rem auto;
  color: var(--nilo-widget-text);
  font-family: var(--nilo-widget-font-family);
}

.nilo-scheduler-cta {
  max-width: 37.5rem;
  margin: 1.5rem auto;
  padding: 1.25rem 2rem;
  border-radius: var(--nilo-widget-radius-sm, 12px);
  background: var(--nilo-widget-surface-muted, #f8f9fa);
  text-align: center;
}

.nilo-scheduler-cta__message {
  margin: 0 0 0.75rem;
  color: var(--nilo-widget-text, #333333);
  font-size: 1.05rem;
}

.scheduler-dialog {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  background: transparent;
}

.scheduler-dialog::backdrop {
  background: rgba(17, 17, 17, 0.6);
}

.scheduler-dialog__surface {
  position: relative;
  max-height: calc(100vh - 2rem);
  padding: 1.5rem;
  overflow-y: auto;
}

.scheduler-dialog nilo-scheduler {
  max-width: none;
  margin: 0;
}

button.scheduler-dialog__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-strong);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

button.scheduler-dialog__close:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

nilo-scheduler .nilo-widget,
nilo-scheduler .nilo-widget-card,
nilo-scheduler .nilo-widget-copy,
nilo-scheduler .nilo-widget-grid,
nilo-scheduler .nilo-field,
nilo-scheduler .nilo-actions,
nilo-scheduler .nilo-scheduler-summary,
nilo-scheduler .nilo-scheduler-booking,
nilo-scheduler .nilo-scheduler-stage,
nilo-scheduler .nilo-scheduler-details {
  box-sizing: border-box;
}

nilo-scheduler .nilo-widget-card {
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem;
  border: 1px solid var(--nilo-widget-border);
  border-radius: var(--nilo-widget-radius);
  background: var(--nilo-widget-surface);
  box-shadow: var(--nilo-widget-shadow);
}

nilo-scheduler .nilo-widget-copy,
nilo-scheduler .nilo-scheduler-header {
  display: grid;
  gap: 0.28rem;
}

nilo-scheduler .nilo-widget-title,
nilo-scheduler .nilo-scheduler-day-title,
nilo-scheduler .nilo-scheduler-month-label {
  margin: 0;
  color: var(--nilo-widget-title);
}

nilo-scheduler .nilo-widget-title {
  font-size: 1.12rem;
  line-height: 1.25;
}

nilo-scheduler p.nilo-widget-text,
nilo-scheduler p.nilo-status,
nilo-scheduler p.nilo-success,
nilo-scheduler p.nilo-widget-error,
nilo-scheduler .nilo-success > p {
  margin: 0;
  color: var(--nilo-widget-text-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

nilo-scheduler .nilo-success-title {
  margin: 0;
}

nilo-scheduler .nilo-success-title + p {
  margin-top: 0.25rem;
}

nilo-scheduler .nilo-widget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

nilo-scheduler .nilo-field {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
  color: var(--nilo-widget-title);
  font-size: 0.84rem;
  font-weight: 600;
}

nilo-scheduler .nilo-field--full {
  grid-column: 1 / -1;
}

nilo-scheduler .nilo-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 0.68rem 0.8rem;
  border: 1px solid var(--nilo-widget-border-strong);
  border-radius: var(--nilo-widget-radius-sm);
  background: var(--nilo-widget-surface);
  color: var(--nilo-widget-text);
  font: inherit;
  font-size: 0.94rem;
}

nilo-scheduler .nilo-actions {
  display: flex;
  justify-content: flex-start;
}

nilo-scheduler .nilo-submit {
  padding: 0.64rem 1rem;
  border: 1px solid var(--nilo-widget-accent);
  border-radius: 999px;
  background: var(--nilo-widget-accent);
  color: #ffffff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

nilo-scheduler .nilo-submit[disabled] {
  cursor: wait;
  opacity: 0.8;
}

nilo-scheduler .nilo-success {
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--nilo-widget-success) 22%, transparent);
  border-radius: var(--nilo-widget-radius-sm);
  background: var(--nilo-widget-success-soft);
  color: var(--nilo-widget-success);
}

nilo-scheduler .nilo-success > p {
  color: inherit;
}

nilo-scheduler .nilo-widget-error {
  color: var(--nilo-widget-error);
}

nilo-scheduler .nilo-input:focus-visible,
nilo-scheduler .nilo-scheduler-type:focus-visible,
nilo-scheduler .nilo-scheduler-timezone-match:focus-visible,
nilo-scheduler .nilo-scheduler-slot:focus-visible,
nilo-scheduler .nilo-scheduler-back:focus-visible,
nilo-scheduler .nilo-scheduler-progress-button:focus-visible,
nilo-scheduler .nilo-scheduler-nav:focus-visible,
nilo-scheduler .nilo-scheduler-calendar-day:focus-visible,
nilo-scheduler .nilo-submit:focus-visible,
nilo-scheduler .nilo-scheduler-clock-format:focus-visible {
  outline: 2px solid var(--nilo-widget-accent);
  outline-offset: 2px;
}

nilo-scheduler .nilo-scheduler-card {
  display: flex;
  flex-direction: row;
  gap: 0;
  width: min(100%, 52rem);
  min-height: 27rem;
  margin-inline: auto;
  padding: 0;
  overflow: hidden;
}

nilo-scheduler .nilo-scheduler-summary,
nilo-scheduler .nilo-scheduler-booking {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
}

nilo-scheduler .nilo-scheduler-summary {
  flex: 0 0 14.5rem;
  background: linear-gradient(
    180deg,
    var(--nilo-widget-surface-muted) 0%,
    var(--nilo-widget-accent-soft) 100%
  );
  border-right: 1px solid var(--nilo-widget-border);
}

nilo-scheduler .nilo-scheduler-booking {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--nilo-widget-surface);
}

nilo-scheduler .nilo-scheduler-progress {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

nilo-scheduler .nilo-scheduler-progress-step {
  position: relative;
  display: flex;
  gap: 0.6rem;
  min-height: 3.3rem;
  color: var(--nilo-widget-text-muted);
}

nilo-scheduler .nilo-scheduler-progress-step:not(:last-child)::after {
  position: absolute;
  top: 1.55rem;
  bottom: 0;
  left: 0.75rem;
  width: 1px;
  background: var(--nilo-widget-border);
  content: "";
}

nilo-scheduler .nilo-scheduler-progress-button {
  display: flex;
  width: 100%;
  gap: 0.6rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

nilo-scheduler .nilo-scheduler-progress-button:disabled {
  cursor: default;
}

nilo-scheduler .nilo-scheduler-progress-marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex: 0 0 1.55rem;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid var(--nilo-widget-border);
  border-radius: 50%;
  background: var(--nilo-widget-surface);
  font-size: 0.75rem;
  font-weight: 700;
}

nilo-scheduler .nilo-scheduler-progress-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.15rem;
}

nilo-scheduler .nilo-scheduler-progress-label {
  font-size: 0.82rem;
  font-weight: 700;
}

nilo-scheduler .nilo-scheduler-progress-value {
  overflow: hidden;
  color: var(--nilo-widget-title);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
}

nilo-scheduler .nilo-scheduler-progress-step.is-active,
nilo-scheduler .nilo-scheduler-progress-step.is-complete {
  color: var(--nilo-widget-title);
}

nilo-scheduler .nilo-scheduler-progress-step.is-active .nilo-scheduler-progress-marker,
nilo-scheduler .nilo-scheduler-progress-step.is-complete .nilo-scheduler-progress-marker {
  border-color: var(--nilo-widget-accent);
  background: var(--nilo-widget-accent);
  color: #ffffff;
}

nilo-scheduler .nilo-scheduler-label {
  color: var(--nilo-widget-title);
  font-size: 0.82rem;
  font-weight: 700;
}

nilo-scheduler .nilo-scheduler-booking-header {
  display: flex;
  min-height: 1.75rem;
  gap: 0.6rem;
  align-items: center;
}

nilo-scheduler .nilo-scheduler-back {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: var(--nilo-widget-radius-sm);
  background: transparent;
  color: var(--nilo-widget-accent-strong);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

nilo-scheduler .nilo-scheduler-back:hover {
  background: var(--nilo-widget-accent-soft);
}

nilo-scheduler .nilo-scheduler-back[hidden],
nilo-scheduler .nilo-scheduler-stage[hidden] {
  display: none;
}

nilo-scheduler .nilo-scheduler-stage {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 0.7rem;
}

nilo-scheduler .nilo-scheduler-calendar-panel {
  justify-content: flex-start;
}

nilo-scheduler .nilo-scheduler-times-panel {
  overflow-y: auto;
}

nilo-scheduler .nilo-scheduler-times-header {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}

nilo-scheduler .nilo-scheduler-clock-format {
  flex: 0 0 auto;
  min-width: 3.15rem;
  padding: 0.32rem 0.5rem;
  border: 1px solid var(--nilo-widget-border-strong);
  border-radius: var(--nilo-widget-radius-sm);
  background: var(--nilo-widget-surface);
  color: var(--nilo-widget-accent-strong);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

nilo-scheduler .nilo-scheduler-clock-format[aria-pressed="true"] {
  border-color: var(--nilo-widget-accent);
  background: var(--nilo-widget-accent-soft);
}

nilo-scheduler .nilo-scheduler-month-nav {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
}

nilo-scheduler .nilo-scheduler-timezone-picker {
  position: relative;
  display: grid;
  margin: auto 0 0;
}

nilo-scheduler .nilo-scheduler-timezone-search {
  display: grid;
  gap: 0.35rem;
}

nilo-scheduler .nilo-scheduler-timezone-matches {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.35rem);
  left: 0;
  z-index: 2;
  display: grid;
  max-height: 11rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--nilo-widget-border-strong);
  border-radius: var(--nilo-widget-radius-sm);
  background: var(--nilo-widget-surface);
  box-shadow: var(--nilo-widget-shadow);
  list-style: none;
}

nilo-scheduler .nilo-scheduler-timezone-match {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: 0;
  background: var(--nilo-widget-surface);
  color: var(--nilo-widget-title);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

nilo-scheduler .nilo-scheduler-timezone-matches li + li {
  border-top: 1px solid var(--nilo-widget-border);
}

nilo-scheduler .nilo-scheduler-timezone-match:hover {
  background: var(--nilo-widget-accent-soft);
}

nilo-scheduler .nilo-scheduler-timezone-match:disabled {
  cursor: progress;
  opacity: 0.65;
}

nilo-scheduler .nilo-scheduler-month-label,
nilo-scheduler .nilo-scheduler-selected-date {
  margin: 0;
  color: var(--nilo-widget-title);
}

nilo-scheduler .nilo-scheduler-month-label {
  font-size: 1rem;
  font-weight: 700;
}

nilo-scheduler p.nilo-scheduler-selected-date {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
}

nilo-scheduler .nilo-scheduler-nav,
nilo-scheduler .nilo-scheduler-type,
nilo-scheduler .nilo-scheduler-slot {
  border: 1px solid var(--nilo-widget-border-strong);
  background: var(--nilo-widget-surface);
  color: var(--nilo-widget-title);
  font: inherit;
  cursor: pointer;
}

nilo-scheduler .nilo-scheduler-type {
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
}

nilo-scheduler .nilo-scheduler-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
}

nilo-scheduler .nilo-scheduler-nav[disabled] {
  cursor: default;
  opacity: 0.45;
}

nilo-scheduler .nilo-scheduler-weekdays,
nilo-scheduler .nilo-scheduler-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

nilo-scheduler .nilo-scheduler-weekdays span {
  color: var(--nilo-widget-text-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

nilo-scheduler .nilo-scheduler-calendar-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 1.9rem;
  min-height: 1.9rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--nilo-widget-title);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

nilo-scheduler .nilo-scheduler-calendar-day--inactive,
nilo-scheduler .nilo-scheduler-calendar-day--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.9rem;
  color: var(--color-text-faint);
  font-size: 0.9rem;
}

nilo-scheduler .nilo-scheduler-calendar-day--empty {
  visibility: hidden;
}

nilo-scheduler .nilo-scheduler-calendar-day.is-active,
nilo-scheduler .nilo-scheduler-slot.is-active {
  border-color: var(--nilo-widget-accent);
  background: var(--nilo-widget-accent);
  color: #ffffff;
}

nilo-scheduler .nilo-scheduler-type-list,
nilo-scheduler .nilo-scheduler-slot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

nilo-scheduler .nilo-scheduler-slot {
  display: inline-flex;
  flex: 1 1 calc(50% - 0.225rem);
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--nilo-widget-radius-sm);
  color: var(--nilo-widget-accent-strong);
  font-weight: 700;
}

nilo-scheduler .nilo-scheduler-slot-list--stack .nilo-status {
  margin: 0;
}

nilo-scheduler .nilo-scheduler-details {
  gap: 0.85rem;
}

nilo-scheduler .nilo-scheduler-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

nilo-scheduler .nilo-scheduler-actions {
  justify-content: flex-end;
}

nilo-scheduler .nilo-widget-loading {
  min-height: 6rem;
  border-radius: var(--nilo-widget-radius);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--nilo-widget-accent) 8%, transparent),
    color-mix(in srgb, var(--nilo-widget-accent) 18%, transparent),
    color-mix(in srgb, var(--nilo-widget-accent) 8%, transparent)
  );
  background-size: 200% 100%;
  animation: nilo-widget-pulse 1.5s ease-in-out infinite;
}

@keyframes nilo-widget-pulse {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@media (max-width: 720px) {
  .scheduler-dialog {
    width: min(100vw, 32rem);
    max-height: 100vh;
  }

  .scheduler-dialog__surface {
    max-height: 100vh;
    padding: 0.75rem;
  }

  nilo-scheduler .nilo-widget-card {
    padding: 1rem;
  }

  nilo-scheduler .nilo-widget-grid {
    grid-template-columns: 1fr;
  }

  nilo-scheduler .nilo-scheduler-card {
    min-height: 0;
    flex-direction: column;
  }

  nilo-scheduler .nilo-scheduler-summary {
    flex-basis: auto;
    border-right: 0;
    border-bottom: 1px solid var(--nilo-widget-border);
  }

  nilo-scheduler .nilo-scheduler-progress {
    gap: 0.6rem;
  }

  nilo-scheduler .nilo-scheduler-progress-step {
    min-height: 0;
  }

  nilo-scheduler .nilo-scheduler-progress-step:not(:last-child)::after {
    display: none;
  }

  nilo-scheduler .nilo-submit,
  nilo-scheduler .nilo-scheduler-slot {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  nilo-scheduler .nilo-widget-loading {
    animation: none;
  }
}
