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

const styles = css`
  ${componentStyles}

  :host {
    display: block;

    --border-color: var(--flow-ui-details-border-color);
    --border-radius: var(--flow-ui-details-border-radius);
    --border-width: var(--flow-ui-details-border-width);
    --padding: var(--flow-ui-spacing-small);

    --background-color: var(--flow-ui-details-background-color);
    --color: var(--flow-ui-details-color);
  }

  .details {
    border: solid var(--border-width) var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--color);
    overflow-anchor: none;
  }

  .details--disabled {
    opacity: 0.5;
  }

  .details__header {
    display: flex;
    align-items: center;
    border-radius: inherit;
    padding: var(--padding);
    user-select: none;
    cursor: pointer;
  }

  .details__header:focus {
    outline: none;
  }

  .details__header:focus-visible {
    outline: var(--flow-ui-focus-ring);
    outline-offset: calc(1px + var(--flow-ui-focus-ring-offset));
  }

  .details--disabled .details__header {
    cursor: not-allowed;
  }

  .details--disabled .details__header:focus-visible {
    outline: none;
    box-shadow: none;
  }

  .details__summary {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
  }

  .details__summary::slotted(*) {
    margin-right: var(--flow-ui-spacing-small);
  }

  .details__summary-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    transition: var(--flow-ui-transition-medium) rotate ease;
  }

  .details--open .details__summary-icon {
    rotate: 90deg;
  }

  .details--open.details--rtl .details__summary-icon {
    rotate: -90deg;
  }

  .details--open slot[name='expand-icon'],
  .details:not(.details--open) slot[name='collapse-icon'] {
    display: none;
  }

  .details__body {
    overflow: hidden;
  }

  .details__content {
    display: block;
    padding: var(--padding);
    padding-top: 0;
  }

  .details__content::slotted(:first-child) {
    margin-top: 0;
  }

  .details__content::slotted(:last-child) {
    margin-bottom: 0;
  }
`;

export { styles as default };
