/* ==== 
 --------- (1.01) mixins start ---------
 ==== */

@use "sass:color";

// Legacy mixins for backward compatibility
@mixin background($color, $repeat, $size, $position) {
  background-color: $color;
  background-repeat: $repeat;
  background-size: $size;
  background-position: $position;
}

@mixin center($width) {
  max-width: $width;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

@mixin box($value) {
  width: $value;
  min-width: $value;
  height: $value;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

// Modern utility mixins
@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@mixin flex-column {
  display: flex;
  flex-direction: column;
}

@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@mixin absolute-cover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

// Typography mixins
@mixin text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin text-clamp($lines: 2) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@mixin font-smoothing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// Visual effects mixins
@mixin glassmorphism($opacity: 0.1, $blur: 10px) {
  background: rgba(255, 255, 255, $opacity);
  backdrop-filter: blur($blur);
  -webkit-backdrop-filter: blur($blur);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@mixin glassmorphism-dark($opacity: 0.1, $blur: 10px) {
  background: rgba(0, 0, 0, $opacity);
  backdrop-filter: blur($blur);
  -webkit-backdrop-filter: blur($blur);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@mixin gradient-text($gradient) {
  background: $gradient;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@mixin gradient-border($gradient, $width: 1px) {
  position: relative;
  background: $gradient;
  border-radius: inherit;
  
  &::before {
    content: '';
    position: absolute;
    inset: $width;
    background: inherit;
    border-radius: inherit;
    z-index: -1;
  }
}

// Shadow mixins
@mixin shadow-elevation($level: 1) {
  @if $level == 1 {
    box-shadow: var(--shadow-sm);
  } @else if $level == 2 {
    box-shadow: var(--shadow-base);
  } @else if $level == 3 {
    box-shadow: var(--shadow-md);
  } @else if $level == 4 {
    box-shadow: var(--shadow-lg);
  } @else if $level == 5 {
    box-shadow: var(--shadow-xl);
  }
}

@mixin shadow-colored($color, $opacity: 0.25) {
  box-shadow: 0 4px 14px 0 rgba($color, $opacity);
}

// Animation mixins
@mixin transition($properties: all, $duration: 0.3s, $timing: ease-in-out) {
  transition: $properties $duration $timing;
}

@mixin hover-lift($lift: 4px) {
  transition: transform var(--transition-default);
  
  &:hover {
    transform: translateY(-#{$lift});
  }
}

@mixin hover-scale($scale: 1.05) {
  transition: transform var(--transition-default);
  
  &:hover {
    transform: scale($scale);
  }
}

@mixin pulse-animation($color: var(--primary-500), $duration: 2s) {
  animation: pulse $duration infinite;
  
  @keyframes pulse {
    0%, 100% {
      box-shadow: 0 0 0 0 rgba($color, 0.7);
    }
    70% {
      box-shadow: 0 0 0 10px rgba($color, 0);
    }
  }
}

@mixin shimmer-effect {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  
  @keyframes shimmer {
    0% {
      background-position: -200% 0;
    }
    100% {
      background-position: 200% 0;
    }
  }
}

// Layout mixins
@mixin container($max-width: var(--container-xl)) {
  width: 100%;
  max-width: $max-width;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  
  @media (min-width: 640px) {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
  
  @media (min-width: 1024px) {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

@mixin grid($columns: 1, $gap: var(--space-4)) {
  display: grid;
  grid-template-columns: repeat($columns, 1fr);
  gap: $gap;
}

@mixin aspect-ratio($width: 16, $height: 9) {
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    display: block;
    padding-top: percentage($height / $width);
  }
  
  > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

// Button mixins
@mixin button-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
  line-height: var(--leading-none);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-colors);
  user-select: none;
  
  &:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--primary-500);
  }
  
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

@mixin button-variant($bg, $color: white, $hover-bg: null, $hover-color: null) {
  background-color: $bg;
  color: $color;
  
  &:hover:not(:disabled) {
    background-color: $hover-bg or $bg;
    color: $hover-color or $color;
    filter: brightness(0.9);
  }
  
  &:active:not(:disabled) {
    background-color: $bg;
    filter: brightness(0.85);
  }
}

@mixin button-outline($color, $hover-bg: null, $hover-color: null) {
  background-color: transparent;
  color: $color;
  border-color: $color;
  
  &:hover:not(:disabled) {
    background-color: $hover-bg or $color;
    color: $hover-color or white;
  }
}

// Form mixins
@mixin input-base {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--secondary-300);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  background-color: var(--white);
  transition: var(--transition-colors);
  
  &:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
  }
  
  &::placeholder {
    color: var(--secondary-400);
  }
  
  &:disabled {
    background-color: var(--secondary-100);
    color: var(--secondary-500);
    cursor: not-allowed;
  }
}

// Card mixins
@mixin card-base {
  background-color: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-shadow);
  
  &:hover {
    box-shadow: var(--shadow-md);
  }
}

@mixin card-elevated {
  @include card-base;
  box-shadow: var(--shadow-lg);
  
  &:hover {
    box-shadow: var(--shadow-xl);
  }
}

// Responsive mixins
@mixin mobile-only {
  @media (max-width: 767px) {
    @content;
  }
}

@mixin tablet-up {
  @media (min-width: 768px) {
    @content;
  }
}

@mixin desktop-up {
  @media (min-width: 1024px) {
    @content;
  }
}

@mixin large-desktop-up {
  @media (min-width: 1280px) {
    @content;
  }
}

// Accessibility mixins
@mixin 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;
}

@mixin focus-visible {
  &:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
  }
}

// Print mixins
@mixin print-only {
  @media print {
    @content;
  }
}

@mixin no-print {
  @media print {
    display: none !important;
  }
}

/* ==== 
 --------- (1.01) mixins end ---------
 ==== */
