// ============================================
// ANALYTICS THEME - Palette Orange/Ambre
// Identité visuelle historique modernisée
// ============================================

// === CSS Variables ===
.analytics-card {
  --analytics-primary: #f5a728;
  --analytics-secondary: #f59e0b;
  --analytics-hover: #fbbf24;
  --analytics-bg-light: #fcd34d;
  --analytics-bg-subtle: #fef3c7;
  --analytics-bg-row-hover: rgba(245, 167, 40, 0.08);
  --analytics-bg-row-selected: rgba(245, 167, 40, 0.15);
  --analytics-border-selected: #f5a728;

  // Shadows avec teinte orange/ambre
  --shadow-sm: 0 1px 2px rgba(245, 167, 40, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(245, 167, 40, 0.12), 0 2px 4px -2px rgba(245, 167, 40, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(245, 167, 40, 0.15), 0 4px 6px -4px rgba(245, 167, 40, 0.1);
  --shadow-glow: 0 0 20px rgba(245, 167, 40, 0.3);

  // Transitions fluides
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  // Border radius
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
}

// === Animations ===
@keyframes analytics-fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes analytics-slideIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes analytics-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 167, 40, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(245, 167, 40, 0);
  }
}

// === Card Container ===
.analytics-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(245, 167, 40, 0.1);
  animation: analytics-fadeIn var(--transition-slow) ease-out;
}

// === Table Styles ===
.analytics-table {
  // Table wrapper
  &-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-md);

    // Custom scrollbar
    &::-webkit-scrollbar {
      width: 6px;
    }
    &::-webkit-scrollbar-track {
      background: var(--analytics-bg-subtle);
      border-radius: var(--radius-full);
    }
    &::-webkit-scrollbar-thumb {
      background: var(--analytics-bg-light);
      border-radius: var(--radius-full);
      &:hover {
        background: var(--analytics-hover);
      }
    }
  }

  // Table element - Style aligné avec les autres tables du projet
  &.table {
    margin-bottom: 0;

    // Header sombre (comme table-dark du projet)
    thead {
      position: sticky;
      top: 0;
      z-index: 10;

      th {
        background: #3d4047;
        color: #fff;
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 0.75rem;
        border-bottom: none;
      }
    }

    // Body rows
    tbody {
      background: #fff;

      tr {
        cursor: pointer;
        transition: background-color var(--transition-fast);

        &:hover {
          background-color: rgba(0, 0, 0, 0.03);
        }

        // Hover state (depuis preview)
        &.analytics-row-hovered {
          background-color: var(--analytics-bg-row-hover);
          box-shadow: inset 3px 0 0 var(--analytics-hover);
        }

        // Selected state
        &.analytics-row-selected {
          background-color: var(--analytics-bg-row-selected);
          box-shadow: inset 3px 0 0 var(--analytics-primary);

          .analytics-badge {
            background: var(--analytics-primary);
          }
        }
      }
    }

    // Cells
    td, th {
      padding: 0.75rem;
      vertical-align: middle;
      border-bottom: 1px solid #e9ecef;
    }

    // Row number
    th[scope="row"] {
      color: #6c757d;
      font-weight: 500;
    }
  }
}

// === Code Tag ===
.analytics-code {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-radius: var(--radius-xs);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  color: #92400e;
  transition: all var(--transition-fast);

  tr:hover &,
  tr.analytics-row-selected &,
  tr.analytics-row-hovered & {
    background: linear-gradient(135deg, var(--analytics-bg-subtle) 0%, var(--analytics-bg-light) 100%);
    border-color: var(--analytics-primary);
    color: #b45309;
  }
}

// === Badge Pill ===
.analytics-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #78716c 0%, #57534e 100%);
  color: white;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);

  tr:hover & {
    background: linear-gradient(135deg, var(--analytics-primary) 0%, #ea580c 100%);
    transform: scale(1.05);
  }
}

// === Progress Bar ===
.analytics-progress {
  height: 6px;
  background: #fef3c7;
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-grow: 1;

  &-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--analytics-primary) 0%, #ea580c 100%);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow) ease-out;
    position: relative;

    // Effet brillant
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 50%;
      background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, transparent 100%);
      border-radius: var(--radius-full) var(--radius-full) 0 0;
    }
  }

  &-text {
    min-width: 45px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #92400e;
  }
}

// === Smartphone Frame Enhancement ===
.smartphone-container {
  &.analytics-mode {
    .smartphone-frame {
      box-shadow:
        0 25px 50px -12px rgba(245, 167, 40, 0.25),
        0 0 0 1px rgba(245, 167, 40, 0.08);
      transition: box-shadow var(--transition-normal);

      &:hover {
        box-shadow:
          0 25px 50px -12px rgba(245, 167, 40, 0.35),
          0 0 0 1px rgba(245, 167, 40, 0.15);
      }
    }

    // Animation d'entrée
    animation: analytics-fadeIn var(--transition-slow) ease-out;
  }
}

// === Chart Colors (pour référence JS) ===
// Palette dégradée orange → ambre → terre
// [
//   '#f5a728', // Orange primaire
//   '#f59e0b', // Ambre
//   '#d97706', // Ambre foncé
//   '#b45309', // Orange brûlé
//   '#92400e', // Terre de sienne
//   '#fbbf24', // Jaune doré
//   '#fcd34d', // Jaune clair
//   '#fde68a', // Crème
//   '#fef3c7', // Crème pâle
//   '#fffbeb', // Le plus clair
// ]

// === Empty State ===
.analytics-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: #b45309;

  i {
    font-size: 2.5rem;
    color: var(--analytics-bg-light);
    margin-bottom: 1rem;
    display: block;
  }

  p {
    margin: 0;
    font-size: 0.9rem;
  }
}

// === Chart Tooltip ===
.analytics-tooltip {
  background: white;
  border: 1px solid var(--analytics-bg-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);

  &-label {
    font-size: 0.75rem;
    color: #92400e;
    margin-bottom: 0.25rem;
  }

  &-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--analytics-primary);
  }
}
