// ========================
// GLOBAL STYLES SCSS
// ========================

@use 'variables' as *;
@use 'mixins' as *;

// Importation des polices Google Fonts
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

// Variables CSS pour les thèmes
:root {
  // Couleurs principales
  --primary-color: #{$primary-color};
  --primary-hover: #{$primary-hover};
  --secondary-color: #{$secondary-color};
  --accent-color: #{$accent-color};
  
  // Variables des thèmes - Light par défaut
  @each $property, $value in map-get($colors, light) {
    --#{$property}: #{$value};
  }
  
  // Transitions
  --transition-fast: #{$transition-fast};
  --transition-normal: #{$transition-normal};
  --transition-slow: #{$transition-slow};
  
  // Espacements
  --section-padding: #{$section-padding};
  --container-padding: #{$container-padding};
  --border-radius: #{$border-radius};
  --border-radius-large: #{$border-radius-large};
}

// Thème sombre
[data-theme="dark"] {
  @each $property, $value in map-get($colors, dark) {
    --#{$property}: #{$value};
  }
}

// Reset et base
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  @include custom-scrollbar();
}

body {
  font-family: $font-family;
  font-size: map-get($font-sizes, base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  @include transition(color background-color);
}

.app {
  min-height: 100vh;
  overflow-x: hidden;
}

// Amélioration des médias
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

// Amélioration des formulaires
input,
button,
textarea,
select {
  font: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

// Amélioration des liens
a {
  color: inherit;
  text-decoration: none;
}

// Amélioration des listes
ul,
ol {
  list-style: none;
}

// Amélioration des titres
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

// Amélioration des paragraphes
p {
  color: var(--text-secondary);
  max-width: 65ch;
}

// Classes globales pour les boutons
.btn {
  @include button-base();

  &-primary {
    @include button-primary();
  }

  &-secondary {
    @include button-secondary();
  }
}

// Classes utilitaires
.container {
  max-width: map-get($breakpoints, xl);
  margin: 0 auto;
  padding: var(--container-padding);

  @include respond-above(xxl) {
    max-width: 1400px;
  }
}

.section-header {
  text-align: center;
  margin-bottom: 60px;

  .section-title {
    font-size: map-get($font-sizes, 3xl);
    font-weight: 700;
    margin-bottom: 16px;
    @include gradient-text();

    @include respond-to(sm) {
      font-size: map-get($font-sizes, 2xl);
    }
  }

  .section-subtitle {
    font-size: map-get($font-sizes, lg);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
  }
}

// Classes d'accessibilité
.visually-hidden,
.sr-only {
  @include visually-hidden();
}

.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

// Focus pour l'accessibilité
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  @include focus-style();
}

// Amélioration de la sélection de texte
::selection {
  background-color: $primary-color;
  color: white;
  text-shadow: none;
}

::-moz-selection {
  background-color: $primary-color;
  color: white;
  text-shadow: none;
}

// Classes d'animation
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -30px, 0);
  }
  70% {
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

// Classes d'animation
.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.6s ease-out;
}

.animate-slide-in-left {
  animation: slideInFromLeft 0.6s ease-out;
}

.animate-slide-in-right {
  animation: slideInFromRight 0.6s ease-out;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.loading {
  pointer-events: none;
  opacity: 0.6;
}

.gpu-accelerated {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

// Amélioration pour les utilisateurs préférant les animations réduites
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

// Mode haut contraste
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-secondary: #333333;
    --bg-primary: #ffffff;
    --bg-secondary: #f0f0f0;
    --border-color: #666666;
  }
  
  [data-theme="dark"] {
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --border-color: #999999;
  }
}

// Support pour les très petits écrans
@include respond-to(xs) {
  :root {
    --container-padding: 0 12px;
  }
}

// Amélioration de l'impression
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a,
  a:visited {
    text-decoration: underline;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
  
  abbr[title]:after {
    content: " (" attr(title) ")";
  }
  
  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }
  
  thead {
    display: table-header-group;
  }
  
  tr,
  img {
    page-break-inside: avoid;
  }
  
  img {
    max-width: 100% !important;
  }
  
  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }
  
  h2,
  h3 {
    page-break-after: avoid;
  }
}