:root {
  --popups-margin: 4px;
}

@keyframes leftToRight {
  0%,
  25% {
    transform: translateX(0%);
    left: 0%;
  }
  75%,
  100% {
    transform: translateX(-100%);
    left: 100%;
  }
}

@keyframes rotateToTheLeft {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

%actionable-button {
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;

  &:hover {
    background-color: rgba(var(--config-accent-color-rgb), 0.2);
  }

  &:active {
    background-color: rgba(var(--config-accent-color-rgb), 0.4);
  }
}

%flex-centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

%list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

%hidden-scroll {
  ::-webkit-scrollbar {
    height: 0;
    width: 0;
  }
}

%section-title {
  font-size: 0.8rem;
  line-height: 1.2em;
  font-weight: 600;
  color: var(--color-gray-600);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

%popup {
  @extend %list;
  gap: 10px;
  margin: var(--popups-margin);
  width: 300px;
  max-height: calc(100vh - var(--config-height) - var(--popups-margin) * 2);
  padding: 10px;
  box-shadow: 0 0 10px 10px #0001;
  border-radius: 10px;
  font-size: 0.9rem;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }
}

.chevron {
  transition: transform 0.3s ease-in-out;
  &.chevron-active {
    transform: rotate(180deg);
  }
}

* {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background-color: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background-color: var(--color-gray-400);
    border-radius: 8px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-gray-500);
  }
}

#root {
  font-size: 0.8rem;
  font-weight: 500;
}

@keyframes PopupBaseAnimation {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.ft-bar {
  color: var(--color-persist-gray-100);
  transition: color 0.2s linear;

  > .bg-layers {
    // we skip the first layer, to avoid break user themes, as before v2.2 the first layer was a noise layer
    > .bg-layer-2 {
      background-color: var(--color-persist-gray-900);
      transition: background-color 0.2s linear;
      will-change: background-color;
    }
  }

  // &[data-there-is-maximized-on-background="true"] {} (this attribute exist but is unused)
  // &[data-focused-is-maximized="true"] {} (this attribute exist but is unused)
  // &[data-focused-is-overlay="true"] {} (this attribute exist but is unused)

  &[data-dynamic-color="true"] {
    // --color-focused-app-foreground (this var exist but is unused)
    color: var(
      --color-maximized-on-bg-foreground,
      var(--color-persist-gray-100)
    );

    > .bg-layers {
      > .bg-layer-2 {
        // --color-focused-app-background (this var exist but is unused)
        background-color: var(
          --color-maximized-on-bg-background,
          var(--color-persist-gray-900)
        );
      }
    }
  }
}

.ft-bar-item {
  .workspaces {
    height: var(--config-height);
    max-height: 100%;
    gap: 12px;

    .workspace-dot {
      width: 6px;
      height: 6px;
      border-radius: 3px;
      background-color: currentColor;
      transition-property: width, border-radius, background-color;
      transition-duration: 200ms;
      transition-timing-function: ease-out;

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

      &.workspace-dot-active {
        width: 18px;
        background-color: var(--config-accent-color);
      }
    }
  }
}

.ft-bar-item-context-menu-container,
.tb-context-menu-container {
  min-width: 160px;

  .bg-layer-1 {
    background-color: var(--color-gray-100);
    border-radius: 10px;
  }

  .tb-context-menu {
    max-height: 60vh;
    overflow-y: auto;

    > li {
      min-height: min-content;
    }

    .tb-context-menu-module-item {
      width: 240px;
      display: grid;
      grid-template-columns: 1rem 1rem 1fr;
      align-items: center;
      gap: 6px;

      .tb-context-menu-module-item-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        line-height: 1.4em;
      }
    }
  }
}

.ft-bar-item-clickable {
  padding: 1px 4px;
  border-radius: 6px;

  &:hover {
    backdrop-filter: brightness(3);
  }
}

.ft-bar-item-active {
  color: var(--config-accent-color);
}

.ft-bar-item-content {
  position: relative;
}

.ft-bar-item-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(25%, -25%);
  background-color: var(--config-accent-color);
  color: #efefef;
  height: 12px;
  min-width: 12px;
  font-size: 10px;
  border-radius: 8px;

  &:empty {
    display: none;
  }
}

.fast-settings {
  @extend %popup;
  width: 300px;
  position: relative;
  gap: 4px;

  .fast-settings-title {
    z-index: 1;
    font-weight: 600;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;

    .fast-settings-item-title-button {
      position: absolute;
      top: 0;
      right: 0;
      padding: 6px;
      border-radius: 6px;

      &:hover {
        backdrop-filter: brightness(0.8);
      }
    }
  }

  .fast-settings-item {
    z-index: 1;
    display: flex;
    gap: 6px;
    align-items: center;

    .ant-slider {
      flex: 1;
    }
  }

  .fast-settings-power {
    display: flex;
    gap: 6px;

    .fast-settings-item-button {
      @extend %actionable-button, %flex-centered;
      flex: 1;
      border: 1px solid var(--color-gray-600);
      border-radius: 8px;
      padding: 8px 12px;
    }
  }
}

.wlan-selector {
  @extend %popup;

  .wlan-selector-title {
    @extend %section-title;
  }

  .wlan-selector-refresh {
    @extend %actionable-button;
    .slu-icon {
      color: var(--color-gray-900);
      animation: rotateToTheLeft 1s linear infinite;
    }
  }

  .wlan-selector-entries {
    @extend %list;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-gray-300);
    overflow-y: auto;
    max-height: 30vh;

    .wlan-selector-empty {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 12px;
      font-style: italic;
    }

    .wlan-entry {
      display: flex;
      flex-direction: column;
      min-height: min-content;
      padding: 12px 10px;
      border-radius: 8px;
      gap: 10px;

      &:hover {
        background-color: var(--color-gray-200);
      }

      &.wlan-entry-selected {
        background-color: rgba(var(--config-accent-color-rgb), 0.2);
      }

      .wlan-entry-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-weight: 600;
        gap: 8px;

        .wlan-entry-info-ssid {
          flex: 1;
          color: var(--color-gray-800);
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .wlan-entry-info-channel {
          font-size: 0.5rem;
          color: var(--color-gray-600);
          border: 1px solid var(--color-gray-600);
          border-radius: 4px;
          padding: 2px 4px;
        }
      }

      .wlan-entry-fields {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }

      .wlan-entry-actions {
        display: flex;
        justify-content: flex-end;
      }
    }
  }

  .wlan-selector-footer {
    .wlan-selector-footer-button {
      @extend %actionable-button;
    }
  }
}

.media-control {
  @extend %popup;
  gap: 0px;

  .media-device-group {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 20vh;
    gap: 6px;

    .media-device {
      display: grid;
      align-items: center;
      grid-template-columns: min-content 1fr 50px;
      gap: 8px;

      .media-device-action {
        @extend %actionable-button;
        justify-content: center;
      }
    }
  }

  .media-device-header {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-bottom: 10px;

    .media-device-back {
      @extend %actionable-button;
    }

    .media-device-title {
      @extend %overflowable-text;
      flex: 1;
      font-weight: 600;
    }
  }

  .media-device-mixer {
    @extend %list;
    padding-right: 10px;

    .media-device-mixer-entry-icon {
      height: 100%;
      display: grid;
      align-items: center;
      grid-template-columns: 1fr 18px;
      gap: 4px;
    }
  }

  .media-device-footer {
    padding-top: 10px;

    .media-device-footer-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}

.media-notifier {
  margin: var(--popups-margin);
  width: 240px;
  padding: 6px 24px 6px 6px;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }
}

.media-control-volume {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  height: 30px;
  align-items: center;
  gap: 4px;

  .media-control-volume-action {
    @extend %actionable-button;
    height: 30px;
    width: 50px;
    justify-content: center;
  }
}

.fast-settings-label,
.media-control-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-gray-600);
  margin-bottom: 4px;
  display: block;
  width: 100%;

  &:not(:first-of-type) {
    margin-top: 10px;
    padding-top: 4px;
    border-top: solid 1px var(--color-gray-300);
  }
}

.media-device {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-gray-700);
}

.media-control-session-list {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  gap: 4px;
}

.media-session {
  display: grid;
  grid-template-columns: 80px 1fr;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  padding: 8px;
  gap: 8px;
  height: min-content;

  .media-session-thumbnail-container {
    position: relative;
    width: 100%;

    .media-session-app-icon {
      position: absolute;
      width: 25%;
      aspect-ratio: 1/1;
      right: 5%;
      bottom: 5%;
      object-fit: contain;
    }

    .media-session-thumbnail {
      border-radius: 8px;
      width: 100%;
      aspect-ratio: 1/1;
      object-fit: contain;
      background: #0004;
    }
  }

  .media-session-blurred-thumbnail {
    filter: blur(15px) brightness(125%) contrast(125%);
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: fill;
  }

  .media-session-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;

    .media-session-title,
    .media-session-author {
      position: relative;
      align-self: flex-start;
      font-size: 0.7rem;
      text-align: center;
      min-width: 100%;
      animation: leftToRight 5s infinite alternate ease-in-out;
    }

    .media-session-title {
      font-weight: 600;
      font-size: 1rem;
    }

    .media-session-actions {
      display: flex;
      justify-content: center;
      gap: 8px;
      margin-top: 4px;
    }
  }
}

.notifications {
  @extend %popup;
  width: 350px;

  .notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .notifications-clear-button {
      @extend %actionable-button;
      font-weight: 600;
      font-size: 0.8rem;
    }
  }

  .notifications-body {
    @extend %list;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 10px;
    margin: 0 -10px;
  }

  .notifications-footer {
    .notifications-settings-button {
      @extend %actionable-button;
      font-weight: 600;
      font-size: 0.8rem;
    }
  }

  .notifications-empty {
    @extend %flex-centered;
    color: var(--color-gray-500);
    font-weight: 600;
    font-size: 0.8rem;
  }
}

@keyframes text-highlight {
  0% {
    color: var(--color-gray-600);
  }
  66% {
    color: var(--config-accent-color);
  }
  100% {
    color: var(--color-gray-600);
  }
}

.notification-arrival {
  @extend %list;
  margin: var(--popups-margin);
  width: 350px;
  max-height: calc(100vh - var(--config-height) - var(--popups-margin) * 2);

  .notification-header-info {
    animation: text-highlight 5s ease-in-out infinite;
  }

  &:not(:has(.notification)) {
    display: none;
  }
}

.notification {
  border-radius: 12px;
  background-color: var(--color-gray-100);
  box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.4);
  padding: 10px;
  transition: scale 0.1s ease-in-out;

  &:active:not(:has(button:active, input:active)) {
    scale: 0.9;
  }

  .notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 6px;
    border-bottom: solid 1px var(--color-gray-300);
    margin-bottom: 6px;

    .notification-header-info {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.8rem;
      color: var(--color-gray-800);
      font-weight: 600;

      .notification-icon {
        width: 1.5em;
      }
    }

    .notification-header-close {
      @extend %actionable-button;
    }
  }

  .notification-body {
    display: grid;
    grid-template-columns: auto 1fr;

    .notification-body-logo-image {
      grid-column: 1 / 2;
      grid-row: 1 / 2;
      width: 3rem;
      height: 3rem;
      margin-right: 10px;

      &.notification-body-logo-image-circle {
        border-radius: 50%;
      }
    }

    .notification-body-content {
      word-break: break-word;
      overflow: hidden;
      grid-column: 2 / 3;
      grid-row: 1 / 2;

      > p:first-of-type {
        font-weight: 600;
      }

      .notification-group {
        display: flex;
        gap: 6px;

        .notification-subgroup {
          display: flex;
          flex-direction: column;
          gap: 10px;
        }
      }
    }

    .notification-body-hero-image {
      grid-column: 1 / 3;
      grid-row: 2 / 3;
      width: 100%;
      max-height: 300px;
      object-fit: cover;
      margin-top: 10px;
    }
  }

  .notification-actions {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    font-size: 0.8rem;
    line-height: 0.8rem;

    .notification-input {
      flex: 3;
      padding: 4px;
      border-radius: 6px;
      border: 1px solid var(--color-gray-600);
    }

    .notification-action {
      @extend %actionable-button;
      flex: 1;
      justify-content: center;
      border: 1px solid var(--color-gray-600);
    }
  }
}

.calendar-container {
  @extend %popup;
  width: 350px;

  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;

    .calendar-date {
      font-size: 1.2em;
      text-transform: capitalize;
      transition: 0.2s ease-in;
      transition-property: color, background-color;
      border-radius: 4px;
      padding: 0 4px;

      &:hover {
        color: var(--config-accent-color);
        background-color: var(--color-gray-200);
      }
    }

    .calendar-actions {
      display: flex;
      align-items: center;
      gap: 2px;

      .calendar-navigator {
        font-size: 1.2em;
        padding: 3px 8px;
        background-color: transparent;
        transition: 0.2s ease-in;
        transition-property: color, background-color;
        border-radius: 4px;

        &:hover {
          color: var(--config-accent-color);
          background-color: var(--color-gray-200);
        }
      }
    }
  }

  .calendar-cell-value {
    --margin: 4px;
    position: relative;
    transition: background-color 0.2s ease-in;
    border-radius: 4px;
    width: calc(100% - var(--margin) * 2);
    height: calc(100% - var(--margin) * 2);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--margin);

    &.calendar-cell-selected {
      background-color: var(--color-gray-100);
      color: var(--config-accent-color);
    }

    &:hover {
      background-color: var(--color-gray-200);
    }

    &.calendar-cell-today {
      background-color: rgba(var(--config-accent-color-rgb), 0.2);
    }

    &.calendar-cell-month {
      text-transform: capitalize;
    }
  }
}

.userhome {
  @extend %popup;
  gap: 4px;

  .userhome-label {
    @extend %section-title;
  }

  .userhome-file {
    @extend %actionable-button;
    display: grid;
    grid-template-columns: 1rem 1fr min-content;
    align-items: center;
    gap: 4px;

    .userhome-file-icon {
      object-fit: contain;
    }

    .userhome-file-label {
      @extend %overflowable-text;
    }

    .userhome-file-date {
      @extend %overflowable-text;
      color: var(--color-gray-600);
      font-size: 0.6rem;
    }
  }

  .userhome-empty-list {
    @extend %flex-centered;
    padding: 20px;
    font-style: italic;
    font-weight: 600;
    color: var(--color-gray-600);
    font-size: 0.8rem;
  }

  .userhome-list-extender {
    @extend %actionable-button;
    white-space: nowrap;
    width: min-content;
    font-size: 0.6rem;
    color: var(--color-gray-600);
  }

  .userhome-profile-container {
    display: flex;
    gap: 10px;

    .userhome-profile-picture-container {
      position: relative;
      height: 90px;
      width: 90px;

      .userhome-profile-picture {
        object-fit: contain;
        border-radius: 6px;
      }

      .userhome-profile-lock-button {
        @extend %actionable-button;
        position: absolute;
        left: 0;
        bottom: 0;
      }

      .userhome-profile-settings-button {
        @extend %actionable-button;
        position: absolute;
        right: 0;
        bottom: 0;
      }
    }

    .userhome-profile-information {
      @extend %list;
      flex: 1;

      .userhome-profile-name {
        text-transform: capitalize;
        font-size: 1.2rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .userhome-profile-email {
        color: var(--color-gray-600);
        margin-top: -8px;
        font-size: 0.8rem;
      }

      .userhome-profile-action-button {
        @extend %actionable-button;
      }
    }
  }

  .userhome-directory {
    .userhome-directory-header {
      @extend %actionable-button;
      position: relative;
      display: grid;
      grid-template-columns: 1rem 1fr;
      align-items: center;
      font-weight: 600;

      .userhome-directory-header-collapse-button {
        @extend %actionable-button, %flex-centered;
        position: absolute;
        right: 0;
        height: 100%;
        aspect-ratio: 1 / 1;
      }
    }

    .userhome-directory-content {
      @extend %list;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.4s ease-in-out;

      &.userhome-directory-content-open {
        max-height: 200px;
        overflow: auto;
      }
    }
  }

  .userhome-seelen-options {
    @extend %list;

    .userhome-seelen-option-item {
      @extend %actionable-button;
      font-weight: 600;
    }
  }

  .userhome-power {
    margin-top: 4px;
    display: flex;
    gap: 6px;

    .userhome-power-button {
      @extend %actionable-button, %flex-centered;
      flex: 1;
      border: 1px solid var(--color-gray-600);
      border-radius: 8px;
      padding: 8px 12px;
    }
  }
}

.keyboard-selector {
  @extend %popup;

  .keyboard-selector-header {
    @extend %section-title;
  }

  .keyboard-selector-body {
    @extend %list;

    .keyboard-selector-entry {
      @extend %actionable-button;
      display: grid;
      grid-template-columns: 20px 1fr;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;

      &.keyboard-selector-entry-active {
        background-color: rgba(var(--config-accent-color-rgb), 0.4);
      }

      .keyboard-selector-entry-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        .keyboard-selector-entry-lang {
          font-weight: 600;
          @extend %overflowable-text;
        }

        .keyboard-selector-entry-keyboard {
          font-size: 0.7em;
          line-height: 1.2em;
          font-weight: 600;
          color: var(--color-gray-600);
          @extend %overflowable-text;
        }
      }
    }
  }

  .keyboard-selector-footer {
    .keyboard-selector-footer-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}

.bluetooth {
  @extend %popup;

  .bluetooth-title {
    @extend %section-title;

    .bluetooth-refresh {
      @extend %actionable-button;
      .slu-icon {
        color: var(--color-gray-900);
        animation: rotateToTheLeft 1s linear infinite;
      }
    }
  }

  .bluetooth-entries {
    @extend %list;
    border-bottom: 1px solid var(--color-gray-300);
    padding-bottom: 10px;
    overflow-y: auto;
    max-height: 30vh;

    .bluetooth-entry {
      @extend %list;
      align-items: flex-end;
      padding: 12px 10px;
      border-radius: 8px;
      gap: 10px;

      &:hover {
        background-color: var(--color-gray-200);
      }

      &.bluetooth-entry-selected {
        background-color: rgba(var(--config-accent-color-rgb), 0.2);
      }

      .bluetooth-entry-info {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;

        .bluetooth-entry-info-label {
          @extend %overflowable-text;
          flex: 1;
        }
      }
    }

    .bluetooth-empty {
      @extend %flex-centered;
      height: 100px;
      font-style: italic;
    }
  }

  .bluetooth-footer {
    .bluetooth-footer-more-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}
