@layer modules {
  .time-off-page {
    margin-inline: auto;
    padding-block: 2rem;
    padding-inline: 1rem;

    @media (min-width: 40rem) {
      padding-inline: 1.5rem;
    }

    @media (min-width: 64rem) {
      padding-inline: 2rem;
    }
  }

  .time-off-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;

    @media (min-width: 48rem) {
      flex-direction: row;
    }
  }

  .time-off-main {
    flex: 1;
    min-width: 0;
  }

  .time-off-header {
    margin-bottom: 2rem;
  }

  .time-off-header--split {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  .time-off-header__title {
    font-weight: var(--font-weight-bold);
    font-size: var(--text-4xl);
    line-height: var(--text-4xl--line-height);
  }

  .time-off-header__subtitle {
    margin-top: 0.5rem;
    color: var(--color-gray-600);
  }

  .time-off-list {
    & > :not(:last-child) {
      margin-block-end: 0.75rem;
    }
  }

  .time-off-card {
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .time-off-card--past {
    opacity: 0.6;
  }

  .time-off-card__range {
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-900);
  }

  .time-off-card__reason {
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    color: var(--color-gray-500);
    margin-top: 0.125rem;
  }

  .time-off-card__delete {
    color: var(--color-red-600);

    &:hover {
      color: var(--color-red-800);
    }
  }

  .time-off-card__delete-icon {
    height: 1.25rem;
    width: 1.25rem;
  }

  .time-off-empty {
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    color: var(--color-gray-500);
  }

  .time-off-past {
    margin-top: 2rem;
  }

  .time-off-past__summary {
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-500);
    cursor: pointer;

    &:hover {
      color: var(--color-gray-700);
    }
  }

  .time-off-past__list {
    margin-top: 0.75rem;

    & > :not(:last-child) {
      margin-block-end: 0.75rem;
    }
  }

  .time-off-form-card {
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
  }

  .time-off-form {
    & > :not(:last-child) {
      margin-block-end: 1.5rem;
    }
  }

  .time-off-errors {
    border-radius: var(--radius-md);
    background-color: var(--color-red-50);
    padding: 1rem;
  }

  .time-off-errors__body {
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    color: var(--color-red-700);
  }

  .time-off-errors__list {
    list-style-type: disc;
    padding-left: 1.25rem;

    & > :not(:last-child) {
      margin-block-end: 0.25rem;
    }
  }

  .time-off-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    width: fit-content;
  }

  .time-off-switch__label {
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-700);
  }

  .time-off-switch__control {
    position: relative;
    display: inline-flex;
    height: 1.5rem;
    width: 2.75rem;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-color: var(--color-blue-600);
    transition: var(--default-transition-duration) var(--default-transition-timing-function);
    transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke;

    &:focus-visible {
      outline: var(--focus-ring);
      outline-offset: var(--focus-ring-offset);
    }
  }

  .time-off-switch__knob {
    pointer-events: none;
    position: relative;
    display: inline-block;
    height: 1.25rem;
    width: 1.25rem;
    translate: 1.25rem 0;
    border-radius: var(--radius-full);
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
    transition: var(--default-transition-duration) var(--default-transition-timing-function);
    transition-property: transform, translate, scale, rotate;
  }

  .time-off-fields {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.5rem;

    @media (min-width: 48rem) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .time-off-field__input {
    margin-top: 0.25rem;
    display: block;
    width: 100%;
    border-radius: var(--radius-md);
    border-color: var(--color-gray-300);
    box-shadow: var(--shadow-xs);

    &:focus {
      --focus-ring-color: var(--color-blue-500);
      border-color: var(--color-blue-500);
    }
  }

  .time-off-form-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .time-off-cancel {
    font-size: var(--text-sm);
    line-height: var(--text-sm--line-height);
    color: var(--color-gray-600);

    &:hover {
      color: var(--color-gray-900);
    }
  }
}

/*
  All-day toggle state. The base .time-off-switch__control / __knob above hold
  the ON (all-day) look — blue track, knob shifted right — which matches the
  controller's default (allDay = true) and the static aria-checked="true". The
  time_off_form controller flips the single data-time-off-form-off attribute on
  its root when all-day is turned off; these rules restore the OFF look.
*/
@layer modules {
  [data-controller~="time-off-form"][data-time-off-form-off] .time-off-switch__control {
    background-color: var(--color-gray-200);
  }

  [data-controller~="time-off-form"][data-time-off-form-off] .time-off-switch__knob {
    translate: 0px 0;
  }
}
