@use 'ui-design-system/src/styles/semantic/index' as *;

.demo-container {
  padding: $semantic-spacing-layout-section-md;
  max-width: 1400px;
  margin: 0 auto;

  h2 {
    font-family: map-get($semantic-typography-heading-h2, font-family);
    font-size: map-get($semantic-typography-heading-h2, font-size);
    font-weight: map-get($semantic-typography-heading-h2, font-weight);
    line-height: map-get($semantic-typography-heading-h2, line-height);
    color: $semantic-color-text-primary;
    margin-bottom: $semantic-spacing-content-heading;
  }

  h3 {
    font-family: map-get($semantic-typography-heading-h3, font-family);
    font-size: map-get($semantic-typography-heading-h3, font-size);
    font-weight: map-get($semantic-typography-heading-h3, font-weight);
    line-height: map-get($semantic-typography-heading-h3, line-height);
    color: $semantic-color-text-primary;
    margin-bottom: $semantic-spacing-component-md;
  }

  p {
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-secondary;
    margin-bottom: $semantic-spacing-content-paragraph;
  }
}

.demo-section {
  margin-bottom: $semantic-spacing-layout-section-lg;

  &:last-child {
    margin-bottom: 0;
  }
}

.demo-variant-container {
  display: flex;
  flex-direction: column;
  gap: $semantic-spacing-component-lg;

  @media (min-width: $semantic-breakpoint-lg) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  }
}

.demo-variant {
  h4 {
    font-family: map-get($semantic-typography-heading-h4, font-family);
    font-size: map-get($semantic-typography-heading-h4, font-size);
    font-weight: map-get($semantic-typography-heading-h4, font-weight);
    line-height: map-get($semantic-typography-heading-h4, line-height);
    color: $semantic-color-text-primary;
    margin-bottom: $semantic-spacing-component-sm;
  }
}

.demo-layout-container {
  height: 400px;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-lg;
  overflow: hidden;

  &.demo-layout--sm {
    height: 350px;
  }

  &.demo-layout--lg {
    height: 450px;
  }

  &.demo-layout--variant {
    height: 300px;
  }

  &.demo-layout--interactive {
    height: 500px;
  }
}

// Demo List Styles
.demo-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: $semantic-color-surface-secondary;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: $semantic-spacing-component-md;
    background: $semantic-color-surface-elevated;
    border-bottom: $semantic-border-width-1 solid $semantic-color-border-primary;

    h4 {
      font-family: map-get($semantic-typography-heading-h4, font-family);
      font-size: map-get($semantic-typography-heading-h4, font-size);
      font-weight: map-get($semantic-typography-heading-h4, font-weight);
      line-height: map-get($semantic-typography-heading-h4, line-height);
      color: $semantic-color-text-primary;
      margin: 0;
    }
  }

  &__content {
    flex: 1;
    overflow-y: auto;
  }
}

.demo-list-item {
  padding: $semantic-spacing-component-md;
  border-bottom: $semantic-border-width-1 solid $semantic-color-border-subtle;
  cursor: pointer;
  transition: background $semantic-motion-duration-fast $semantic-motion-easing-ease;

  &:hover {
    background: $semantic-color-surface-container;
  }

  &--selected {
    background: $semantic-color-surface-elevated;
    border-left: 3px solid $semantic-color-primary;
  }

  &__content {
    h5 {
      font-family: map-get($semantic-typography-heading-h5, font-family);
      font-size: map-get($semantic-typography-heading-h5, font-size);
      font-weight: map-get($semantic-typography-heading-h5, font-weight);
      line-height: map-get($semantic-typography-heading-h5, line-height);
      color: $semantic-color-text-primary;
      margin: 0 0 $semantic-spacing-component-xs 0;
    }

    p {
      font-family: map-get($semantic-typography-body-small, font-family);
      font-size: map-get($semantic-typography-body-small, font-size);
      font-weight: map-get($semantic-typography-body-small, font-weight);
      line-height: map-get($semantic-typography-body-small, line-height);
      color: $semantic-color-text-secondary;
      margin: 0 0 $semantic-spacing-component-xs 0;
    }
  }

  &__status {
    display: inline-block;
    padding: 2px $semantic-spacing-component-xs;
    border-radius: $semantic-border-radius-sm;
    font-family: map-get($semantic-typography-caption, font-family);
    font-size: map-get($semantic-typography-caption, font-size);
    font-weight: map-get($semantic-typography-caption, font-weight);
    line-height: map-get($semantic-typography-caption, line-height);
    text-transform: uppercase;

    &--active {
      background: $semantic-color-success;
      color: $semantic-color-on-success;
    }

    &--pending {
      background: $semantic-color-warning;
      color: $semantic-color-on-warning;
    }

    &--completed {
      background: $semantic-color-info;
      color: $semantic-color-on-info;
    }
  }
}

// Demo Detail Styles
.demo-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: $semantic-color-surface-primary;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: $semantic-spacing-component-lg;
    background: $semantic-color-surface-elevated;
    border-bottom: $semantic-border-width-1 solid $semantic-color-border-primary;

    h3 {
      font-family: map-get($semantic-typography-heading-h3, font-family);
      font-size: map-get($semantic-typography-heading-h3, font-size);
      font-weight: map-get($semantic-typography-heading-h3, font-weight);
      line-height: map-get($semantic-typography-heading-h3, line-height);
      color: $semantic-color-text-primary;
      margin: 0;
    }
  }

  &__category {
    padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border-radius: $semantic-border-radius-sm;
    font-family: map-get($semantic-typography-caption, font-family);
    font-size: map-get($semantic-typography-caption, font-size);
    font-weight: map-get($semantic-typography-caption, font-weight);
    line-height: map-get($semantic-typography-caption, line-height);
  }

  &__content {
    flex: 1;
    padding: $semantic-spacing-component-lg;
    overflow-y: auto;

    p {
      margin-bottom: $semantic-spacing-content-paragraph;
    }

    h4 {
      font-family: map-get($semantic-typography-heading-h4, font-family);
      font-size: map-get($semantic-typography-heading-h4, font-size);
      font-weight: map-get($semantic-typography-heading-h4, font-weight);
      line-height: map-get($semantic-typography-heading-h4, line-height);
      color: $semantic-color-text-primary;
      margin: $semantic-spacing-component-lg 0 $semantic-spacing-component-sm 0;
    }
  }

  &__meta {
    margin-bottom: $semantic-spacing-component-lg;
    padding: $semantic-spacing-component-md;
    background: $semantic-color-surface-secondary;
    border-radius: $semantic-border-radius-md;

    p {
      margin: $semantic-spacing-component-xs 0;
      
      strong {
        font-weight: $semantic-typography-font-weight-semibold;
        color: $semantic-color-text-primary;
      }
    }
  }

  &__description {
    margin-bottom: $semantic-spacing-component-lg;
  }

  &__actions {
    display: flex;
    gap: $semantic-spacing-component-sm;
    flex-wrap: wrap;
  }

  &__stats {
    display: flex;
    gap: $semantic-spacing-component-lg;
    flex-wrap: wrap;
    margin-top: $semantic-spacing-component-md;
  }
}

.demo-stat {
  display: flex;
  flex-direction: column;
  gap: $semantic-spacing-component-xs;

  label {
    font-family: map-get($semantic-typography-label, font-family);
    font-size: map-get($semantic-typography-label, font-size);
    font-weight: map-get($semantic-typography-label, font-weight);
    line-height: map-get($semantic-typography-label, line-height);
    color: $semantic-color-text-secondary;
    text-transform: uppercase;
  }

  span {
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-primary;
  }
}

// Empty State
.demo-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: $semantic-spacing-component-lg;
  text-align: center;

  &__icon {
    font-size: 3rem;
    margin-bottom: $semantic-spacing-component-md;
  }

  h4 {
    font-family: map-get($semantic-typography-heading-h4, font-family);
    font-size: map-get($semantic-typography-heading-h4, font-size);
    font-weight: map-get($semantic-typography-heading-h4, font-weight);
    line-height: map-get($semantic-typography-heading-h4, line-height);
    color: $semantic-color-text-primary;
    margin: 0 0 $semantic-spacing-component-sm 0;
  }

  p {
    color: $semantic-color-text-secondary;
    margin: 0;
  }
}

// Interactive Controls
.demo-interactive {
  display: flex;
  flex-direction: column;
  gap: $semantic-spacing-component-lg;
}

.demo-controls {
  display: flex;
  gap: $semantic-spacing-component-lg;
  flex-wrap: wrap;
  padding: $semantic-spacing-component-md;
  background: $semantic-color-surface-secondary;
  border-radius: $semantic-border-radius-md;

  label {
    display: flex;
    align-items: center;
    gap: $semantic-spacing-component-xs;
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-primary;
    cursor: pointer;

    input[type="checkbox"] {
      width: 18px;
      height: 18px;
    }
  }
}

// Buttons
.demo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: $semantic-spacing-component-xs;
  padding: $semantic-spacing-interactive-button-padding-y $semantic-spacing-interactive-button-padding-x;
  border: $semantic-border-width-1 solid transparent;
  border-radius: $semantic-border-button-radius;
  cursor: pointer;
  transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
  
  font-family: map-get($semantic-typography-button-medium, font-family);
  font-size: map-get($semantic-typography-button-medium, font-size);
  font-weight: map-get($semantic-typography-button-medium, font-weight);
  line-height: map-get($semantic-typography-button-medium, line-height);

  &--primary {
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border-color: $semantic-color-primary;

    &:hover {
      box-shadow: $semantic-shadow-button-hover;
    }
  }

  &--secondary {
    background: $semantic-color-surface-primary;
    color: $semantic-color-text-primary;
    border-color: $semantic-color-border-primary;

    &:hover {
      background: $semantic-color-surface-elevated;
    }
  }

  &--small {
    padding: calc($semantic-spacing-interactive-button-padding-y / 2) $semantic-spacing-interactive-button-padding-x;
    font-family: map-get($semantic-typography-button-small, font-family);
    font-size: map-get($semantic-typography-button-small, font-size);
    font-weight: map-get($semantic-typography-button-small, font-weight);
    line-height: map-get($semantic-typography-button-small, line-height);
  }

  &:focus-visible {
    outline: 2px solid $semantic-color-focus;
    outline-offset: 2px;
  }
}

// Event Log
.demo-event-log {
  max-height: 300px;
  overflow-y: auto;
  background: $semantic-color-surface-secondary;
  border-radius: $semantic-border-radius-md;
  padding: $semantic-spacing-component-md;

  &__item {
    display: flex;
    gap: $semantic-spacing-component-sm;
    padding: $semantic-spacing-component-xs 0;
    border-bottom: $semantic-border-width-1 solid $semantic-color-border-subtle;
    font-family: map-get($semantic-typography-body-small, font-family);
    font-size: map-get($semantic-typography-body-small, font-size);
    font-weight: map-get($semantic-typography-body-small, font-weight);
    line-height: map-get($semantic-typography-body-small, line-height);

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

  &__timestamp {
    color: $semantic-color-text-tertiary;
    font-family: $semantic-typography-font-family-mono;
    min-width: 80px;
  }

  &__type {
    color: $semantic-color-primary;
    font-weight: $semantic-typography-font-weight-semibold;
    min-width: 100px;
  }

  &__data {
    color: $semantic-color-text-secondary;
    flex: 1;
  }
}

// Responsive adjustments
@media (max-width: calc($semantic-breakpoint-md - 1px)) {
  .demo-variant-container {
    display: flex;
    flex-direction: column;
  }

  .demo-layout-container {
    height: 300px;

    &.demo-layout--interactive {
      height: 400px;
    }
  }

  .demo-controls {
    flex-direction: column;
    gap: $semantic-spacing-component-sm;
  }
}