@use '../../../../shared/styles/variables' as *;

.machine-charts-tab {
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.machine-charts-toolbar {
  min-width: 0;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;

  p {
    margin: 6px 0 0;
    color: $color-text-muted;
    font-size: $font-size-14;
    font-weight: 550;
    line-height: 1.35;
  }
}

.machine-charts-period-control {
  flex: 0 0 auto;
  padding: 4px;
  border-radius: 12px;
  background: $color-surface;
  box-shadow: $shadow-card-soft;

  display: inline-flex;
  align-items: center;
  gap: 4px;

  button {
    height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: 9px;
    background: transparent;

    color: $color-text-muted;
    font-family: inherit;
    font-size: $font-size-14;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      box-shadow 0.2s ease;

    &:hover {
      color: $color-text-heading;
      background: $color-surface-hover;
    }

    &.is-active {
      background: $blue;
      color: $color-text-inverse;
      box-shadow: var(--shadow-primary);
    }
  }
}

.machine-charts-loading {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  background: $color-surface-subtle;

  color: $color-text-muted;
  font-size: $font-size-13;
  font-weight: 650;
}

.machine-usage-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.machine-usage-kpi-card {
  min-width: 0;
  padding: 14px;
  border-radius: 10px;
  background: $color-bg;

  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 14px;

  svg {
    width: 28px;
    height: 28px;
    padding: 8px;
    border-radius: 10px;
    color: $blue;
    background: $blue20;
  }

  div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  span {
    overflow: hidden;
    color: $color-text-muted;
    font-size: $font-size-13;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  b {
    color: $color-text-heading;
    font-size: $font-size-18;
    font-weight: 760;
    line-height: 1.1;
  }
}

.machine-usage-kpi-card--moving svg {
  background: $color-success-tint;
  color: $color-success;
}

.machine-usage-kpi-card--engine-on svg {
  background: $color-warning-tint;
  color: $color-warning;
}

.machine-usage-kpi-card--idle svg {
  background: rgba($gray50-rgb, 0.15);
  color: $color-text-muted;
}

.machine-usage-kpi-card--no-data svg {
  background: $color-danger-tint;
  color: $red;
}

.machine-usage-kpi-card--utilization svg {
  background: $blue20;
  color: $blue;
}

.machine-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: stretch;
}

.machine-chart-card {
  min-width: 0;
}

.machine-chart-card--wide {
  grid-column: span 1;
}

.machine-chart-card:nth-child(3) {
  grid-column: 1 / -1;
}

.machine-state-timeline-chart,
.machine-distribution-chart,
.machine-usage-trend-chart {
  min-width: 0;
}

.machine-state-timeline-chart .echarts-for-react,
.machine-distribution-chart .echarts-for-react,
.machine-usage-trend-chart .echarts-for-react {
  width: 100%;
}

.machine-chart-empty {
  min-height: 180px;
  padding: 18px;
  border-radius: 10px;
  background: $color-bg;

  display: flex;
  align-items: center;
  justify-content: center;

  color: $color-text-muted;
  font-size: $font-size-15;
  font-weight: 650;
  text-align: center;
}

.machine-distribution-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.machine-distribution-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.machine-distribution-item {
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid $gray20;

  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;

  &:last-child {
    border-bottom: none;
  }

  span:not(.machine-distribution-item__dot) {
    overflow: hidden;
    color: $color-text-strong;
    font-size: $font-size-14;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  strong {
    color: $color-text-heading;
    font-size: $font-size-14;
    font-weight: 700;
    white-space: nowrap;
  }

  em {
    min-width: 40px;
    color: $color-text-muted;
    font-size: $font-size-13;
    font-style: normal;
    font-weight: 650;
    text-align: right;
  }
}

.machine-distribution-item__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

@include laptop-down {
  .machine-usage-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .machine-charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .machine-chart-card:nth-child(3) {
    grid-column: auto;
  }
}

@include tablet-down {
  .machine-charts-toolbar {
    flex-direction: column;
  }

  .machine-charts-period-control {
    max-width: 100%;
    overflow-x: auto;
  }

  .machine-usage-kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
