import { css } from 'lit';
import componentStyles from '../../styles/component.styles.mjs';

const styles = css`
  ${componentStyles}

  :host {
    display: inline-block;
    --width: 300px;
    --font-size: var(--flow-ui-font-size-medium);
    --day-font-size: var(--flow-ui-font-size-small);
    --day-color-filler: var(--flow-ui-calendar-day-color-filler);
    --day-color-hover: var(--flow-ui-calendar-day-color-hover);
    --day-color-selected: var(--flow-ui-calendar-day-color-selected);
    --day-color-today: var(--flow-ui-calendar-day-color-today);
  }

  .calendar {
    width: var(--width);
    font-size: var(--font-size);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--flow-ui-spacing-x-small);
    user-select: none;
  }

  .calendar--small {
    --width: 270px;
    --font-size: var(--flow-ui-font-size-small);
    --day-font-size: var(--flow-ui-font-size-x-small);
  }

  .calendar--medium {
    --width: 300px;
    --font-size: var(--flow-ui-font-size-medium);
    --day-font-size: var(--flow-ui-font-size-small);
  }

  .calendar--large {
    --width: 350px;
    --font-size: var(--flow-ui-font-size-large);
    --day-font-size: var(--flow-ui-font-size-medium);
  }

  .calendar__header {
    display: flex;
    align-items: center;
  }

  .calendar__header-month {
    flex: 1;
    text-align: center;
  }

  .calendar__grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--flow-ui-spacing-2x-small);
  }

  .calendar__header-day {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: var(--flow-ui-font-weight-bold);
  }

  .calendar__day {
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    border-radius: var(--flow-ui-border-radius-circle);
    background-color: inherit;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    font-size: var(--day-font-size);
  }

  .calendar__day:hover:not(.calendar__day--selected) {
    background-color: var(--day-color-hover);
  }

  .calendar__day--filler {
    color: var(--day-color-filler);
  }

  .calendar__day--today {
    border: 1px solid var(--day-color-today);
  }

  .calendar__day--selected {
    color: var(--flow-ui-color-background);
    background-color: var(--day-color-selected);
  }

  .calendar__header {
    justify-content: space-between;
    padding-inline: var(--flow-ui-spacing-small);
  }

  .calendar__header-select::part(listbox) {
    max-height: min(var(--auto-size-available-height), 10rem);
  }

  .calendar__time-container {
    display: flex;
    gap: var(--flow-ui-spacing-2x-small);
    align-items: center;
  }

  .calendar__time-input {
    flex: 1;
    /* Allow the input to shrink to accommodate narrow calendars in sidebars */
    min-width: 0;
    --flow-ui-control-spacing-medium: var(--flow-ui-spacing-small);
  }

  .calendar__time-input::part(form-control-input) {
    background-color: var(--flow-ui-calendar-time-color);
  }

  .calendar__time-input::part(input) {
    /* Remove padding between spin controls to accommodate narrow calendars */

    padding-right: 0;
  }

  .calendar__time-separator {
    font-weight: var(--flow-ui-font-weight-bold);
  }

  .calendar__utc-marker {
    font-size: var(--flow-ui-font-size-2x-small);
    font-weight: var(--flow-ui-font-weight-bold);
    writing-mode: vertical-lr;
    text-orientation: upright;
    margin-left: calc(var(--flow-ui-spacing-2x-small) * -1);
  }

  .calendar--small .calendar__utc-marker {
    font-size: var(--flow-ui-font-size-3x-small);
  }
`;

export { styles as default };
