import { Component, Input, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';

type StackSpacing = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
type HorizontalAlignment = 'start' | 'center' | 'end' | 'stretch';
type VerticalJustify = 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';

@Component({
  selector: 'ui-vstack',
  standalone: true,
  imports: [CommonModule],
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
  template: `
    <div 
      [ngClass]="getClasses()"
      [attr.role]="role"
      [style.gap]="customGap">
      
      <ng-content></ng-content>
    </div>
  `,
  styleUrl: './vstack.component.scss'
})
export class VStackComponent {
  @Input() spacing: StackSpacing = 'md';
  @Input() align?: HorizontalAlignment;
  @Input() justify?: VerticalJustify;
  @Input() inline = false;
  @Input() responsive = true;
  @Input() divider = false;
  @Input() fullWidth = false;
  @Input() fullHeight = false;
  @Input() customGap?: string;
  @Input() role?: string;

  getClasses(): Record<string, boolean> {
    const classes: Record<string, boolean> = {
      'ui-vstack': true,
      [`ui-vstack--spacing-${this.spacing}`]: true,
      'ui-vstack--inline': this.inline,
      'ui-vstack--responsive': this.responsive,
      'ui-vstack--divider': this.divider,
      'ui-vstack--full-width': this.fullWidth,
      'ui-vstack--full-height': this.fullHeight
    };

    if (this.align) {
      classes[`ui-vstack--align-${this.align}`] = true;
    }

    if (this.justify) {
      classes[`ui-vstack--justify-${this.justify}`] = true;
    }

    return classes;
  }
}