@use "../../../styles/tokens/color" as *;

@layer components {
  // ===== PREVIEW GRID STYLES =====
  .preview-grid {
    .grid {
      position: relative;
      z-index: 0;
      padding: 0.5em 0;
      background-color: rgba(0, 0, 0, 0.08);
      border: 1px solid rgba(0, 0, 0, 0.15);
    }

    .grid__col,
    *[class*="grid__col\-\-"] {
      position: relative;
      min-height: 1em;
      line-height: 1.5;
      background-color: rgba(0, 0, 0, 0.1);
      background-clip: content-box;
    }
  }

  // ===== PREVIEW COMPONENT STYLES =====
  .previewWrapper {
    display: flex;
    flex-flow: column;
    margin-bottom: 2rem;

    &.isFullscreen {
      background-color: white;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100vh;
      z-index: 9999;
    }

    // ===== PREVIEW TITLE BAR STYLES =====
    > .bar {
      margin-top: 1rem !important;
      margin-bottom: 0.5rem;
      gap: 0.5rem;
      justify-content: flex-end;
      align-items: center;
      .btn {
        margin: 0 !important;
      }
    }
  }
  .preview {
    padding: 24px;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    overflow: visible !important;
  }

  // Card defaults to overflow hidden; ensure preview content can escape.
  .card.preview {
    overflow: visible !important;
  }

  .previewLive {
    transition: all 200ms ease-in-out;
    overflow: visible;
  }

  .previewLiveViewportArea {
    overflow: visible;
    width: 100%;

    &.hasFixedViewport {
      overflow-x: auto;
      overflow-y: visible;
      padding: 1rem 0;
      background: color-mix(
        in srgb,
        var(--color-text-default),
        transparent 96%
      );

      .previewLiveViewport {
        background: var(--color-background-primary);
        border: 1px solid
          color-mix(in srgb, var(--color-border-strong), transparent 25%);
        box-shadow:
          0 0 0 1px
            color-mix(in srgb, var(--color-border-strong), transparent 60%),
          0 12px 28px
            color-mix(in srgb, var(--color-text-default), transparent 88%);
      }
    }
  }

  .previewLiveViewport {
    margin: 0 auto;
    overflow: visible;

    &.isAuto {
      width: 100%;
    }
  }

  .previewViewportFrame {
    width: 100%;
    border: 0;
    display: block;
    background: transparent;
    padding-top: 16px;
  }

  .selectWrapper {
    position: relative;
    font-family: inherit;
    font-size: 14px;

    .select {
      .select__control {
        cursor: pointer;
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        min-width: 130px;
      }

      .select__value-container {
        display: inline-flex;
        justify-content: flex-end;
      }

      .select__single-value,
      .select__option {
        text-transform: uppercase;
        font-weight: bold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .select__menu {
        border-radius: 0 !important;
        text-align: center;
      }
    }
  }

  .codeExample {
    margin-bottom: 0;
    border-radius: 0 !important;
    padding: 24px;

    .isFullscreen & {
      flex: 1 1 auto;
      margin-bottom: 0;
      padding: 0;
    }
  }

  // ===== CODE EXAMPLE STYLES =====
  .wrapper {
    position: relative;
  }

  .codeTypeToggle {
    margin-bottom: 0 !important;
    border-radius: 0 !important;
    border-bottom: none !important;
    background-color: var(--color-background-primary);

    &.isActive {
      background-color: var(--color-background-contrast);
      color: var(--color-text-inverse);
    }
  }

  .triangle {
    font-size: 18px;
    display: inline-block;
    transition: transform 0.3s;

    &.up {
      transform: rotate(180deg);
    }

    &.down {
      transform: none;
    }
  }
}
