/*
 * ═══════════════════════════════════════════════════════════
 * Lions.dev - Form Controls Component Styles
 * ═══════════════════════════════════════════════════════════
 * Styles pour Checkbox, Radio, Switch, Toggle, Slider, Rating
 *
 * Version: 1.0.0
 * Date: 2 Janvier 2026
 * Author: Lions Development Team
 * Priority: CRITIQUE #28-33
 * ═══════════════════════════════════════════════════════════
 */

@import '../variables';
@import '../mixins';

// ============================================
// ☑️ CHECKBOX STYLES
// ============================================

.ui-chkbox {
  display: inline-flex;
  align-items: center;
  gap: $lions-spacing-2;
  cursor: pointer;
  @include lions-transition();

  .ui-chkbox-box {
    width: 1.25rem;
    height: 1.25rem;
    @include lions-rounded('md');
    border: 2px solid $lions-gray-400;
    background: $lions-white;
    @include lions-flex-center;
    @include lions-transition();
    flex-shrink: 0;

    .ui-chkbox-icon {
      font-size: 0.875rem;
      color: $lions-white;
      opacity: 0;
      transform: scale(0.5);
      @include lions-transition();
    }

    &:hover {
      border-color: $lions-blue-500;
      background: rgba($lions-blue-50, 0.3);
    }

    &:focus-visible {
      @include lions-focus-ring();
    }

    &.ui-state-active {
      @include lions-gradient-blue;
      border-color: $lions-blue-600;
      box-shadow: 0 2px 4px rgba($lions-blue-500, 0.2);

      .ui-chkbox-icon {
        opacity: 1;
        transform: scale(1);
      }
    }

    &.ui-state-disabled {
      background: $lions-gray-100;
      border-color: $lions-gray-300;
      cursor: not-allowed;
      opacity: 0.6;
    }
  }

  .ui-chkbox-label {
    cursor: pointer;
    color: $lions-text-primary;
    @include lions-font-size('base');
    @include lions-font-weight('medium');
    user-select: none;
    @include lions-transition();

    &:hover {
      color: $lions-blue-700;
    }
  }

  // Size variants
  &.ui-chkbox-sm {
    .ui-chkbox-box {
      width: 1rem;
      height: 1rem;

      .ui-chkbox-icon {
        font-size: 0.75rem;
      }
    }

    .ui-chkbox-label {
      @include lions-font-size('sm');
    }
  }

  &.ui-chkbox-lg {
    .ui-chkbox-box {
      width: 1.5rem;
      height: 1.5rem;

      .ui-chkbox-icon {
        font-size: 1rem;
      }
    }

    .ui-chkbox-label {
      @include lions-font-size('lg');
    }
  }

  // State error
  &.ui-state-error {
    .ui-chkbox-box {
      border-color: $lions-danger-500;

      &.ui-state-active {
        @include lions-gradient-danger;
      }
    }

    .ui-chkbox-label {
      color: $lions-danger-700;
    }
  }

  // State disabled
  &.ui-state-disabled {
    cursor: not-allowed;
    opacity: 0.6;

    .ui-chkbox-label {
      cursor: not-allowed;
      color: $lions-gray-500;
    }
  }
}

// ============================================
// 🔘 RADIO BUTTON STYLES
// ============================================

.ui-radiobutton {
  display: inline-flex;
  align-items: center;
  gap: $lions-spacing-2;
  cursor: pointer;
  @include lions-transition();

  .ui-radiobutton-box {
    width: 1.25rem;
    height: 1.25rem;
    @include lions-rounded('full');
    border: 2px solid $lions-gray-400;
    background: $lions-white;
    @include lions-flex-center;
    @include lions-transition();
    flex-shrink: 0;

    .ui-radiobutton-icon {
      width: 0.625rem;
      height: 0.625rem;
      @include lions-rounded('full');
      background: $lions-white;
      opacity: 0;
      transform: scale(0);
      @include lions-transition();
    }

    &:hover {
      border-color: $lions-blue-500;
      background: rgba($lions-blue-50, 0.3);
    }

    &:focus-visible {
      @include lions-focus-ring();
    }

    &.ui-state-active {
      @include lions-gradient-blue;
      border-color: $lions-blue-600;
      box-shadow: 0 2px 4px rgba($lions-blue-500, 0.2);

      .ui-radiobutton-icon {
        opacity: 1;
        transform: scale(1);
      }
    }

    &.ui-state-disabled {
      background: $lions-gray-100;
      border-color: $lions-gray-300;
      cursor: not-allowed;
      opacity: 0.6;
    }
  }

  .ui-radiobutton-label {
    cursor: pointer;
    color: $lions-text-primary;
    @include lions-font-size('base');
    @include lions-font-weight('medium');
    user-select: none;
    @include lions-transition();

    &:hover {
      color: $lions-blue-700;
    }
  }

  // Size variants
  &.ui-radiobutton-sm {
    .ui-radiobutton-box {
      width: 1rem;
      height: 1rem;

      .ui-radiobutton-icon {
        width: 0.5rem;
        height: 0.5rem;
      }
    }

    .ui-radiobutton-label {
      @include lions-font-size('sm');
    }
  }

  &.ui-radiobutton-lg {
    .ui-radiobutton-box {
      width: 1.5rem;
      height: 1.5rem;

      .ui-radiobutton-icon {
        width: 0.75rem;
        height: 0.75rem;
      }
    }

    .ui-radiobutton-label {
      @include lions-font-size('lg');
    }
  }

  // State error
  &.ui-state-error {
    .ui-radiobutton-box {
      border-color: $lions-danger-500;

      &.ui-state-active {
        @include lions-gradient-danger;
      }
    }

    .ui-radiobutton-label {
      color: $lions-danger-700;
    }
  }

  // State disabled
  &.ui-state-disabled {
    cursor: not-allowed;
    opacity: 0.6;

    .ui-radiobutton-label {
      cursor: not-allowed;
      color: $lions-gray-500;
    }
  }
}

// ============================================
// 🔀 SWITCH TOGGLE STYLES
// ============================================

.ui-inputswitch {
  display: inline-flex;
  align-items: center;
  gap: $lions-spacing-2;

  .ui-inputswitch-slider {
    width: 2.75rem;
    height: 1.5rem;
    @include lions-rounded('full');
    background: $lions-gray-300;
    border: 2px solid $lions-gray-400;
    position: relative;
    cursor: pointer;
    @include lions-transition();
    flex-shrink: 0;

    &::before {
      content: '';
      position: absolute;
      top: 2px;
      left: 2px;
      width: 1.125rem;
      height: 1.125rem;
      @include lions-rounded('full');
      background: $lions-white;
      @include lions-shadow('sm');
      @include lions-transition();
    }

    &:hover {
      background: $lions-gray-400;
      border-color: $lions-gray-500;
    }

    &:focus-visible {
      @include lions-focus-ring();
    }

    &.ui-inputswitch-checked {
      @include lions-gradient-blue;
      border-color: $lions-blue-600;

      &::before {
        left: calc(100% - 1.125rem - 2px);
      }

      &:hover {
        background: linear-gradient(135deg, darken($lions-blue-500, 5%) 0%, darken($lions-blue-700, 5%) 100%);
      }
    }

    &.ui-state-disabled {
      background: $lions-gray-200;
      border-color: $lions-gray-300;
      cursor: not-allowed;
      opacity: 0.6;

      &::before {
        background: $lions-gray-300;
      }
    }
  }

  // Size variants
  &.ui-inputswitch-sm {
    .ui-inputswitch-slider {
      width: 2.25rem;
      height: 1.25rem;

      &::before {
        width: 0.875rem;
        height: 0.875rem;
      }

      &.ui-inputswitch-checked::before {
        left: calc(100% - 0.875rem - 2px);
      }
    }
  }

  &.ui-inputswitch-lg {
    .ui-inputswitch-slider {
      width: 3.25rem;
      height: 1.75rem;

      &::before {
        width: 1.375rem;
        height: 1.375rem;
      }

      &.ui-inputswitch-checked::before {
        left: calc(100% - 1.375rem - 2px);
      }
    }
  }

  // Success variant
  &.ui-inputswitch-success {
    .ui-inputswitch-slider.ui-inputswitch-checked {
      @include lions-gradient-success;
      border-color: $lions-success-600;
    }
  }

  // Danger variant
  &.ui-inputswitch-danger {
    .ui-inputswitch-slider.ui-inputswitch-checked {
      @include lions-gradient-danger;
      border-color: $lions-danger-600;
    }
  }
}

// ============================================
// 🎚️ SLIDER STYLES
// ============================================

.ui-slider {
  background: $lions-gray-200;
  border: none;
  @include lions-rounded('full');
  position: relative;
  height: 0.5rem;
  cursor: pointer;

  .ui-slider-range {
    @include lions-gradient-blue;
    @include lions-rounded('full');
    position: absolute;
    height: 100%;
  }

  .ui-slider-handle {
    width: 1.25rem;
    height: 1.25rem;
    @include lions-rounded('full');
    background: $lions-white;
    border: 3px solid $lions-blue-500;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    @include lions-shadow('md');
    @include lions-transition();

    &:hover {
      transform: translateY(-50%) scale(1.1);
      border-color: $lions-blue-600;
      @include lions-shadow('lg');
    }

    &:active {
      cursor: grabbing;
      transform: translateY(-50%) scale(1.15);
      @include lions-shadow('xl');
    }

    &:focus-visible {
      @include lions-focus-ring();
    }
  }

  // Horizontal slider
  &.ui-slider-horizontal {
    width: 100%;

    .ui-slider-handle {
      left: 0;
      margin-left: -0.625rem;
    }

    .ui-slider-range {
      left: 0;
    }
  }

  // Vertical slider
  &.ui-slider-vertical {
    width: 0.5rem;
    height: 200px;

    .ui-slider-handle {
      left: 50%;
      bottom: 0;
      margin-left: -0.625rem;
      margin-bottom: -0.625rem;
    }

    .ui-slider-range {
      bottom: 0;
      width: 100%;
    }
  }

  // Size variants
  &.ui-slider-sm {
    height: 0.375rem;

    .ui-slider-handle {
      width: 1rem;
      height: 1rem;
    }

    &.ui-slider-horizontal .ui-slider-handle {
      margin-left: -0.5rem;
    }

    &.ui-slider-vertical {
      width: 0.375rem;

      .ui-slider-handle {
        margin-left: -0.5rem;
        margin-bottom: -0.5rem;
      }
    }
  }

  &.ui-slider-lg {
    height: 0.625rem;

    .ui-slider-handle {
      width: 1.5rem;
      height: 1.5rem;
    }

    &.ui-slider-horizontal .ui-slider-handle {
      margin-left: -0.75rem;
    }

    &.ui-slider-vertical {
      width: 0.625rem;

      .ui-slider-handle {
        margin-left: -0.75rem;
        margin-bottom: -0.75rem;
      }
    }
  }

  // State disabled
  &.ui-state-disabled {
    opacity: 0.6;
    cursor: not-allowed;

    .ui-slider-handle {
      cursor: not-allowed;
      background: $lions-gray-200;
      border-color: $lions-gray-400;
    }

    .ui-slider-range {
      background: $lions-gray-400;
    }
  }

  // Color variants
  &.ui-slider-success {
    .ui-slider-range {
      @include lions-gradient-success;
    }

    .ui-slider-handle {
      border-color: $lions-success-500;
    }
  }

  &.ui-slider-danger {
    .ui-slider-range {
      @include lions-gradient-danger;
    }

    .ui-slider-handle {
      border-color: $lions-danger-500;
    }
  }

  &.ui-slider-warning {
    .ui-slider-range {
      @include lions-gradient-warning;
    }

    .ui-slider-handle {
      border-color: $lions-warning-500;
    }
  }
}

// ============================================
// ⭐ RATING STYLES
// ============================================

.ui-rating {
  display: inline-flex;
  align-items: center;
  gap: $lions-spacing-1;

  .ui-rating-icon {
    font-size: 1.5rem;
    color: $lions-gray-300;
    cursor: pointer;
    @include lions-transition();

    &:hover {
      color: $lions-gold-400;
      transform: scale(1.15);
    }

    &:active {
      transform: scale(1.05);
    }

    &.ui-rating-icon-active {
      color: $lions-gold-500;
      text-shadow: 0 2px 4px rgba($lions-gold-500, 0.3);
    }

    &.ui-rating-icon-hover {
      color: $lions-gold-400;
    }
  }

  .ui-rating-cancel {
    color: $lions-danger-500;
    margin-right: $lions-spacing-2;

    &:hover {
      color: $lions-danger-600;
      transform: scale(1.15);
    }
  }

  // Size variants
  &.ui-rating-sm {
    .ui-rating-icon {
      font-size: 1.125rem;
    }
  }

  &.ui-rating-lg {
    .ui-rating-icon {
      font-size: 2rem;
    }
  }

  // State disabled
  &.ui-state-disabled {
    opacity: 0.6;

    .ui-rating-icon {
      cursor: not-allowed;

      &:hover {
        transform: none;
        color: $lions-gray-300;
      }

      &.ui-rating-icon-active {
        color: $lions-gold-500;
      }
    }
  }

  // Readonly
  &.ui-rating-readonly {
    .ui-rating-icon {
      cursor: default;

      &:hover {
        transform: none;
      }

      &.ui-rating-icon-active {
        color: $lions-gold-500;
      }
    }
  }

  // Heart variant
  &.ui-rating-hearts {
    .ui-rating-icon {
      color: $lions-gray-300;

      &.ui-rating-icon-active {
        color: $lions-danger-500;
        text-shadow: 0 2px 4px rgba($lions-danger-500, 0.3);
      }

      &:hover {
        color: $lions-danger-400;
      }
    }
  }
}

// ============================================
// 🔢 SPINNER STYLES
// ============================================

.ui-spinner {
  display: inline-flex;
  align-items: stretch;
  @include lions-rounded('md');
  overflow: hidden;
  border: 1px solid $lions-gray-300;
  background: $lions-white;
  @include lions-transition();

  &:hover {
    border-color: $lions-gray-400;
  }

  &:focus-within {
    border-color: $lions-blue-500;
    box-shadow: 0 0 0 3px rgba($lions-blue-500, 0.15);
  }

  .ui-spinner-input {
    flex: 1;
    border: none;
    padding: $lions-spacing-3 $lions-spacing-4;
    font-family: $lions-font-family-primary;
    @include lions-font-size('base');
    color: $lions-text-primary;
    text-align: center;
    min-width: 80px;

    &:focus {
      outline: none;
    }

    &::placeholder {
      color: $lions-gray-400;
    }
  }

  .ui-spinner-button {
    @include lions-button-base;
    width: 2.5rem;
    background: $lions-gray-100;
    border: none;
    border-left: 1px solid $lions-gray-300;
    color: $lions-gray-700;
    @include lions-flex-center;
    cursor: pointer;
    @include lions-transition();

    &:hover {
      background: $lions-blue-50;
      color: $lions-blue-600;
    }

    &:active {
      background: $lions-blue-100;
    }

    &:first-of-type {
      border-right: 1px solid $lions-gray-300;
      border-left: none;
    }

    .ui-icon {
      font-size: 1rem;
    }
  }

  // Vertical layout
  &.ui-spinner-vertical {
    flex-direction: column;

    .ui-spinner-button {
      border-left: none;
      border-top: 1px solid $lions-gray-300;
      width: 100%;
      height: 1.5rem;

      &:first-of-type {
        border-top: none;
        border-bottom: 1px solid $lions-gray-300;
      }
    }
  }

  // Size variants
  &.ui-spinner-sm {
    .ui-spinner-input {
      padding: $lions-spacing-2 $lions-spacing-3;
      @include lions-font-size('sm');
      min-width: 60px;
    }

    .ui-spinner-button {
      width: 2rem;
    }
  }

  &.ui-spinner-lg {
    .ui-spinner-input {
      padding: $lions-spacing-4 $lions-spacing-5;
      @include lions-font-size('lg');
      min-width: 100px;
    }

    .ui-spinner-button {
      width: 3rem;
    }
  }

  // State disabled
  &.ui-state-disabled {
    background: $lions-gray-100;
    opacity: 0.6;
    cursor: not-allowed;

    .ui-spinner-input {
      cursor: not-allowed;
      color: $lions-gray-500;
    }

    .ui-spinner-button {
      cursor: not-allowed;
      background: $lions-gray-100;
      color: $lions-gray-400;

      &:hover {
        background: $lions-gray-100;
        color: $lions-gray-400;
      }
    }
  }

  // State error
  &.ui-state-error {
    border-color: $lions-danger-500;

    &:focus-within {
      box-shadow: 0 0 0 3px rgba($lions-danger-500, 0.15);
    }
  }
}

// ============================================
// 🔄 TOGGLE BUTTON STYLES
// ============================================

.ui-togglebutton {
  @include lions-button-base;
  padding: $lions-spacing-3 $lions-spacing-5;
  @include lions-rounded('md');
  border: 2px solid $lions-gray-400;
  background: $lions-white;
  color: $lions-text-primary;
  @include lions-font-weight('medium');
  cursor: pointer;
  @include lions-transition();

  .ui-button-icon-left {
    margin-right: $lions-spacing-2;
    @include lions-transition();
  }

  .ui-button-text {
    @include lions-font-size('base');
  }

  &:hover {
    border-color: $lions-blue-500;
    background: rgba($lions-blue-50, 0.5);
    color: $lions-blue-700;
  }

  &:active {
    transform: scale(0.98);
  }

  &:focus-visible {
    @include lions-focus-ring();
  }

  &.ui-state-active {
    @include lions-gradient-blue;
    border-color: $lions-blue-600;
    color: $lions-white;
    @include lions-shadow('md');

    .ui-button-icon-left {
      color: $lions-white;
    }

    &:hover {
      background: linear-gradient(135deg, darken($lions-blue-500, 5%) 0%, darken($lions-blue-700, 5%) 100%);
    }
  }

  // Size variants
  &.ui-togglebutton-sm {
    padding: $lions-spacing-2 $lions-spacing-4;

    .ui-button-text {
      @include lions-font-size('sm');
    }

    .ui-button-icon-left {
      font-size: 0.875rem;
    }
  }

  &.ui-togglebutton-lg {
    padding: $lions-spacing-4 $lions-spacing-6;

    .ui-button-text {
      @include lions-font-size('lg');
    }

    .ui-button-icon-left {
      font-size: 1.25rem;
    }
  }

  // State disabled
  &.ui-state-disabled {
    background: $lions-gray-100;
    border-color: $lions-gray-300;
    color: $lions-gray-500;
    cursor: not-allowed;
    opacity: 0.6;

    &:hover {
      background: $lions-gray-100;
      border-color: $lions-gray-300;
      color: $lions-gray-500;
      transform: none;
    }
  }
}

// ============================================
// 📱 RESPONSIVE ADJUSTMENTS
// ============================================

@media (max-width: $lions-breakpoint-md) {
  .ui-chkbox,
  .ui-radiobutton {
    gap: $lions-spacing-3;

    .ui-chkbox-box,
    .ui-radiobutton-box {
      width: 1.375rem;
      height: 1.375rem;
    }
  }

  .ui-rating {
    .ui-rating-icon {
      font-size: 1.25rem;
    }
  }

  .ui-slider {
    &.ui-slider-vertical {
      height: 150px;
    }
  }
}

// ============================================
// ♿ ACCESSIBILITY ENHANCEMENTS
// ============================================

.ui-chkbox,
.ui-radiobutton,
.ui-inputswitch,
.ui-slider,
.ui-rating,
.ui-spinner,
.ui-togglebutton {
  // Focus visible
  *:focus-visible {
    @include lions-focus-ring();
  }

  // High contrast mode
  @media (prefers-contrast: high) {
    border-width: 2px !important;

    .ui-chkbox-box,
    .ui-radiobutton-box,
    .ui-inputswitch-slider,
    .ui-slider-handle {
      border-width: 3px !important;
    }
  }

  // Reduced motion
  @media (prefers-reduced-motion: reduce) {
    * {
      transition: none !important;
      animation: none !important;
    }
  }
}
