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

.fleet-report-modal__overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: $color-backdrop;
  backdrop-filter: blur(2px);
}

.fleet-report-modal {
  position: fixed;
  z-index: 120;
  top: 50%;
  left: 50%;

  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 24px;
  border-radius: 26px;
  background: $color-surface;
  box-shadow: $shadow-modal;
  transform: translate(-50%, -50%);
}

.fleet-report-modal__header {
  margin-bottom: 22px;

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

.fleet-report-modal__title {
  margin: 0;
  color: $color-text-strong;
  font-size: $font-size-24;
  font-weight: 650;
}

.fleet-report-modal__description {
  max-width: 720px;
  margin: 6px 0 0;
  color: $gray50;
  font-size: $font-size-15;
  font-weight: 400;
  line-height: 1.35;
}

.fleet-report-modal__close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: $color-bg;

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

  color: $gray50;
  cursor: pointer;
  transition: 0.2s ease;

  &:hover {
    color: $blue;
    background: $gray20;
  }

  &:disabled {
    opacity: 0.6;
    cursor: default;
  }
}

.fleet-report-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fleet-report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  align-items: stretch;
}

.fleet-report-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid $color-border-accent;
  border-radius: 22px;
  background: $color-surface-muted;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fleet-report-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

  h3 {
    margin: 0;
    color: $color-text-strong;
    font-size: $font-size-16;
    font-weight: 650;
  }

  p {
    margin: 5px 0 0;
    color: $gray50;
    font-size: $font-size-13;
    font-weight: 500;
    line-height: 1.35;
  }

  >span {
    min-width: 34px;
    height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    background: $blue20;
    color: $blue;

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

    font-size: $font-size-14;
    font-weight: 700;
  }
}

.fleet-report-search {
  height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  background: $color-surface;
  border: 1px solid $color-border-strong;

  display: flex;
  align-items: center;
  gap: 8px;

  color: $gray50;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;

  input {
    width: 100%;
    border: none;
    outline: none;
    background: $transparent;
    color: $color-text-strong;
    font-size: $font-size-15;

    &::placeholder {
      color: $gray50;
    }
  }

  &:focus-within {
    border-color: $blue;
    box-shadow: 0 0 0 3px rgba($color-primary-rgb, 0.12);
  }
}

.fleet-report-recipient-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;

  button {
    min-height: 34px;
    padding: 0 12px;
    border: none;
    border-radius: 12px;
    background: $color-surface;
    color: $blue;
    font-size: $font-size-13;
    font-weight: 650;
    cursor: pointer;
    transition:
      background-color 0.18s ease,
      color 0.18s ease;

    &:hover:not(:disabled) {
      background: $blue20;
    }

    &:disabled {
      color: $gray50;
      cursor: default;
      opacity: 0.72;
    }
  }
}

.fleet-report-recipient-list {
  height: 390px;
  overflow: auto;
  padding-right: 4px;

  display: flex;
  flex-direction: column;
  gap: 8px;

  scrollbar-width: thin;
  scrollbar-color: $gray50 $transparent;
}

.fleet-report-recipient {
  min-width: 0;
  min-height: 62px;
  padding: 10px;
  border: 1px solid $transparent;
  border-radius: 16px;
  background: $color-surface;

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

  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;

  input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  &:hover {
    border-color: $color-border-accent;
    box-shadow: 0 10px 22px -18px rgba($color-shadow-rgb, 0.45);
  }

  &.is-selected {
    border-color: rgba($color-primary-rgb, 0.24);
    background: $blue20;

    .fleet-report-recipient__check {
      opacity: 1;
      transform: scale(1);
    }
  }
}

.fleet-report-recipient__avatar {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba($white, 0.1), $transparent 28%),
    linear-gradient(135deg, $blue, $color-primary-hover);
  color: $color-text-inverse;

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

  font-size: $font-size-13;
  font-weight: 750;
  letter-spacing: 0.04em;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.fleet-report-recipient__info {
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 3px;

  strong,
  small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  strong {
    color: $color-text;
    font-size: $font-size-15;
    font-weight: 650;
  }

  small {
    color: $gray50;
    font-size: $font-size-12;
    font-weight: 500;
  }
}

.fleet-report-recipient__role {
  padding: 6px 9px;
  border-radius: 999px;
  background: $color-bg;
  color: $gray50;
  font-size: $font-size-12;
  font-weight: 650;
  white-space: nowrap;
}

.fleet-report-recipient__check {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: $blue;
  color: $color-text-inverse;
  opacity: 0;
  transform: scale(0.86);

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

  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.fleet-report-recipient-state {
  padding: 24px 12px;
  color: $gray50;
  font-size: $font-size-14;
  font-weight: 550;
  text-align: center;

  &.is-error {
    color: $red;
  }
}

.fleet-report-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fleet-report-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;

  >span {
    color: $color-text-heading;
    font-size: $font-size-14;
    font-weight: 600;
  }
}

.fleet-report-format {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;

  button {
    min-width: 0;
    min-height: 52px;
    padding: 12px;
    border: 1px solid $color-border-strong;
    border-radius: 16px;
    background: $color-surface;
    color: $color-text;
    text-align: left;

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

    cursor: pointer;
    transition:
      border-color 0.18s ease,
      background-color 0.18s ease,
      box-shadow 0.18s ease;

    svg {
      color: $blue;
    }

    span {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    b {
      color: $color-text-strong;
      font-size: $font-size-15;
      font-weight: 700;
    }

    &:hover:not(:disabled),
    &.is-selected {
      border-color: rgba($color-primary-rgb, 0.24);
      background: $blue20;
    }

    &.is-selected {
      box-shadow: 0 10px 24px -20px rgba($color-primary-rgb, 0.9);
    }

    &:disabled {
      opacity: 0.7;
      cursor: default;
    }
  }
}

.fleet-report-time {
  height: 44px;
  padding: 0 12px;
  border: 1px solid $color-border-strong;
  border-radius: 14px;
  background: $color-surface;

  display: flex;
  align-items: center;
  gap: 8px;

  color: $gray50;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;

  input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: $transparent;
    color: $color-text-strong;
    font: inherit;
    font-size: $font-size-15;
  }

  &:focus-within {
    border-color: $blue;
    box-shadow: 0 0 0 3px rgba($color-primary-rgb, 0.12);
  }
}

.fleet-report-period {
  min-height: 64px;
  padding: 12px;
  border-radius: 16px;
  background: $color-surface;

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

  >svg {
    width: 20px;
    height: 20px;
    padding: 8px;
    border-radius: 12px;
    color: $blue;
    background: $blue20;
  }

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

  span {
    color: $gray50;
    font-size: $font-size-12;
    font-weight: 650;
  }

  b {
    color: $color-text-strong;
    font-size: $font-size-15;
    font-weight: 700;
    line-height: 1.25;
  }
}

.fleet-report-download {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 14px;
  background: $blue20;
  color: $blue;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  font: inherit;
  font-size: $font-size-15;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;

  &:hover:not(:disabled) {
    background: $color-primary-tint;
    box-shadow: 0 8px 20px -12px rgba($color-primary-rgb, 0.7);
  }

  &:disabled {
    opacity: 0.6;
    cursor: default;
  }
}

.fleet-report-submit-error {
  padding: 12px 14px;
  border-radius: 14px;
  background: $color-danger-bg;
  color: $red;
  font-size: $font-size-14;
  font-weight: 600;
}

.fleet-report-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  >span {
    color: $gray50;
    font-size: $font-size-14;
    font-weight: 600;
  }

  >div {
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

.fleet-report-modal__cancel,
.fleet-report-modal__submit {
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  font-size: $font-size-15;
  font-weight: 650;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.fleet-report-modal__cancel {
  background: $color-bg;
  color: $gray50;

  &:hover:not(:disabled) {
    color: $color-text;
    background: $gray20;
  }
}

.fleet-report-modal__submit {
  background: $blue;
  color: $color-text-inverse;

  &:hover:not(:disabled) {
    box-shadow: 0 8px 20px -8px rgba($color-primary-rgb, 0.8);
  }

  &:disabled {
    opacity: 0.6;
    cursor: default;
  }
}

@include laptop-down {
  .fleet-report-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .fleet-report-recipient-list {
    height: 320px;
  }
}

@include tablet-down {
  .fleet-report-modal {
    padding: 18px;
    border-radius: 22px;
  }

  .fleet-report-format {
    grid-template-columns: minmax(0, 1fr);
  }

  .fleet-report-recipient {
    grid-template-columns: 40px minmax(0, 1fr) 28px;
  }

  .fleet-report-recipient__role {
    display: none;
  }

  .fleet-report-modal__footer {
    align-items: stretch;
    flex-direction: column;

    >div {
      width: 100%;
      flex-direction: column-reverse;
      align-items: stretch;
    }
  }
}
