:host {
  --vc-background: var(
    --ha-card-background,
    var(--card-background-color, white)
  );
  --vc-primary-text-color: var(--primary-text-color);
  --vc-secondary-text-color: var(--secondary-text-color);
  --vc-icon-color: var(--secondary-text-color);
  --vc-toolbar-background: var(--vc-background);
  --vc-toolbar-text-color: var(--secondary-text-color);
  --vc-toolbar-icon-color: var(--secondary-text-color);
  --vc-divider-color: var(--entities-divider-color, var(--divider-color));
  --vc-spacing: 10px;

  display: flex;
  flex: 1;
  flex-direction: column;
}

ha-card {
  flex-direction: column;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.preview {
  background: var(--vc-background);
  position: relative;
  text-align: center;

  &.not-available {
    filter: grayscale(1);
  }
}

.header {
  display: flex;
  justify-content: space-between;
}

.tips {
  display: flex;
  gap: var(--vc-spacing);
  flex-grow: 1;
  flex-wrap: wrap;
  padding: var(--vc-spacing);

  & .tip {
    cursor: pointer;
  }
}

.map {
  max-width: 95%;
  image-rendering: crisp-edges;
  cursor: pointer;
}

@keyframes cleaning {
  0% {
    transform: rotate(0) translate(0);
  }
  5% {
    transform: rotate(0) translate(0, -10px);
  }
  10% {
    transform: rotate(0) translate(0, 5px);
  }
  15% {
    transform: rotate(0) translate(0);
  }
  /* Turn left */
  20% {
    transform: rotate(30deg) translate(0);
  }
  25% {
    transform: rotate(30deg) translate(0, -10px);
  }
  30% {
    transform: rotate(30deg) translate(0, 5px);
  }
  35% {
    transform: rotate(30deg) translate(0);
  }
  40% {
    transform: rotate(0) translate(0);
  }
  /* Turn right */
  45% {
    transform: rotate(-30deg) translate(0);
  }
  50% {
    transform: rotate(-30deg) translate(0, -10px);
  }
  55% {
    transform: rotate(-30deg) translate(0, 5px);
  }
  60% {
    transform: rotate(-30deg) translate(0);
  }
  70% {
    transform: rotate(0deg) translate(0);
  }
  /* Staying still */
  100% {
    transform: rotate(0deg);
  }
}

@keyframes returning {
  0% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(10deg);
  }
  50% {
    transform: rotate(0);
  }
  75% {
    transform: rotate(-10deg);
  }
  100% {
    transform: rotate(0);
  }
}

.vacuum {
  display: block;
  max-width: 90%;
  max-height: 200px;
  image-rendering: crisp-edges;
  margin: var(--vc-spacing) auto;
  cursor: pointer;
  filter: brightness(0.9);
}

.vacuum.on,
.vacuum.cleaning,
.vacuum.auto,
.vacuum.spot,
.vacuum.edge,
.vacuum.single_room {
  animation: cleaning 5s linear infinite;
}

.vacuum.returning {
  animation: returning 2s linear infinite;
}

.vacuum.paused {
  opacity: 100%;
}

.vacuum.docked {
  opacity: 50%;
}

.fill-gap {
  flex-grow: 1;
}

.more-info ha-icon {
  display: flex;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
}

.status-text {
  color: var(--vc-secondary-text-color);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin-left: calc(28px + var(--vc-spacing)); /* size + margin of spinner */
}

.status mwc-circular-progress {
  --mdc-theme-primary: var(--vc-secondary-text-color) !important;
  margin-left: var(--vc-spacing);
}

.vacuum-name {
  text-align: center;
  font-weight: bold;
  color: var(--vc-primary-text-color);
  font-size: 16px;
}

.not-available .offline {
  text-align: center;
  color: var(--vc-primary-text-color);
  font-size: 16px;
}

.metadata {
  margin: var(--vc-spacing) auto;
}

.stats {
  border-top: 1px solid var(--vc-divider-color);
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  color: var(--vc-secondary-text-color);
}

.stats-block {
  cursor: pointer;
  padding: var(--vc-spacing) 0px;
  text-align: center;
  border-right: 1px solid var(--vc-divider-color);
  flex-grow: 1;

  &:last-of-type {
    border-right: 0px;
  }
}

.stats-value {
  font-size: 20px;
  color: var(--vc-primary-text-color);
}

ha-icon {
  color: var(--vc-icon-color);
}

.toolbar {
  background: var(--vc-toolbar-background);
  min-height: 30px;
  display: flex;
  flex-direction: row;
  flex-flow: row wrap;
  flex-wrap: wrap;
  justify-content: space-evenly;
  padding: 5px;
  border-top: 1px solid var(--vc-divider-color);
}

.toolbar ha-icon-button {
  color: var(--vc-toolbar-text-color);
  flex-direction: column;
  width: 44px;
  height: 44px;
  --mdc-icon-button-size: 44px;
}

.toolbar paper-button {
  color: var(--vc-toolbar-text-color);
  display: flex;
  align-items: center;
  margin-right: 10px;
  padding: 15px 10px;
  cursor: pointer;

  & ha-icon {
    margin-right: 5px;
    color: var(--vc-toolbar-icon-color);
  }
}

.toolbar ha-icon {
  color: var(--vc-toolbar-icon-color);
  display: flex;
}

.icon-title {
  display: inline-block;
  vertical-align: middle;
  padding: 0 3px;
}
