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

const styles = css`
  ${componentStyles}

  :host {
    display: inline-block;

    --color: var(--flow-ui-gauge-color, var(--flow-ui-color-text));
    --background-color: var(--flow-ui-gauge-background-color, var(--flow-ui-color-neutral-100));
    --padding: var(--flow-ui-gauge-padding, var(--flow-ui-spacing-x-small));
    --header-height: var(--flow-ui-gauge-font-header-height, var(--flow-ui-control-height-medium));
    --header-font-size: var(--flow-ui-gauge-font-header-font-size, var(--flow-ui-font-size-medium));
    --header-color: var(--flow-ui-gauge-header-color, var(--flow-ui-color-text));
    --header-icon-color: var(--flow-ui-gauge-header-icon-color, var(--flow-ui-color-neutral-700));
    --value-font-size: var(--flow-ui-gauge-value-font-size, var(--flow-ui-font-size-2x-large));
    --units-font-size: var(--flow-ui-gauge-units-font-size, var(--flow-ui-font-size-small));
    --units-color: var(--flow-ui-gauge-units-color, var(--flow-ui-color-text));
  }

  .gauge {
    color: var(--color);
    background-color: var(--background-color);

    display: flex;
    height: 100%;
    flex-direction: column;
  }

  .gauge__header {
    height: var(--header-height);
    padding: 0 var(--padding);
    flex-shrink: 0;

    display: flex;
    gap: var(--padding);
    align-items: center;
    justify-content: flex-start;

    font-size: var(--header-font-size);
    color: var(--header-color);
  }

  .gauge__header-icon {
    color: var(--header-icon-color);
  }

  .gauge__header-button {
    color: var(--header-icon-color);
  }

  .gauge__header-button::part(base) {
    /* remove left/right padding from button - replaced by flex gap and padding on header */
    padding-inline: 0;
  }

  /* Wrapper needed to support text ellipsis in flex item */
  .gauge__title-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
  }

  .gauge__title {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .gauge__body {
    flex: 1;
    /* Prevent content from expanding body beyond its bounds */
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--padding);
    line-height: 1;
    padding: var(--padding);
  }

  .gauge__value {
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .gauge__units {
    max-width: 100%;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.2;
  }

  .gauge__value {
    color: var(--color);
    font-size: var(--value-font-size);
    font-weight: var(--flow-ui-font-weight-bold);
  }

  .gauge__units {
    color: var(--units-color);
    font-size: var(--units-font-size);
  }

  /* Spacer to keep gauge value and units visually centered and balanced with header*/
  .gauge__spacer {
    flex: 1;
    align-self: stretch;
    min-height: 0;
    max-height: calc(var(--header-height) * 0.6);
  }

  /* Info Dialog */
  .gauge__info-dialog-heading {
    display: flex;
    gap: var(--flow-ui-spacing-small);
    align-items: center;
  }
`;

export { styles as default };
