/*
 * ═══════════════════════════════════════════════════════════
 * Lions.dev - Advanced Form Component Styles
 * ═══════════════════════════════════════════════════════════
 * Styles pour composants de formulaire avancés
 * Spinner, Mask, Chips, ColorPicker, Editor, FileUpload
 *
 * Version: 1.0.0
 * Date: 2 Janvier 2026
 * Author: Lions Development Team
 * Priority: BASSE #40-44
 * ═══════════════════════════════════════════════════════════
 */

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

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

.ui-spinner {
  display: inline-flex;
  position: relative;
  width: 100%;

  .ui-spinner-input {
    width: 100%;
    height: $lions-input-height-base;
    padding: $lions-spacing-3 $lions-spacing-4;
    padding-right: 2.5rem;
    @include lions-rounded('md');
    border: 1px solid $lions-gray-300;
    @include lions-font-size('base');
    color: $lions-text-primary;
    background: $lions-white;
    @include lions-transition();

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

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

    &:disabled {
      background: $lions-gray-100;
      cursor: not-allowed;
      opacity: 0.6;
    }
  }

  .ui-spinner-button-group {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .ui-spinner-button {
    @include lions-button-base;
    width: 2rem;
    height: 50%;
    min-width: 2rem;
    padding: 0;
    @include lions-flex-center;
    background: $lions-gray-100;
    border: 1px solid $lions-gray-300;
    border-left: none;
    color: $lions-gray-600;
    cursor: pointer;
    @include lions-transition();

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

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

    &.ui-spinner-up {
      border-top-right-radius: $lions-rounded-md;
      border-bottom: none;
    }

    &.ui-spinner-down {
      border-bottom-right-radius: $lions-rounded-md;
    }

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

  // Size variants
  &.ui-spinner-sm {
    .ui-spinner-input {
      height: $lions-input-height-sm;
      padding: $lions-spacing-2 $lions-spacing-3;
      padding-right: 2rem;
      @include lions-font-size('sm');
    }

    .ui-spinner-button {
      width: 1.75rem;
      min-width: 1.75rem;
    }
  }

  &.ui-spinner-lg {
    .ui-spinner-input {
      height: $lions-input-height-lg;
      padding: $lions-spacing-4 $lions-spacing-5;
      padding-right: 3rem;
      @include lions-font-size('lg');
    }

    .ui-spinner-button {
      width: 2.5rem;
      min-width: 2.5rem;

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

// ============================================
// 🎭 INPUT MASK STYLES
// ============================================

.ui-inputmask {
  width: 100%;
  height: $lions-input-height-base;
  padding: $lions-spacing-3 $lions-spacing-4;
  @include lions-rounded('md');
  border: 1px solid $lions-gray-300;
  @include lions-font-size('base');
  color: $lions-text-primary;
  background: $lions-white;
  @include lions-transition();
  font-family: $lions-font-family-mono;

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

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

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

  &:disabled {
    background: $lions-gray-100;
    cursor: not-allowed;
    opacity: 0.6;
  }

  // Size variants
  &.ui-inputmask-sm {
    height: $lions-input-height-sm;
    padding: $lions-spacing-2 $lions-spacing-3;
    @include lions-font-size('sm');
  }

  &.ui-inputmask-lg {
    height: $lions-input-height-lg;
    padding: $lions-spacing-4 $lions-spacing-5;
    @include lions-font-size('lg');
  }
}

// ============================================
// 🏷️ CHIPS STYLES
// ============================================

.ui-chips {
  display: block;
  width: 100%;

  .ui-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: $lions-spacing-2;
    padding: $lions-spacing-2;
    @include lions-rounded('md');
    border: 1px solid $lions-gray-300;
    background: $lions-white;
    min-height: $lions-input-height-base;
    @include lions-transition();

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

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

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

  .ui-chips-token {
    display: inline-flex;
    align-items: center;
    gap: $lions-spacing-2;
    padding: $lions-spacing-2 $lions-spacing-3;
    @include lions-rounded('md');
    background: $lions-blue-100;
    color: $lions-blue-700;
    @include lions-font-size('sm');
    @include lions-font-weight('medium');
    @include lions-transition();

    &:hover {
      background: $lions-blue-200;
    }
  }

  .ui-chips-token-icon {
    @include lions-button-base;
    width: 1rem;
    height: 1rem;
    min-width: 1rem;
    padding: 0;
    @include lions-flex-center;
    background: transparent;
    border: none;
    color: $lions-blue-600;
    cursor: pointer;
    @include lions-rounded('full');
    @include lions-transition();

    &:hover {
      background: rgba($lions-blue-700, 0.2);
      color: $lions-blue-800;
    }

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

  .ui-chips-input-token {
    flex: 1;
    min-width: 120px;

    input {
      width: 100%;
      border: none;
      outline: none;
      background: transparent;
      padding: $lions-spacing-2;
      @include lions-font-size('base');
      color: $lions-text-primary;

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

  // Severity variants
  &.ui-chips-success .ui-chips-token {
    background: $lions-success-100;
    color: $lions-success-700;

    .ui-chips-token-icon {
      color: $lions-success-600;
    }
  }

  &.ui-chips-warning .ui-chips-token {
    background: $lions-warning-100;
    color: $lions-warning-700;

    .ui-chips-token-icon {
      color: $lions-warning-600;
    }
  }

  &.ui-chips-danger .ui-chips-token {
    background: $lions-danger-100;
    color: $lions-danger-700;

    .ui-chips-token-icon {
      color: $lions-danger-600;
    }
  }
}

// ============================================
// 🎨 COLOR PICKER STYLES
// ============================================

.ui-colorpicker {
  display: inline-flex;
  position: relative;

  .ui-colorpicker-preview {
    width: 2.5rem;
    height: 2.5rem;
    @include lions-rounded('md');
    border: 2px solid $lions-gray-300;
    cursor: pointer;
    @include lions-shadow('sm');
    @include lions-transition();
    position: relative;
    overflow: hidden;

    &:hover {
      border-color: $lions-blue-400;
      transform: scale(1.05);
    }

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

    .ui-colorpicker-color {
      width: 100%;
      height: 100%;
    }
  }

  .ui-colorpicker-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: $lions-spacing-2;
    @include lions-rounded('lg');
    @include lions-shadow('xl');
    background: $lions-white;
    border: 1px solid $lions-gray-200;
    padding: $lions-spacing-4;
    z-index: 1000;

    .ui-colorpicker-content {
      display: flex;
      flex-direction: column;
      gap: $lions-spacing-3;
    }

    .ui-colorpicker-hue {
      width: 100%;
      height: 1rem;
      @include lions-rounded('md');
      cursor: crosshair;
    }

    .ui-colorpicker-color-selector {
      width: 200px;
      height: 150px;
      @include lions-rounded('md');
      cursor: crosshair;
      position: relative;
      background: linear-gradient(to right, #fff, transparent),
                  linear-gradient(to top, #000, transparent);
    }

    .ui-colorpicker-color-handle {
      position: absolute;
      width: 12px;
      height: 12px;
      @include lions-rounded('full');
      border: 2px solid $lions-white;
      @include lions-shadow('md');
      transform: translate(-50%, -50%);
      pointer-events: none;
    }
  }

  // Inline variant
  &.ui-colorpicker-inline {
    .ui-colorpicker-panel {
      position: static;
      margin-top: 0;
      display: block;
    }
  }

  // Size variants
  &.ui-colorpicker-sm .ui-colorpicker-preview {
    width: 2rem;
    height: 2rem;
  }

  &.ui-colorpicker-lg .ui-colorpicker-preview {
    width: 3rem;
    height: 3rem;
  }
}

// ============================================
// 📝 RICH TEXT EDITOR STYLES
// ============================================

.ui-editor {
  display: block;
  width: 100%;
  @include lions-rounded('lg');
  border: 1px solid $lions-gray-300;
  background: $lions-white;
  @include lions-shadow('sm');
  overflow: hidden;

  .ui-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: $lions-spacing-1;
    padding: $lions-spacing-3;
    background: $lions-gray-50;
    border-bottom: 1px solid $lions-gray-200;
  }

  .ui-editor-toolbar-group {
    display: flex;
    gap: $lions-spacing-1;
    padding-right: $lions-spacing-2;
    border-right: 1px solid $lions-gray-300;

    &:last-child {
      border-right: none;
      padding-right: 0;
    }
  }

  .ui-editor-toolbar-button {
    @include lions-button-base;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    padding: 0;
    @include lions-flex-center;
    background: transparent;
    border: 1px solid transparent;
    @include lions-rounded('md');
    color: $lions-gray-600;
    cursor: pointer;
    @include lions-transition();

    &:hover {
      background: $lions-white;
      border-color: $lions-gray-300;
      color: $lions-blue-600;
    }

    &:active,
    &.ui-state-active {
      background: $lions-blue-100;
      border-color: $lions-blue-300;
      color: $lions-blue-700;
    }

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

  .ui-editor-content {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: $lions-spacing-4;
    @include lions-font-size('base');
    line-height: 1.6;
    color: $lions-text-primary;

    &:focus {
      outline: none;
    }

    // Typography inside editor
    h1, h2, h3, h4, h5, h6 {
      margin-top: $lions-spacing-4;
      margin-bottom: $lions-spacing-3;
      @include lions-font-weight('bold');
      color: $lions-text-primary;
    }

    h1 { @include lions-font-size('3xl'); }
    h2 { @include lions-font-size('2xl'); }
    h3 { @include lions-font-size('xl'); }
    h4 { @include lions-font-size('lg'); }
    h5 { @include lions-font-size('base'); }
    h6 { @include lions-font-size('sm'); }

    p {
      margin-bottom: $lions-spacing-3;
    }

    a {
      color: $lions-blue-600;
      text-decoration: underline;

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

    ul, ol {
      margin-left: $lions-spacing-6;
      margin-bottom: $lions-spacing-3;
    }

    li {
      margin-bottom: $lions-spacing-1;
    }

    blockquote {
      border-left: 4px solid $lions-blue-500;
      padding-left: $lions-spacing-4;
      margin-left: 0;
      margin-bottom: $lions-spacing-3;
      color: $lions-gray-600;
      font-style: italic;
    }

    pre {
      background: $lions-gray-100;
      @include lions-rounded('md');
      padding: $lions-spacing-4;
      margin-bottom: $lions-spacing-3;
      overflow-x: auto;
      font-family: $lions-font-family-mono;
      @include lions-font-size('sm');
    }

    code {
      background: $lions-gray-100;
      padding: $lions-spacing-1 $lions-spacing-2;
      @include lions-rounded('sm');
      font-family: $lions-font-family-mono;
      @include lions-font-size('sm');
      color: $lions-danger-600;
    }

    img {
      max-width: 100%;
      height: auto;
      @include lions-rounded('md');
      margin: $lions-spacing-3 0;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: $lions-spacing-3;

      th, td {
        border: 1px solid $lions-gray-300;
        padding: $lions-spacing-3;
        text-align: left;
      }

      th {
        background: $lions-gray-100;
        @include lions-font-weight('semibold');
      }
    }
  }

  // Focused state
  &.ui-state-focus {
    border-color: $lions-blue-500;
    box-shadow: 0 0 0 3px rgba($lions-blue-500, 0.15);
  }

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

    .ui-editor-toolbar,
    .ui-editor-content {
      pointer-events: none;
    }
  }

  // Size variants
  &.ui-editor-sm {
    .ui-editor-toolbar {
      padding: $lions-spacing-2;
    }

    .ui-editor-toolbar-button {
      width: 1.75rem;
      height: 1.75rem;
      min-width: 1.75rem;

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

    .ui-editor-content {
      min-height: 150px;
      padding: $lions-spacing-3;
      @include lions-font-size('sm');
    }
  }

  &.ui-editor-lg {
    .ui-editor-toolbar {
      padding: $lions-spacing-4;
    }

    .ui-editor-toolbar-button {
      width: 2.5rem;
      height: 2.5rem;
      min-width: 2.5rem;

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

    .ui-editor-content {
      min-height: 300px;
      padding: $lions-spacing-5;
      @include lions-font-size('lg');
    }
  }
}

// ============================================
// 📂 FILE UPLOAD STYLES
// ============================================

.ui-fileupload {
  display: block;
  width: 100%;
  @include lions-rounded('lg');
  border: 1px solid $lions-gray-300;
  background: $lions-white;
  overflow: hidden;

  .ui-fileupload-buttonbar {
    display: flex;
    gap: $lions-spacing-3;
    padding: $lions-spacing-4;
    background: $lions-gray-50;
    border-bottom: 1px solid $lions-gray-200;
  }

  .ui-fileupload-choose {
    @include lions-button-primary;
  }

  .ui-fileupload-upload,
  .ui-fileupload-cancel {
    @include lions-button-base;
    padding: $lions-spacing-3 $lions-spacing-5;
    @include lions-rounded('md');
    @include lions-font-weight('semibold');
    @include lions-transition();
  }

  .ui-fileupload-upload {
    background: $lions-success-500;
    color: $lions-white;

    &:hover {
      background: $lions-success-600;
    }
  }

  .ui-fileupload-cancel {
    background: $lions-gray-200;
    color: $lions-gray-700;

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

  .ui-fileupload-content {
    padding: $lions-spacing-4;
  }

  .ui-fileupload-files {
    display: flex;
    flex-direction: column;
    gap: $lions-spacing-3;
  }

  .ui-fileupload-row {
    display: flex;
    align-items: center;
    gap: $lions-spacing-3;
    padding: $lions-spacing-3;
    @include lions-rounded('md');
    background: $lions-gray-50;
    border: 1px solid $lions-gray-200;
    @include lions-transition();

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

  .ui-fileupload-filename {
    flex: 1;
    @include lions-font-size('sm');
    @include lions-font-weight('medium');
    color: $lions-text-primary;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-fileupload-size {
    @include lions-font-size('xs');
    color: $lions-gray-600;
  }

  .ui-fileupload-remove {
    @include lions-button-base;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    padding: 0;
    @include lions-flex-center;
    background: transparent;
    border: 1px solid $lions-gray-300;
    @include lions-rounded('md');
    color: $lions-danger-600;
    cursor: pointer;
    @include lions-transition();

    &:hover {
      background: $lions-danger-50;
      border-color: $lions-danger-300;
    }

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

  // Drag & Drop zone
  &.ui-fileupload-advanced {
    .ui-fileupload-content {
      position: relative;
      min-height: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 2px dashed $lions-gray-300;
      @include lions-rounded('lg');
      margin: $lions-spacing-4;
      @include lions-transition();

      &.ui-fileupload-highlight {
        border-color: $lions-blue-500;
        background: rgba($lions-blue-50, 0.5);
      }
    }

    .ui-fileupload-empty {
      text-align: center;
      padding: $lions-spacing-6;

      .ui-fileupload-drag-icon {
        font-size: 3rem;
        color: $lions-gray-400;
        margin-bottom: $lions-spacing-3;
      }

      .ui-fileupload-drag-text {
        @include lions-font-size('base');
        color: $lions-gray-600;
        margin-bottom: $lions-spacing-2;
      }

      .ui-fileupload-drag-hint {
        @include lions-font-size('sm');
        color: $lions-gray-500;
      }
    }
  }

  // Progress bar
  .ui-fileupload-progress {
    height: 0.5rem;
    @include lions-rounded('full');
    background: $lions-gray-200;
    overflow: hidden;
    margin-top: $lions-spacing-2;

    .ui-fileupload-progress-bar {
      height: 100%;
      @include lions-gradient-blue;
      @include lions-transition();
    }
  }
}

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

@media (max-width: $lions-breakpoint-md) {
  .ui-editor {
    .ui-editor-toolbar {
      padding: $lions-spacing-2;
    }

    .ui-editor-toolbar-button {
      width: 1.75rem;
      height: 1.75rem;
      min-width: 1.75rem;
    }

    .ui-editor-content {
      min-height: 150px;
    }
  }

  .ui-fileupload {
    .ui-fileupload-buttonbar {
      flex-wrap: wrap;
    }

    &.ui-fileupload-advanced .ui-fileupload-content {
      min-height: 150px;
    }
  }

  .ui-colorpicker-panel {
    .ui-colorpicker-color-selector {
      width: 150px;
      height: 120px;
    }
  }
}

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

.ui-spinner,
.ui-inputmask,
.ui-chips,
.ui-colorpicker,
.ui-editor,
.ui-fileupload {
  // Focus visible
  &:focus-visible,
  .ui-state-focus {
    @include lions-focus-ring();
  }

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

    button,
    .ui-button {
      border-width: 2px !important;
    }
  }

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