/**
 * InApp Preview Pane Styles
 */

@import '~@capillarytech/cap-ui-library/styles/_variables.scss';

// ContentOverlay Variables
$content-overlay-bg: $CAP_WHITE;
$content-overlay-border-radius: 0.5rem;
$content-overlay-border-color: $CAP_G07;
$content-overlay-shadow: 0 0.125rem 0.75rem rgba($CAP_G01, 0.15);
$content-overlay-z-index: 10;

// Empty State Variables
$empty-state-color: $CAP_G10;
$empty-state-font-size: 0.75rem;
$empty-state-padding: 1.25rem;
$empty-state-icon-size: 1.5rem;
$empty-state-icon-margin: 0.5rem;
$empty-state-meta-font-size: 0.625rem;
$empty-state-meta-margin: 0.25rem;
$empty-state-meta-opacity: 0.7;

.inapp-preview-pane {
  height: 100%;
  position: relative;
  background-color: $CAP_G07;
  background-image: radial-gradient(circle at 50% 50%, rgba($CAP_WHITE, 0.1) 0%, transparent 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;

  &--adaptive-focus {
    scroll-padding-top: 1.25rem;
    scroll-padding-bottom: 1.25rem;
  }

  &--modal-context {
    padding: 3.125rem 0.25rem 0.5rem 0.25rem;
    justify-content: center;
  }

  &--fullscreen {
    padding: 0.25rem;
  }

  .html-editor-fullscreen &,
  .html-editor-fullscreen .inapp-preview-pane,
  .ant-modal .inapp-preview-pane {
    padding: 3.125rem 0.25rem 0.5rem 0.25rem;
    justify-content: center;
    min-height: 37.5rem;
    overflow: auto;

    &::-webkit-scrollbar {
      width: 0.5rem;
    }

    .inapp-preview-pane__device-container,
    .inapp-preview-pane__device-container.inapp-preview-pane__device-container {
      margin: 1.25rem auto 0.3125rem auto;
      min-height: 25rem;
    }

    .device-frame {
      margin: 0.9375rem 0 0.125rem 0;
    }
  }

  &::-webkit-scrollbar {
    width: 0.375rem;
  }

  &::-webkit-scrollbar-track {
    background: rgba($CAP_G01, 0.05);
    border-radius: 0.1875rem;
  }

  &::-webkit-scrollbar-thumb {
    background: rgba($CAP_G01, 0.2);
    border-radius: 0.1875rem;

    &:hover {
      background: rgba($CAP_G01, 0.3);
    }
  }

  &__device-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0.3125rem auto;
    max-width: 100%;
    min-width: min-content;
    width: auto;
    transition: transform 0.3s ease-in-out;
    transform-origin: center center;

    &--modal-context {
      transform: scale(0.65);
      margin: 1.25rem auto 0.3125rem auto;
    }

    &--fullscreen {
      transform: scale(1.1);
      margin: 0.3125rem auto;
    }

    &--normal {
      transform: scale(0.95);
      margin: 0.3125rem auto;
    }
  }

}

.device-frame {
  position: relative;
  display: inline-block;
  transition: all 0.3s ease-in-out;

  &:hover {
    transform: translateY(-0.125rem);
  }

  &__content-area {
    position: absolute;
    overflow: hidden;
    background-color: rgba($CAP_G01, 0.08);
    border: 0.125rem solid rgba($CAP_G01, 0.15);
    box-shadow: inset 0 0.125rem 0.5rem rgba($CAP_G01, 0.1);
  }
}

.content-overlay {
  position: absolute;
  background-color: $content-overlay-bg;
  border-radius: $content-overlay-border-radius;
  box-shadow: $content-overlay-shadow;
  border: 0.0625rem solid $content-overlay-border-color;
  overflow: hidden;
  z-index: $content-overlay-z-index;

  &__screen-area {
    position: absolute;
  }

  &--popup {
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 1.25rem rgba($CAP_G01, 0.2);
  }

  &--header {
    border-radius: 0.5rem 0.5rem 0.75rem 0.75rem;
    box-shadow: 0 0.125rem 0.5rem rgba($CAP_G01, 0.15);
  }

  &--footer {
    border-radius: 0.75rem 0.75rem 0.5rem 0.5rem;
    box-shadow: 0 -0.125rem 0.5rem rgba($CAP_G01, 0.15);
  }

  &--fullscreen {
    border-radius: 0.25rem;
    box-shadow: none;
    border: none;
  }

  &__empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: $empty-state-padding;
    text-align: center;
    color: $empty-state-color;
    font-size: $empty-state-font-size;

    &__icon {
      font-size: $empty-state-icon-size;
      margin-bottom: $empty-state-icon-margin;
    }

    &__meta {
      font-size: $empty-state-meta-font-size;
      margin-top: $empty-state-meta-margin;
      opacity: $empty-state-meta-opacity;
    }
  }

  iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: $content-overlay-bg;
    display: block;
  }
}

@media (max-width: 768px) {
  .inapp-preview-pane {
    padding: 0.125rem;

    &__device-container,
    &__device-container.inapp-preview-pane__device-container {
      transform: scale(0.8);
      margin: 0.25rem auto;
    }

    &__controls {
      top: 0.5rem;

      .layout-selector__radio-group {
        .ant-radio-button-wrapper {
          font-size: 0.625rem;
          padding: 0.1875rem 0.375rem;
        }
      }
    }
  }
}

@media (max-width: 576px) {
  .inapp-preview-pane {
    padding: 0.125rem;

    &__device-container,
    &__device-container.inapp-preview-pane__device-container {
      transform: scale(0.7);
      margin: 0.1875rem auto;
    }
  }
}

@media (max-width: 480px) {
  .inapp-preview-pane {
    padding: 0.0625rem;

    &__device-container,
    &__device-container.inapp-preview-pane__device-container {
      transform: scale(0.6);
      margin: 0.125rem auto;
    }
  }
}