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

.ui-floating-toolbar {
  // Core Structure
  position: absolute;
  display: flex;
  align-items: center;
  gap: $semantic-spacing-component-xs;
  opacity: 0;
  transform: translateY(-8px);
  transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
  z-index: $semantic-z-index-overlay;
  pointer-events: none;
  will-change: opacity, transform;
  
  // Visual Design
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-primary;
  border-radius: $semantic-border-radius-lg;
  box-shadow: $semantic-shadow-elevation-3;
  
  // Typography
  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;
  
  // Size Variants
  &--sm {
    padding: $semantic-spacing-component-xs;
    gap: $semantic-spacing-component-xs;
    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);
  }
  
  &--md {
    padding: $semantic-spacing-component-sm;
    gap: $semantic-spacing-component-sm;
  }
  
  &--lg {
    padding: $semantic-spacing-component-md;
    gap: $semantic-spacing-component-md;
    font-family: map-get($semantic-typography-body-large, font-family);
    font-size: map-get($semantic-typography-body-large, font-size);
    font-weight: map-get($semantic-typography-body-large, font-weight);
    line-height: map-get($semantic-typography-body-large, line-height);
  }
  
  // Variant Styles
  &--default {
    background: $semantic-color-surface-primary;
    border-color: $semantic-color-border-primary;
    box-shadow: $semantic-shadow-elevation-2;
  }
  
  &--elevated {
    background: $semantic-color-surface-elevated;
    border: none;
    box-shadow: $semantic-shadow-elevation-4;
  }
  
  &--floating {
    background: $semantic-color-surface-secondary;
    border-color: $semantic-color-border-subtle;
    backdrop-filter: blur(8px);
    box-shadow: $semantic-shadow-elevation-3;
  }
  
  &--compact {
    padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    gap: $semantic-spacing-component-xs;
    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);
  }
  
  // Context Variants
  &--contextual {
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border: none;
  }
  
  // State Variants
  &--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  
  &--entering {
    opacity: 0;
    transform: translateY(-8px);
  }
  
  &--leaving {
    opacity: 0;
    transform: translateY(-8px);
    transition-duration: $semantic-motion-duration-fast;
  }
  
  &--disabled {
    opacity: $semantic-opacity-disabled;
    pointer-events: none;
  }
  
  // Content Areas
  &__actions {
    display: flex;
    align-items: center;
    gap: $semantic-spacing-component-xs;
  }
  
  &__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: $semantic-spacing-component-xs;
    padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    background: transparent;
    border: none;
    border-radius: $semantic-border-button-radius;
    color: $semantic-color-text-primary;
    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;
    min-height: $semantic-sizing-button-height-sm;
    white-space: nowrap;
    user-select: none;
    
    &:hover:not(:disabled) {
      background: $semantic-color-surface-elevated;
      color: $semantic-color-text-primary;
    }
    
    &:active:not(:disabled) {
      background: $semantic-color-surface-pressed;
      transform: translateY(1px);
    }
    
    &:focus-visible {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }
    
    &--disabled,
    &:disabled {
      opacity: $semantic-opacity-disabled;
      cursor: not-allowed;
      pointer-events: none;
    }
    
    // Contextual toolbar button styles
    .ui-floating-toolbar--contextual & {
      color: $semantic-color-on-primary;
      
      &:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.1);
        color: $semantic-color-on-primary;
      }
      
      &:active:not(:disabled) {
        background: rgba(255, 255, 255, 0.2);
      }
    }
    
    // Icon styling
    i {
      flex-shrink: 0;
      font-size: $semantic-typography-font-size-sm;
      line-height: 1;
    }
  }
  
  &__action-label {
    display: none;
    
    &--visible {
      display: inline;
    }
    
    // Show labels on small screens or when no icon
    @media (max-width: $semantic-breakpoint-sm - 1) {
      display: inline;
    }
  }
  
  &__shortcut {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: $semantic-color-surface-secondary;
    color: $semantic-color-text-secondary;
    font-family: $semantic-typography-font-family-mono;
    font-size: $semantic-typography-font-size-xs;
    font-weight: $semantic-typography-font-weight-medium;
    border-radius: $semantic-border-radius-sm;
    border: $semantic-border-width-1 solid $semantic-color-border-subtle;
    margin-left: $semantic-spacing-component-xs;
    
    .ui-floating-toolbar--contextual & {
      background: rgba(255, 255, 255, 0.15);
      color: $semantic-color-on-primary;
      border-color: rgba(255, 255, 255, 0.2);
      opacity: $semantic-opacity-subtle;
    }
  }
  
  &__divider {
    width: $semantic-border-width-1;
    height: $semantic-sizing-button-height-sm;
    background: $semantic-color-border-subtle;
    margin: 0 $semantic-spacing-component-xs;
    
    .ui-floating-toolbar--contextual & {
      background: rgba(255, 255, 255, 0.2);
    }
  }
  
  &__label {
    color: $semantic-color-text-secondary;
    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);
    white-space: nowrap;
    
    .ui-floating-toolbar--contextual & {
      color: $semantic-color-on-primary;
      opacity: $semantic-opacity-subtle;
    }
  }
  
  // Position Variants
  &--top {
    transform: translateY(8px);
    
    &.ui-floating-toolbar--visible {
      transform: translateY(0);
    }
  }
  
  &--bottom {
    transform: translateY(-8px);
    
    &.ui-floating-toolbar--visible {
      transform: translateY(0);
    }
  }
  
  &--left {
    transform: translateX(8px);
    
    &.ui-floating-toolbar--visible {
      transform: translateX(0);
    }
  }
  
  &--right {
    transform: translateX(-8px);
    
    &.ui-floating-toolbar--visible {
      transform: translateX(0);
    }
  }
  
  // Animation Variants
  &--slide-fade {
    transition: opacity $semantic-motion-duration-normal $semantic-motion-easing-ease,
                transform $semantic-motion-duration-normal $semantic-motion-easing-ease;
  }
  
  &--bounce {
    transition: opacity $semantic-motion-duration-fast $semantic-motion-easing-spring,
                transform $semantic-motion-duration-fast $semantic-motion-easing-spring;
  }
  
  // Interactive States
  &:not(.ui-floating-toolbar--disabled) {
    &:focus-within {
      box-shadow: $semantic-shadow-elevation-4, 0 0 0 2px $semantic-color-focus;
    }
  }
  
  // Responsive Design
  @media (max-width: $semantic-breakpoint-md - 1) {
    padding: $semantic-spacing-component-xs $semantic-spacing-component-sm;
    gap: $semantic-spacing-component-xs;
    
    &.ui-floating-toolbar--lg {
      padding: $semantic-spacing-component-sm;
      gap: $semantic-spacing-component-sm;
    }
  }
  
  @media (max-width: $semantic-breakpoint-sm - 1) {
    padding: $semantic-spacing-component-xs;
    gap: $semantic-spacing-component-xs;
    border-radius: $semantic-border-radius-md;
    
    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);
    
    &__actions {
      gap: $semantic-spacing-component-xs;
    }
    
    &__divider {
      margin: 0 $semantic-spacing-component-xs;
    }
  }
  
  // Touch-friendly adjustments
  @media (hover: none) and (pointer: coarse) {
    min-height: $semantic-sizing-touch-target;
    
    &__actions {
      min-height: $semantic-sizing-touch-minimum;
    }
  }
  
  // High contrast mode support
  @media (prefers-contrast: high) {
    border-width: $semantic-border-width-2;
    box-shadow: none;
    
    &--elevated,
    &--floating {
      border: $semantic-border-width-2 solid $semantic-color-border-primary;
    }
  }
  
  // Reduced motion support
  @media (prefers-reduced-motion: reduce) {
    transition: none;
    
    &--slide-fade,
    &--bounce {
      transition: none;
    }
  }
}

// Backdrop for modal-like behavior when needed
.ui-floating-toolbar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: calc($semantic-z-index-overlay - 1);
  pointer-events: auto;
}