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

#plugin {
  overflow: auto;
  max-width: 800px;
  padding: 20px;
  margin: 0 auto;

  .plugin-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: start;
    margin-bottom: 24px;

    .plugin-icon {
      width: 80px;
      height: 80px;
      border-radius: 16px;
      background-position: center;
      background-repeat: no-repeat;
      background-size: contain;
    }

    .plugin-info {
      .title-wrapper {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 16px;
        margin-bottom: 8px;

        .plugin-name {
          font-size: 24px;
          margin-bottom: 0;
        }

        .source-indicator {
          display: flex;
          align-items: center;
          gap: 6px;
          background: rgba(0, 0, 0, 0.3);
          backdrop-filter: blur(10px);
          border-radius: 20px;
          padding: 6px 10px;
          font-size: 11px;
          color: var(--primary-text-color);
          cursor: pointer;
          transition: all 0.3s ease;
          border: 1px solid rgba(255, 255, 255, 0.1);
          text-decoration: none;

          &:hover {
            background-color: rgba(0, 0, 0, 0.5);
            transform: translateY(-1px);
          }

          .icon {
            color: var(--primary-text-color);
            font-size: 14px;
          }
        }
      }

      .plugin-meta {
        display: flex;
        gap: 16px;
        flex-wrap: wrap;
        color: color-mix(in srgb, var(--primary-text-color) 60%, transparent);
        font-size: 14px;
        margin-bottom: 12px;

        .author-name {
          display: inline-flex;
          align-items: center;
          gap: 4px;

          a {
            text-decoration: none;
            color: inherit;
          }
        }

        .verified-tick {
          color: #3b82f6;
          font-size: 16px;
        }

        .version-updated {
          opacity: 0.6;
          font-size: 0.8em;
          margin-left: 4px;
        }
      }

      .metrics-row {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        color: color-mix(in srgb, var(--primary-text-color) 60%, transparent);
        font-size: 14px;

        .metric {
          display: flex;
          align-items: center;
          gap: 4px;

          .metric-value {
            color: var(--primary-text-color);
            font-weight: 500;
          }

          .rating-value {
            padding: 2px 8px;
            border-radius: 12px;
            font-weight: 600;
          }

          .rating-high {
            background: var(--link-text-color);
            color: #0a3600;
          }

          .rating-medium {
            background: #f0a500;
            color: #3d2800;
          }

          .rating-low {
            background: var(--error-text-color);
            color: #fff;
          }
        }
      }

      .keywords {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        margin-top: 16px;
        position: relative;

        .keyword {
          background: color-mix(in srgb,
              var(--link-text-color) 10%,
              transparent);
          color: var(--link-text-color);
          padding: 6px 10px;
          border-radius: 12px;
          font-size: 13px;
          transition: all 0.2s;
          border: 1px solid color-mix(in srgb, var(--link-text-color) 25%, transparent);
        }
      }
    }

    .action-buttons {
      display: flex;
      gap: 8px;

      .error {
        display: flex;
        color: rgb(255, 185, 92);
        color: var(--error-text-color);
        align-items: center;

        a {
          color: inherit;
          text-decoration: none;
        }
      }

      .btn {
        padding: 8px 16px;
        border-radius: 6px;
        border: none;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
        gap: 6px;

        &:hover {
          transform: translateY(-1px);
        }
      }

      .btn-install {
        background: var(--button-background-color);
        color: white;
      }

      .btn-update {
        background: var(--button-background-color);
        color: white;
      }

      .btn-uninstall {
        background-color: var(--danger-color) !important;
        color: white;
      }

      .btn-secondary {
        background: var(--primary-color);
        color: var(--primary-text-color);
        box-shadow: 0 0 10px var(--box-shadow-color);
      }
    }

    .more-info-small {
      text-align: center;
      font-style: italic;
      font-size: 0.8rem;
      opacity: 0.8;
    }
  }

  #plugin-tab {
    .options {
      display: flex;
      gap: 0;
      margin: 20px -20px;
      padding: 0 20px;
      border-bottom: 1px solid var(--border-color);

      .tab {
        color: color-mix(in srgb, var(--primary-text-color) 60%, transparent);
      }

      .tab.active {
        color: var(--primary-text-color);
      }
    }

    .tab-content {
      padding: 0 0 24px;

      #overview {
        [class*="language-"] {
          word-wrap: normal;
          white-space: pre;
          font-size: 0.8rem;
          border-radius: 4px;
          padding: 1em;
          margin: 5px 0;
          background: var(--primary-color);
          color: var(--primary-text-color);
          /* border-left: solid 5px var(--active-color); */
          overflow: auto;
          width: calc(100% - 10px);
          display: block;
          user-select: text;

          div {
            background: var(--primary-color);
          }
        }
      }
    }

    .content-section {
      display: none;
    }

    .content-section.active {
      display: block;
    }

    .contributor {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      text-decoration: none;

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

      img {
        width: 32px;
        height: 32px;
        border-radius: 50%;
      }

      .contributor-info {
        flex-grow: 1;

        .contributor-name {
          font-weight: 500;
          margin-bottom: 2px;
          color: var(--primary-text-color);
        }

        .contributor-role {
          font-size: 13px;
          color: color-mix(in srgb, var(--primary-text-color) 60%, transparent);
        }
      }
    }

    #changelog {
      .no-changelog {
        text-align: center;
        padding: 2rem;
        color: color-mix(in srgb, var(--primary-text-color) 60%, transparent);

        i {
          font-size: 3rem;
          margin-bottom: 1rem;
          opacity: 0.7;
          display: block;
        }

        p {
          margin: 0.5rem 0;
        }
      }
    }
  }

  @media (max-width: 768px) {
    .plugin-header {
      grid-template-columns: 1fr;
      justify-items: center;
      text-align: center;
    }

    .source-indicator {
      position: absolute;
      top: 20px;
      right: 20px;
    }

    .title-wrapper,
    .plugin-meta,
    .metrics-row,
    .keywords {
      justify-content: center;
    }

    .action-buttons {
      flex-direction: column;
      width: 100%;
    }

    .btn {
      width: 100%;
      justify-content: center;
    }

    .tabs {
      overflow-x: auto;
      margin: 24px -24px;
      padding: 0 24px;
    }
  }
}

.reviews-container {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 70vh;
  top: auto;
  bottom: 0;
  background-color: rgb(255, 255, 255);
  background-color: var(--secondary-color);
  z-index: 999;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 20px var(--box-shadow-color);
  border-radius: 40px 40px 0 0;
  overflow: hidden;
  animation: slide-up 0.3s ease-in-out;

  &.hide {
    transition: all 0.3s ease-in-out !important;
    transform: translateY(100%) !important;
  }

  .reviews-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;

    &::after {
      content: "";
      width: 40px;
      height: 5px;
      border-radius: 2.5px;
      background-color: rgba(0, 0, 0, 0.2);
    }
  }

  .write-review {
    padding: 0 10px;
    display: flex;
    align-content: center;
    justify-content: center;
    width: fit-content;
    margin: auto;

    span {
      height: fit-content;
      margin: auto;
    }

    .icon {
      height: 30px;
      margin-right: 10px;
    }
  }

  .reviews-body {
    flex: 1;
    overflow: auto;

    &.loading {
      @include mixins.loader(30px);
    }

    .review {
      padding: 10px;
      display: flex;
      flex-direction: column;
      border-bottom: solid 1px rgba(255, 255, 255, 0.1);

      .review-author {
        display: flex;
        height: 30px;
        align-items: center;
        justify-content: flex-start;
        margin-bottom: 5px;

        .vote {
          height: 40px;
          width: 40px;
          background-position: center;
          background-repeat: no-repeat;
          background-size: 20px;
        }

        .user-profile {
          height: 30px;
          width: 30px;
          border-radius: 50%;
          background-position: center;
          background-repeat: no-repeat;
          background-size: cover;
          margin-right: 10px;
          font-weight: 400;
        }
      }

      .review-body {
        display: flex;
        align-items: center;
        font-weight: 300;
        overflow: auto;
      }

      .author-reply {
        &::before {
          display: block;
          content: attr(data-author);
          font-weight: 400;
          margin-bottom: 10px;
        }

        padding: 10px;
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
  }
}