/* ===== VARIABLES & RESET ===== */
:root {
  /* Palette colorée */
  --primary: #2196F3;
  --secondary: #4CAF50;
  --accent: #FF9800;
  --background: #FAFAFA;
  --text: #424242;
  --success: #8BC34A;
  --warning: #FFC107;
  --error: #F44336;
  
  /* Espacements (grid 8px) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-xxl: 32px;
  
  /* Animations */
  --transition: 0.3s ease;
  --border-radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--text);
  background-color: var(--background);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: var(--font-size-xxl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

p {
  margin-bottom: var(--spacing-md);
}

/* ===== UTILITAIRES ===== */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-accent { background-color: var(--accent); }

.hidden { display: none !important; }
.visible { display: block !important; }

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--transition);
}

.loading-spinner {
  text-align: center;
  color: white;
}

.loading-spinner i {
  font-size: var(--font-size-xxl);
  margin-bottom: var(--spacing-md);
  color: var(--accent);
}

.loading-spinner p {
  font-size: var(--font-size-lg);
  font-weight: 500;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ===== OVERLAY ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== OPTIMISATIONS PERFORMANCE ===== */
.modal-content,
.tool-card,
.icon-button {
  will-change: transform;
  transform: translateZ(0);
}

.detail-section,
.tool-card,
.modal-body {
  contain: layout style paint;
}

/* ===== ANIMATIONS ===== */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(2px);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== FOCUS VISIBLE ===== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== SELECTION ===== */
::selection {
  background: var(--primary);
  color: white;
}

/* ===== PRINT ===== */
@media print {
  .top-bar,
  .sidebar,
  .overlay,
  .loading-screen {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  * {
    box-shadow: none !important;
  }
}