// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC Sucursal en España SL

@use "ds/typography.scss" as t;
@use "ds/z-index.scss" as *;
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@use "ds/_utils.scss" as *;

.dashboard-templates-section {
  background-color: var(--color-background-tertiary);
  inset-block-end: 0;
  border-end-start-radius: $br-8;
  border-end-end-radius: $br-8;
  border-start-end-radius: $br-8;
  display: flex;
  flex-direction: column;
  height: px2rem(244);
  justify-content: flex-end;
  margin-inline: var(--sp-s);
  margin-block-end: var(--sp-xs);
  position: absolute;
  transition: inset-block-end 300ms;
  width: calc(100% - $sz-12);
  pointer-events: none;
  z-index: var(--z-index-panels);

  &.collapsed {
    inset-block-end: calc(-1 * px2rem(228));
    background-color: transparent;
    transition: inset-block-end 300ms;

    .title-btn {
      border-end-end-radius: $br-8;
      border-end-start-radius: $br-8;
    }

    .content,
    .content-description {
      visibility: hidden;
    }
  }
}

.title {
  pointer-events: all;
  width: px2rem(420);
  inset-block-start: calc(-1 * $sz-40);
  text-align: right;
  height: px2rem(56);
  position: absolute;
}

.title-btn {
  border: none;
  cursor: pointer;
  height: px2rem(56);
  display: inline-flex;
  align-items: center;
  border-start-start-radius: $br-8;
  border-start-end-radius: $br-8;
  position: relative;
  z-index: var(--z-index-auto);
  background-color: var(--color-background-tertiary);
  width: 100%;
}

.title-text {
  @include t.use-typography("body-large");

  display: inline-block;
  vertical-align: middle;
  margin-inline: var(--sp-m) var(--sp-s);
  color: var(--color-foreground-primary);
}

.title-icon-container {
  display: inline-block;
  vertical-align: middle;
  margin-inline: auto var(--sp-s);
  color: var(--color-foreground-primary);
}

.title-icon {
  display: inline-block;
  vertical-align: middle;
  margin-inline: auto var(--sp-s);
  transform: rotate(90deg);
}

.title-icon-text {
  margin-inline-end: var(--sp-s);
}

.title-icon-collapsed {
  transform: rotate(-90deg);
}

.arrow-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  height: $sz-16;
  width: $sz-16;
  color: transparent;
  fill: none;
  stroke-width: $b-1;
  stroke: var(--color-foreground-secondary);
}

.move-button {
  position: absolute;
  inset-block-start: px2rem(96);
  border: $b-2 solid var(--color-foreground-secondary);
  border-radius: 50%;
  text-align: center;
  width: $sz-36;
  height: $sz-36;
  cursor: pointer;
  background-color: var(--color-background-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;

  &:hover {
    border: $b-2 solid var(--color-background-tertiary);
    background-color: var(--color-accent-primary);

    .arrow-icon {
      stroke: var(--color-background-tertiary);
    }
  }
}

.move-left {
  inset-inline-start: 0;
  margin-inline-start: px2rem(44);
  transform: rotate(180deg);
}

.move-right {
  inset-inline-end: 0;
  margin-inline-end: px2rem(44);
}

.content-description {
  @include t.use-typography("body-medium");

  color: var(--color-foreground-primary);
  margin-block: var(--sp-l) calc(-1 * var(--sp-s));
  margin-inline-start: var(--sp-l);
  visibility: visible;
}

.content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(px2rem(276), px2rem(276)));
  grid-auto-flow: column;
  pointer-events: all;
  height: px2rem(228);
  overflow: scroll hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scroll-snap-stop: always;
  visibility: visible;
}

.card-container {
  width: px2rem(276);
  margin-block-start: var(--sp-xl);
  text-align: center;
  vertical-align: top;
  background-color: transparent;
  border: none;
  padding: 0;
  scroll-snap-align: start;
}

.template-card {
  @include t.use-typography("body-large");

  display: inline-block;
  width: px2rem(256);
  cursor: pointer;
  color: var(--color-foreground-primary);
  padding: 0 var(--sp-xs) var(--sp-s) var(--sp-xs);
  border-radius: $br-8;
  border: $b-2 solid transparent;

  &:hover {
    text-decoration: none;
    border-color: var(--color-accent-primary);

    .download-icon {
      stroke: var(--color-accent-primary);
    }

    .card-text {
      color: var(--color-accent-primary);
    }
  }
}

.img-container {
  width: 100%;
  height: px2rem(136);
  margin-block-end: var(--sp-s);
  border-radius: $br-6;
  display: flex;
  justify-content: center;
  flex-direction: column;

  img {
    border-radius: $br-4;
  }
}

.card-name {
  padding: 0 var(--sp-s);
  display: flex;
  justify-content: space-between;
  height: $sz-24;
  align-items: center;
}

.card-text {
  @include t.use-typography("body-large");

  white-space: nowrap;
  overflow: hidden;
  width: 90%;
  text-overflow: ellipsis;
  text-align: left;
}

.download-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  height: $sz-16;
  width: $sz-16;
  color: transparent;
  fill: none;
  stroke-width: $b-1;
  stroke: var(--icon-foreground);
}

.template-link {
  border: $b-2 solid transparent;
  margin: var(--sp-xxxl);
  padding: var(--sp-xxxl) 0;
}

.template-link-title {
  @include t.use-typography("body-medium");

  color: var(--color-foreground-primary);
}

.template-link-text {
  @include t.use-typography("body-small");

  margin-block-start: var(--sp-s);
  color: var(--color-foreground-secondary);
}
