@use "../../../styles/mixins";

.root {
  --group-call-panel-color: #212121;
  --group-call-panel-header-border-color: #3b3b3b;
  --color-dividers: var(--group-call-panel-header-border-color);
  --group-call-background-color: #000000;
  --green-button-color: rgba(1, 200, 80, 0.3);
  --blue-button-color: rgb(60, 135, 247, 0.2);
  --purple-button-color: rgb(61, 82, 223, 0.2);
  --gradient-blue: linear-gradient(225deg, #4EABF8 14.73%, #3478F6 85.27%);
  --gradient-green: linear-gradient(230.46deg, #00A3B4 12.94%, #00CB47 86.29%);
  --gradient-purple: linear-gradient(230.46deg, #CE4D74 0%, #3D52DF 100%);
  --gradient-speaking: linear-gradient(135deg, #5CC85C 0%, #48A1B3 101.27%);

  --red-button-color: rgba(255, 89, 90, 0.3);
  --disabled-button-color: #333333;
  --color-text-secondary: #AAAAAA;
  --color-text: #FFFFFF;

  --default-width: 26.25rem;
  --max-height: 40rem;

  color: var(--color-text);

  :global {
    .modal-dialog {
      overflow: hidden;

      max-width: var(--default-width);
      height: 100%;
      min-height: min(80vh, var(--max-height));
      max-height: min(var(--max-height), 100vh);

      background: var(--group-call-background-color);
    }

    .modal-content {
      display: flex;
      min-height: 100%;
      padding: 0;
    }
  }
}

.panelWrapper {
  width: 100%;
  max-width: var(--default-width);
}

.panel {
  position: relative;

  overflow-y: scroll;
  display: flex;
  flex-direction: column;

  height: 100%;

  background: var(--group-call-panel-color);
}

.panelScrollTrigger {
  position: absolute;
  top: 0;
  width: 100%;
}

.panelHeader {
  user-select: none;

  position: sticky;
  z-index: 1;
  top: 0;

  display: flex;
  align-items: center;

  padding: 0.375rem 0.875rem;
  border-bottom: 0.0625rem solid transparent;

  background: var(--group-call-panel-color);

  transition: 0.25s ease-in-out border-bottom-color;

  @include mixins.adapt-padding-to-scrollbar(0.875rem);

  &.scrolled {
    border-bottom-color: var(--group-call-panel-header-border-color);
  }

  :global(body.is-tauri) .root.fullscreen:not(.landscape) & {
    padding-left: var(--window-controls-width);
  }
}

.headerButton {
  color: var(--color-text) !important;
}

.firstButton {
  margin-right: 1.375rem;
}

.lastButton {
  margin-left: auto;
}

.panelHeaderText {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title {
  unicode-bidi: plaintext;
  overflow: hidden;

  margin: 0;

  font-size: 1rem;
  font-weight: var(--font-weight-medium);
  line-height: 1.375rem;
  text-overflow: ellipsis;
  white-space: pre;
}

.bigger {
  font-size: 1.25rem;
}

.subtitle {
  overflow: hidden;
  display: inline-block;

  margin: 0;

  font-size: 0.875rem;
  line-height: 1.125rem;
  color: var(--color-text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participants {
  position: relative;
  margin: 0.125rem 0.5rem 0;

  @include mixins.adapt-margin-to-scrollbar(0.5rem);
}

.participantVideos {
  position: relative;
  width: 100%;
}

.addParticipantButton {
  position: fixed;
}

.videos {
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--default-width));
}

.mainVideoContainer {
  position: absolute;
}

.videosHeader {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.875rem;

  :global(body.is-tauri) .root:not(.appFullscreen) & {
    padding-left: var(--window-controls-width);
  }
}

.videosHeaderLastButton {
  margin-left: auto;
}

.videosContent {
  flex-grow: 1;
  margin: 0.1875rem 0.625rem 0.5rem;
}

.actions {
  --actions-max-width: 0px;

  position: absolute;
  z-index: 2;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(calc(-50% - var(--actions-max-width) / 2));

  display: flex;
  gap: 1.25rem;
}

.actionButton {
  width: 3.375rem !important;
  height: 3.375rem !important;

  color: var(--color-text) !important;

  background-color: var(--green-button-color) !important;
  backdrop-filter: blur(25px);

  transition: 0.15s filter, 0.25s ease-out background-color;

  &:global(.disabled) {
    background: var(--disabled-button-color) !important;
  }

  &:hover {
    filter: brightness(1.1);
  }
}

.destructive {
  background: var(--red-button-color) !important;
}

.canRequestToSpeak {
  background: var(--purple-button-color) !important;
}

.muted {
  background: var(--blue-button-color) !important;
}

.fullscreen {
  :global {
    .modal-dialog {
      min-width: 100%;
      min-height: 100%;
      border-radius: 0;
    }

    .modal-content {
      max-height: initial;
    }
  }

  &.portrait .panelWrapper {
    max-width: 100%;
  }
}

.landscape {
  .panelWrapper {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateZ(0);
  }

  &:not(.noVideoParticipants) {
    .actions {
      --actions-max-width: var(--default-width);

      bottom: 2.5rem;

      padding: 0.75rem;
      border-radius: 1.25rem;

      opacity: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(50px);

      transition: 250ms ease-in-out opacity;
    }

    .videos:hover ~ .actions, .mainVideoContainer:hover ~ .actions, .actions:hover {
      opacity: 1;
    }
  }

  &.noVideoParticipants {
    .panelWrapper {
      right: 0;
      left: 50%;
      transform: translateX(-50%);

      width: 100%;
      max-width: max(50vw, 30rem);
    }

    :global(.modal-content) {
      background: var(--group-call-panel-color);
    }
  }
}

.portrait {
  .panelWrapper::after {
    pointer-events: none;
    content: '';

    position: fixed;
    bottom: 0;
    left: 0;

    display: block;

    width: 100%;
    height: 7.5rem;

    background: linear-gradient(180deg, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.65) 48.54%, #212121 100%);
  }
}

.noSidebar {
  .panelWrapper {
    transform: translate3d(100%, 0, 0);
  }

  .videos {
    width: 100%;
  }

  .actions {
    --actions-max-width: 0px !important;
  }
}
