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

.demo-container {
  padding: $semantic-spacing-layout-section-md;
  max-width: 1200px;
  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-layout-section-lg;
    text-align: center;
  }
}

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

.demo-row {
  display: flex;
  gap: $semantic-spacing-layout-section-md;
  align-items: flex-start;
  flex-wrap: wrap;
  
  > * {
    flex: 1;
    min-width: 300px;
  }
  
  @media (max-width: calc(#{$semantic-breakpoint-md} - 1px)) {
    flex-direction: column;
    gap: $semantic-spacing-layout-section-sm;
    
    > * {
      min-width: unset;
    }
  }
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: $semantic-spacing-layout-section-md;
  
  @media (max-width: calc(#{$semantic-breakpoint-sm} - 1px)) {
    grid-template-columns: 1fr;
    gap: $semantic-spacing-layout-section-sm;
  }
}

.demo-item {
  padding: $semantic-spacing-component-lg;
  background: $semantic-color-surface-secondary;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-md;
  box-shadow: $semantic-shadow-elevation-1;
}

.demo-info {
  padding: $semantic-spacing-component-lg;
  background: $semantic-color-surface-elevated;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-md;
  box-shadow: $semantic-shadow-elevation-1;
  
  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-primary;
    margin-bottom: $semantic-spacing-component-sm;
  }
  
  strong {
    font-weight: $semantic-typography-font-weight-semibold;
    color: $semantic-color-text-primary;
  }
}

.color-preview {
  width: 100px;
  height: 60px;
  border: $semantic-border-width-2 solid $semantic-color-border-primary;
  border-radius: $semantic-border-radius-sm;
  box-shadow: $semantic-shadow-elevation-1;
  margin-top: $semantic-spacing-component-sm;
}

.demo-form {
  .demo-form-info {
    margin-top: $semantic-spacing-component-lg;
    padding: $semantic-spacing-component-md;
    background: $semantic-color-surface-container;
    border: $semantic-border-width-1 solid $semantic-color-border-subtle;
    border-radius: $semantic-border-radius-sm;
    
    pre {
      font-family: $semantic-typography-font-family-mono;
      font-size: $semantic-typography-font-size-sm;
      color: $semantic-color-text-secondary;
      background: $semantic-color-surface-primary;
      padding: $semantic-spacing-component-sm;
      border-radius: $semantic-border-radius-sm;
      border: $semantic-border-width-1 solid $semantic-color-border-subtle;
      overflow-x: auto;
      white-space: pre-wrap;
      margin: 0;
    }
  }
  
  .demo-theme-preview {
    margin-top: $semantic-spacing-component-lg;
    
    .theme-sample {
      padding: $semantic-spacing-component-lg;
      border-radius: $semantic-border-radius-md;
      border: $semantic-border-width-1 solid $semantic-color-border-subtle;
      text-align: center;
      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);
      box-shadow: $semantic-shadow-elevation-1;
    }
  }
}

.event-log {
  max-height: 300px;
  overflow-y: auto;
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-sm;
  padding: $semantic-spacing-component-sm;
  margin-bottom: $semantic-spacing-component-md;
  
  .event-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    border-radius: $semantic-border-radius-sm;
    margin-bottom: $semantic-spacing-component-xs;
    font-family: $semantic-typography-font-family-mono;
    font-size: $semantic-typography-font-size-sm;
    transition: background-color $semantic-motion-duration-fast $semantic-motion-easing-ease;
    
    &--recent {
      background-color: $semantic-color-surface-elevated;
      border: $semantic-border-width-1 solid $semantic-color-border-focus;
    }
    
    .event-type {
      font-weight: $semantic-typography-font-weight-semibold;
      color: $semantic-color-primary;
      min-width: 80px;
    }
    
    .event-value {
      flex: 1;
      color: $semantic-color-text-primary;
      margin: 0 $semantic-spacing-component-sm;
      text-align: center;
    }
    
    .event-time {
      color: $semantic-color-text-tertiary;
      font-size: $semantic-typography-font-size-xs;
      min-width: 80px;
      text-align: right;
    }
  }
}

.clear-log-btn {
  padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
  background: $semantic-color-danger;
  color: $semantic-color-on-danger;
  border: none;
  border-radius: $semantic-border-button-radius;
  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);
  cursor: pointer;
  transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
  
  &:hover {
    box-shadow: $semantic-shadow-button-hover;
    transform: translateY(-1px);
  }
  
  &:active {
    transform: translateY(0);
    box-shadow: $semantic-shadow-button-rest;
  }
}

.preset-colors {
  padding: $semantic-spacing-component-lg;
  background: $semantic-color-surface-elevated;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-radius-md;
  box-shadow: $semantic-shadow-elevation-1;
  
  .preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: $semantic-spacing-component-sm;
    max-width: 400px;
    margin-top: $semantic-spacing-component-md;
  }
  
  .preset-color-btn {
    width: 40px;
    height: 40px;
    border: $semantic-border-width-2 solid $semantic-color-border-primary;
    border-radius: $semantic-border-radius-sm;
    cursor: pointer;
    transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
    box-shadow: $semantic-shadow-elevation-1;
    
    &:hover {
      transform: scale(1.1);
      box-shadow: $semantic-shadow-elevation-3;
      border-color: $semantic-color-border-focus;
    }
    
    &:focus {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }
    
    &:active {
      transform: scale(1.05);
      box-shadow: $semantic-shadow-elevation-2;
    }
    
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }
  }
}

// Responsive adjustments
@media (max-width: calc(#{$semantic-breakpoint-md} - 1px)) {
  .demo-container {
    padding: $semantic-spacing-layout-section-sm;
  }
  
  .demo-item {
    padding: $semantic-spacing-component-md;
  }
  
  .demo-info {
    padding: $semantic-spacing-component-md;
  }
  
  .preset-colors {
    padding: $semantic-spacing-component-md;
  }
}

@media (max-width: calc(#{$semantic-breakpoint-sm} - 1px)) {
  .demo-container {
    padding: $semantic-spacing-layout-section-xs;
  }
  
  .demo-item {
    padding: $semantic-spacing-component-sm;
  }
  
  .demo-info {
    padding: $semantic-spacing-component-sm;
  }
  
  .preset-colors {
    padding: $semantic-spacing-component-sm;
    
    .preset-grid {
      grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
      gap: $semantic-spacing-component-xs;
    }
    
    .preset-color-btn {
      width: 35px;
      height: 35px;
    }
  }
  
  .event-log {
    .event-entry {
      flex-direction: column;
      align-items: flex-start;
      gap: $semantic-spacing-component-xs;
      
      .event-type,
      .event-value,
      .event-time {
        min-width: unset;
        margin: 0;
        text-align: left;
      }
    }
  }
}