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

.demo-container {
  padding: $semantic-spacing-component-lg;
  max-width: 1200px;
  margin: 0 auto;
}

.demo-section {
  margin-bottom: $semantic-spacing-layout-section-md;
  
  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;
  }
}

.demo-showcase {
  border: $semantic-border-width-1 solid $semantic-color-border-primary;
  border-radius: $semantic-border-radius-md;
  background: $semantic-color-surface-secondary;
  padding: $semantic-spacing-component-md;
  height: 400px;
  position: relative;
}

.demo-scroll-container {
  width: 100%;
  height: 100%;
  border-radius: $semantic-border-radius-sm;
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
}

// Basic demo items
.demo-item {
  padding: $semantic-spacing-component-md;
  margin-bottom: $semantic-spacing-component-sm;
  background: $semantic-color-surface-elevated;
  border-radius: $semantic-border-radius-sm;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  
  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-content-line-normal 0;
  }
  
  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: 0 0 $semantic-spacing-component-xs 0;
  }
  
  small {
    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);
    color: $semantic-color-text-tertiary;
  }
}

// Template demo items
.demo-template-item {
  padding: $semantic-spacing-component-lg;
  background: $semantic-color-surface-elevated;
  border-radius: $semantic-border-radius-md;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
  
  &:hover {
    box-shadow: $semantic-shadow-elevation-2;
    transform: translateY(-2px);
  }
  
  &--last {
    border-color: $semantic-color-primary;
    box-shadow: $semantic-shadow-elevation-1;
  }
  
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: $semantic-spacing-component-sm;
  }
  
  &__id {
    font-family: map-get($semantic-typography-body-small, font-family);
    font-size: map-get($semantic-typography-body-small, font-size);
    font-weight: $semantic-typography-font-weight-semibold;
    line-height: map-get($semantic-typography-body-small, line-height);
    color: $semantic-color-primary;
  }
  
  &__category {
    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);
    background: $semantic-color-surface-container;
    color: $semantic-color-text-secondary;
    padding: $semantic-spacing-1 $semantic-spacing-2;
    border-radius: $semantic-border-radius-sm;
  }
  
  &__title {
    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-xs 0;
  }
  
  &__description {
    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: 0 0 $semantic-spacing-component-sm 0;
  }
  
  &__footer {
    border-top: $semantic-border-width-1 solid $semantic-color-border-subtle;
    padding-top: $semantic-spacing-component-xs;
    
    small {
      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);
      color: $semantic-color-text-tertiary;
    }
  }
}

// Bidirectional demo items
.demo-bidirectional-item {
  padding: $semantic-spacing-component-sm;
  
  &__content {
    background: $semantic-color-surface-elevated;
    padding: $semantic-spacing-component-md;
    border-radius: $semantic-border-radius-lg;
    border-left: 4px solid $semantic-color-primary;
    
    strong {
      font-family: map-get($semantic-typography-body-medium, font-family);
      font-size: map-get($semantic-typography-body-medium, font-size);
      font-weight: $semantic-typography-font-weight-semibold;
      line-height: map-get($semantic-typography-body-medium, line-height);
      color: $semantic-color-text-primary;
      display: block;
      margin-bottom: $semantic-spacing-content-line-tight;
    }
    
    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-content-line-tight 0;
    }
    
    small {
      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);
      color: $semantic-color-text-tertiary;
    }
  }
}

// Custom templates
.demo-custom-item {
  display: flex;
  gap: $semantic-spacing-component-md;
  padding: $semantic-spacing-component-md;
  background: $semantic-color-surface-elevated;
  border-radius: $semantic-border-radius-md;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  
  &__avatar {
    flex-shrink: 0;
    width: $semantic-sizing-touch-target;
    height: $semantic-sizing-touch-target;
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: $semantic-typography-font-weight-bold;
    line-height: map-get($semantic-typography-body-medium, line-height);
  }
  
  &__content {
    flex: 1;
    min-width: 0;
    
    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-content-line-tight 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-content-line-tight 0;
    }
  }
  
  &__time {
    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);
    color: $semantic-color-text-tertiary;
  }
}

.demo-custom-loading {
  display: flex;
  align-items: center;
  gap: $semantic-spacing-component-md;
  padding: $semantic-spacing-component-lg;
  background: linear-gradient(45deg, $semantic-color-primary, $semantic-color-secondary);
  color: $semantic-color-on-primary;
  border-radius: $semantic-border-radius-lg;
  
  &__spinner {
    width: $semantic-sizing-icon-button;
    height: $semantic-sizing-icon-button;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin $semantic-motion-duration-slow linear infinite;
  }
  
  span {
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: $semantic-typography-font-weight-medium;
    line-height: map-get($semantic-typography-body-medium, line-height);
  }
}

.demo-custom-error {
  text-align: center;
  padding: $semantic-spacing-component-xl;
  background: rgba($semantic-color-danger, 0.1);
  border: $semantic-border-width-1 solid $semantic-color-danger;
  border-radius: $semantic-border-radius-lg;
  
  &__icon {
    font-size: $semantic-typography-font-size-2xl;
    margin-bottom: $semantic-spacing-component-sm;
  }
  
  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-danger;
    margin: 0 0 $semantic-spacing-component-xs 0;
  }
  
  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: 0;
  }
}

.demo-custom-end {
  text-align: center;
  padding: $semantic-spacing-component-xl;
  background: linear-gradient(135deg, $semantic-color-success, $semantic-color-primary);
  color: $semantic-color-on-success;
  border-radius: $semantic-border-radius-lg;
  
  &__icon {
    font-size: $semantic-typography-font-size-3xl;
    margin-bottom: $semantic-spacing-component-sm;
  }
  
  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);
    margin: 0 0 $semantic-spacing-component-xs 0;
  }
  
  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);
    margin: 0;
    opacity: 0.9;
  }
}

// Configuration demo
.demo-config-item {
  display: flex;
  align-items: center;
  gap: $semantic-spacing-component-md;
  padding: $semantic-spacing-component-md;
  background: $semantic-color-surface-elevated;
  border-radius: $semantic-border-radius-sm;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  
  &__index {
    flex-shrink: 0;
    width: $semantic-sizing-touch-minimum;
    height: $semantic-sizing-touch-minimum;
    background: $semantic-color-surface-container;
    color: $semantic-color-text-secondary;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: map-get($semantic-typography-body-small, font-family);
    font-size: map-get($semantic-typography-body-small, font-size);
    font-weight: $semantic-typography-font-weight-semibold;
    line-height: map-get($semantic-typography-body-small, line-height);
  }
  
  &__content {
    flex: 1;
    
    h4 {
      font-family: map-get($semantic-typography-body-medium, font-family);
      font-size: map-get($semantic-typography-body-medium, font-size);
      font-weight: $semantic-typography-font-weight-semibold;
      line-height: map-get($semantic-typography-body-medium, line-height);
      color: $semantic-color-text-primary;
      margin: 0 0 $semantic-spacing-content-line-tight 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;
    }
  }
}

// Controls
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: $semantic-spacing-component-md;
  margin-bottom: $semantic-spacing-component-lg;
  padding: $semantic-spacing-component-md;
  background: $semantic-color-surface-secondary;
  border-radius: $semantic-border-radius-md;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  
  button {
    padding: $semantic-spacing-interactive-button-padding-y $semantic-spacing-interactive-button-padding-x;
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border: none;
    border-radius: $semantic-border-radius-sm;
    cursor: pointer;
    
    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);
    
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
    
    &:hover {
      box-shadow: $semantic-shadow-elevation-2;
      transform: translateY(-1px);
    }
    
    &:active {
      transform: translateY(0);
      box-shadow: $semantic-shadow-elevation-1;
    }
    
    &:focus-visible {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }
  }
}

.demo-control {
  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-primary;
    display: flex;
    flex-direction: column;
    gap: $semantic-spacing-component-xs;
  }
  
  input[type="checkbox"] {
    width: auto;
    margin-right: $semantic-spacing-component-xs;
  }
  
  input[type="range"] {
    width: 150px;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
  .demo-template-item {
    transition: none;
    
    &:hover {
      transform: none;
    }
  }
  
  .demo-custom-loading__spinner {
    animation: none;
  }
  
  button {
    transition: none;
    
    &:hover {
      transform: none;
    }
    
    &:active {
      transform: none;
    }
  }
}