/* ZHAGA-25-AI - Design Responsive
   Adaptatif: PC · Tablette · Smartphone */

/* ═══════════════════════════════════════════════════════════
   RTL TEXT SUPPORT (Arabic only - structure stays LTR)
   ═══════════════════════════════════════════════════════════ */

/* Appliquer RTL UNIQUEMENT au texte, JAMAIS à la structure */
/* La plateforme reste toujours gauche-à-droite (LTR) */
/* Dashboard/Menu TOUJOURS à gauche même en arabe */

/* Forcer TOUS les conteneurs structurels en LTR */
body.rtl-text,
body.rtl-text *,
body.rtl-text header,
body.rtl-text nav,
body.rtl-text .header-content,
body.rtl-text .stats-bar,
body.rtl-text .nav-menu,
body.rtl-text .container,
body.rtl-text .card,
body.rtl-text .form-grid,
body.rtl-text .grid-2,
body.rtl-text .grid-3,
body.rtl-text .view,
body.rtl-text .menu-item,
body.rtl-text .button-group {
  direction: ltr !important;
}

/* S'assurer que le menu reste à gauche */
body.rtl-text .nav-menu {
  text-align: left !important;
}

body.rtl-text .menu-item {
  justify-content: flex-start !important;
}

/* RTL UNIQUEMENT pour le texte affiché */
body.rtl-text p,
body.rtl-text h1, body.rtl-text h2, body.rtl-text h3, body.rtl-text h4,
body.rtl-text label,
body.rtl-text span:not(.byte):not(.stat),
body.rtl-text button,
body.rtl-text option {
  direction: rtl;
  text-align: right;
}

/* Exceptions: garder LTR pour valeurs numériques et techniques */
body.rtl-text input[type="number"],
body.rtl-text input[type="range"],
body.rtl-text code,
body.rtl-text pre {
  direction: ltr;
  text-align: left;
}

/* ═══════════════════════════════════════════════════════════
   DÉTECTION DEVICE & VARIABLES
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Breakpoints */
  --mobile-max: 768px;
  --tablet-min: 769px;
  --tablet-max: 1024px;
  --desktop-min: 1025px;

  /* Spacing adaptatif */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Font sizes adaptatif */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-md: 1rem;
  --font-lg: 1.25rem;
  --font-xl: 1.5rem;
  --font-xxl: 2rem;

  /* Touch targets */
  --touch-target-min: 44px; /* Apple HIG */
  --touch-target-comfortable: 48px; /* Material Design */
}

/* ═══════════════════════════════════════════════════════════
   BASE - MOBILE FIRST
   ═══════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-size: var(--font-md);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* Supprimé - retour aux grilles adaptatives */

/* Container adaptatif */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-sm);
}

/* Assurer que tous les éléments sont responsive */
img, video, canvas, iframe {
  max-width: 100%;
  height: auto;
}

/* Tables responsive */
table {
  width: 100%;
  overflow-x: auto;
  display: block;
}

@media (max-width: 768px) {
  table {
    font-size: 0.85rem;
  }

  table td, table th {
    padding: 0.5rem !important;
  }
}

/* Formulaires adaptatifs */
input, select, textarea {
  max-width: 100%;
  width: 100%;
}

/* Boutons adaptatifs */
button {
  min-width: 0;
  word-wrap: break-word;
}

/* ═══════════════════════════════════════════════════════════
   HEADER RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

/* Header luxe 56px une ligne */
header {
  margin: 0 !important;
  padding: 0 !important;
}

.header-content {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  height: 56px !important;
  max-height: 56px !important;
  padding: 0 1.25rem !important;
  gap: 12px !important;
  flex-wrap: nowrap !important;
  margin: 0 !important;
}

/* Logo rond luxe 40px */
.logo-circle {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: -0.5px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(6,182,212,0.4);
}

/* LED Pass/Fail - 8px inline */
#pass-fail-led {
  width: 8px !important;
  height: 8px !important;
  min-width: 8px !important;
  min-height: 8px !important;
  border-radius: 50%;
  transition: all 0.3s;
  flex-shrink: 0;
}

/* File input caché */
input[type="file"] {
  display: none !important;
}

/* Drop Zone Premium */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  border: 2px dashed #0891b2;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
}

.drop-zone:hover {
  background: rgba(8,145,178,0.1);
  border-color: #06b6d4;
  transform: translateY(-2px);
}

.drop-icon {
  font-size: 2.5rem;
  margin-bottom: 4px;
  filter: grayscale(20%);
}

.drop-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.drop-sub {
  font-size: 0.875rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.drop-btn {
  background: #0891b2;
  color: white;
  padding: 10px 28px;
  border-radius: 8px;
  font-weight: 600;
  margin-top: 8px;
  transition: all 0.3s;
  font-size: 0.95rem;
}

.drop-zone:hover .drop-btn {
  background: #06b6d4;
  box-shadow: 0 4px 12px rgba(8,145,178,0.3);
  transform: translateY(-1px);
}

/* Scan Section - Lecture Sans Contact */
.scan-section {
  margin-bottom: 2rem;
}

.scan-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.scan-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  border-radius: 12px;
  border: 2px solid;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  font-family: 'Inter', sans-serif;
}

.scan-btn.nfc {
  border-color: #0891b2;
  color: #0891b2;
}

.scan-btn.ble {
  border-color: #6366f1;
  color: #6366f1;
}

.scan-btn:hover {
  background: rgba(255,255,255,0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.scan-btn.nfc:hover {
  box-shadow: 0 4px 12px rgba(8,145,178,0.3);
}

.scan-btn.ble:hover {
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.scan-btn.scanning {
  animation: pulse-scan 1s infinite;
}

@keyframes pulse-scan {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

.scan-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.scan-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.scan-sub {
  font-size: 11px;
  opacity: 0.7;
}

.scan-status {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
}

.scan-status.hidden {
  display: none;
}

.scan-status.scanning {
  background: rgba(8,145,178,0.1);
  color: #0891b2;
  border-left: 3px solid #0891b2;
}

.scan-status.success {
  background: rgba(16,185,129,0.1);
  color: #10b981;
  border-left: 3px solid #10b981;
}

.scan-status.error {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border-left: 3px solid #ef4444;
}

/* ═══════════════════════════════════════════════════════════
   OPTIMISATION SMARTPHONE (< 480px) - QUALITÉ MAXIMALE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* Header compact une ligne */
  .header-content {
    padding: 0.5rem 0.75rem !important;
    gap: 0.5rem !important;
  }

  /* Logo rond petit sur mobile */
  .logo-circle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    min-height: 32px;
    font-size: 0.6rem !important;
  }

  /* LED Status 8px */
  #pass-fail-led {
    width: 8px !important;
    height: 8px !important;
  }

  /* Titre compact */
  .header-content span {
    font-size: 0.9rem !important;
  }

  /* Espacement confortable */
  .container {
    padding: 0.75rem;
  }

  .card {
    padding: 1rem;
    margin-bottom: 0.875rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  /* Titres lisibles */
  .card h2 {
    font-size: 1.15rem;
    margin-bottom: 0.875rem;
    font-weight: 600;
  }

  .card h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    margin-top: 1.25rem;
    font-weight: 600;
    color: #06b6d4;
  }

  /* Labels et inputs bien espacés */
  label {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    display: block;
    font-weight: 500;
  }

  input,
  select,
  textarea {
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.875rem;
    font-size: 16px; /* Empêche zoom iOS */
  }

  /* Boutons touch-friendly */
  button {
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    min-height: 48px;
    font-weight: 600;
    margin: 0.25rem 0;
    font-size: 16px; /* Empêche zoom iOS */
  }

  /* Menu items plus accessibles */
  .menu-item {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
    min-height: 48px;
    border-radius: 8px;
    margin: 0.125rem 0;
  }

  /* Stats bar responsive */
  .stats-bar {
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .stat {
    font-size: 0.8rem;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
  }

  /* Grilles avec gap optimal */
  .form-grid,
  .grid-2,
  .grid-3 {
    gap: 0.875rem;
  }
}

.stats-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  justify-content: center;
  font-size: var(--font-sm);
}

.stat {
  white-space: nowrap;
  font-size: 0.8rem;
}

@media (max-width: 480px) {
  .stat {
    font-size: 0.7rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   NAVIGATION MOBILE
   ═══════════════════════════════════════════════════════════ */

nav {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

nav::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.nav-menu {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm);
  min-width: min-content;
}

.menu-item {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-sm);
  min-height: var(--touch-target-comfortable);
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 8px;
  transition: all 0.2s ease;
}

/* Menu hamburger (mobile uniquement) */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 1001;
  font-size: 24px;
  color: white;
  transition: transform 0.3s ease;
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════
   CARDS & FORMS
   ═══════════════════════════════════════════════════════════ */

.card {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border-radius: 12px;
  overflow: hidden; /* Empêcher débordement */
}

@media (max-width: 480px) {
  .card {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border-radius: 8px;
  }
}

.card h2 {
  font-size: var(--font-lg);
  margin-bottom: var(--spacing-sm);
  word-wrap: break-word;
}

.card h3 {
  font-size: var(--font-md);
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  word-wrap: break-word;
}

@media (max-width: 480px) {
  .card h2 {
    font-size: var(--font-md);
  }

  .card h3 {
    font-size: var(--font-sm);
  }
}

/* Grilles adaptatives - Responsive */
.form-grid,
.grid-2,
.grid-3 {
  display: grid;
  gap: var(--spacing-sm);
  width: 100%;
}

@media (max-width: 480px) {
  .form-grid,
  .grid-2,
  .grid-3 {
    gap: var(--spacing-xs);
  }
}

/* Groupes de formulaire verticaux */
.form-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.form-group label {
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

/* Inputs touch-friendly */
input,
select,
textarea,
button {
  min-height: var(--touch-target-comfortable);
  font-size: var(--font-md);
  padding: var(--spacing-sm);
  border-radius: 8px;
}

@media (max-width: 480px) {
  input,
  select,
  textarea {
    font-size: 16px; /* Empêche zoom auto sur iOS */
    padding: 0.6rem;
  }
}

button {
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 480px) {
  button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}

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

/* ═══════════════════════════════════════════════════════════
   DASHBOARDS & CHARTS
   ═══════════════════════════════════════════════════════════ */

canvas {
  max-width: 100%;
  height: auto !important;
  touch-action: pan-y; /* Permet scroll vertical mais pas zoom */
}

/* Conteneurs graphiques */
#dimming-chart,
#ntc-chart,
#hcl-chart,
#counter-chart {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════
   UTILITAIRES
   ═══════════════════════════════════════════════════════════ */

/* Cacher sur mobile */
.hide-mobile {
  display: none;
}

/* Afficher uniquement sur mobile */
.show-mobile {
  display: block;
}

/* Scroll horizontal smooth */
.horizontal-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Touch feedback */
.touch-feedback:active {
  opacity: 0.7;
  transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════════
   PETIT MOBILE (< 480px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  :root {
    --font-sm: 0.75rem;
    --font-md: 0.875rem;
    --font-lg: 1rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
  }

  .container {
    padding: 0.5rem;
  }

  .nav-menu {
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .menu-item {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  /* Masquer textes longs sur petit écran */
  .hide-xs {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   TABLETTE (Portrait 769px - 1024px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --font-md: 1rem;
    --font-lg: 1.375rem;
    --font-xl: 1.75rem;
  }

  .container {
    padding: var(--spacing-md);
  }

  .header-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .stats-bar {
    justify-content: flex-end;
  }

  .nav-menu {
    justify-content: center;
  }

  /* Grilles multi-colonnes */
  .form-grid,
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Cacher éléments mobile */
  .hide-tablet {
    display: none;
  }

  .show-tablet {
    display: block;
  }
}

/* ═══════════════════════════════════════════════════════════
   TABLETTE PAYSAGE & PETIT DESKTOP (1025px - 1280px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1025px) and (max-width: 1280px) {
  .container {
    padding: var(--spacing-lg);
  }

  .header-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  /* Grilles multi-colonnes */
  .form-grid,
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .hide-mobile,
  .hide-tablet {
    display: block;
  }

  .show-mobile {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   DESKTOP (> 1280px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1281px) {
  :root {
    --font-md: 1rem;
    --font-lg: 1.5rem;
    --font-xl: 2rem;
    --font-xxl: 2.5rem;
  }

  .container {
    padding: var(--spacing-xl);
  }

  .header-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .logo {
    font-size: var(--font-xl);
    text-align: left;
  }

  .stats-bar {
    font-size: var(--font-md);
    gap: var(--spacing-md);
  }

  .nav-menu {
    gap: var(--spacing-sm);
  }

  .menu-item {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-md);
  }

  /* Grilles multi-colonnes */
  .form-grid,
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .card {
    padding: var(--spacing-lg);
  }

  /* Cacher éléments mobile/tablette */
  .hide-desktop {
    display: none;
  }

  .show-desktop {
    display: block;
  }

  .hide-mobile,
  .hide-tablet {
    display: block;
  }

  .show-mobile,
  .show-tablet {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   TRÈS GRAND ÉCRAN (> 1920px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1921px) {
  .container {
    max-width: 1800px;
  }

  /* Grilles restent verticales même en très grand écran */
  .form-grid,
  .grid-2,
  .grid-3 {
    display: flex;
    flex-direction: column;
  }
}

/* ═══════════════════════════════════════════════════════════
   ORIENTATION PAYSAGE (MOBILE)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) and (orientation: landscape) {
  header {
    position: relative; /* Libérer espace vertical */
  }

  .nav-menu {
    padding: var(--spacing-xs);
  }

  .menu-item {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-xs);
  }

  .card {
    padding: var(--spacing-sm);
  }

  /* Grilles multi-colonnes */
  .form-grid,
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════ */

@media print {
  header,
  nav,
  .mobile-menu-toggle,
  button {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .card {
    page-break-inside: avoid;
    border: 1px solid #000;
  }

  body {
    background: white;
    color: black;
  }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE (Préférence système)
   ═══════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  /* Déjà géré par variables CSS, mais on peut ajouter des ajustements */
  img,
  canvas {
    filter: brightness(0.9);
  }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION (Accessibilité)
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   HIGH CONTRAST (Accessibilité)
   ═══════════════════════════════════════════════════════════ */

@media (prefers-contrast: high) {
  button,
  .menu-item {
    border: 2px solid currentColor;
  }

  .card {
    border: 2px solid var(--border);
  }
}

/* ═══════════════════════════════════════════════════════════
   TOUCH DEVICE OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
  /* Appareil tactile */

  button,
  .menu-item,
  input,
  select {
    min-height: 48px; /* Plus grand pour touch */
  }

  /* Espacement augmenté entre éléments cliquables */
  .nav-menu {
    gap: var(--spacing-sm);
  }

  /* Feedback visuel amélioré */
  button:active,
  .menu-item:active {
    transform: scale(0.95);
    opacity: 0.8;
  }

  /* Désactiver hover effects */
  *:hover {
    /* Hover ne fonctionne pas bien sur tactile */
  }
}

/* ═══════════════════════════════════════════════════════════
   CLASSES UTILITAIRES POUR MOBILE-FIRST
   ═══════════════════════════════════════════════════════════ */

/* Boutons en ligne sur desktop, verticaux sur mobile */
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

/* Cartes/grilles responsive */
.mobile-stack {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Grilles responsive selon écran */

/* Sur mobile, forcer TOUT en vertical et optimiser UX */
@media (max-width: 768px) {
  /* Header et stats toujours verticaux sur mobile */
  .header-content {
    flex-direction: column !important;
  }

  .stats-bar {
    justify-content: center !important;
    width: 100%;
  }

  /* Boutons adaptés mobile */
  button,
  .btn {
    min-height: 48px;
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
  }

  /* Inputs plus larges et accessibles */
  input,
  select,
  textarea {
    width: 100%;
    min-height: 48px;
    font-size: 16px; /* Empêche zoom auto iOS */
    padding: 0.875rem;
  }

  /* Labels plus visibles */
  label {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
  }

  /* Cartes avec padding confortable */
  .card {
    padding: 1.25rem;
    margin-bottom: 1rem;
  }

  /* Titres adaptés mobile */
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  /* Menu plus accessible */
  .menu-item {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    min-height: 44px;
  }

  /* Stats bar responsive */
  .stat {
    font-size: 0.85rem;
    padding: 0.5rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   MOUSE/TRACKPAD OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════ */

@media (hover: hover) and (pointer: fine) {
  /* Appareil avec souris/trackpad */

  button:hover,
  .menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }

  /* Scroll bars personnalisés */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--bg);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
  }
}

/* ═══════════════════════════════════════════════════════════
   SAFE AREA (iPhone X+ notch)
   ═══════════════════════════════════════════════════════════ */

@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: env(safe-area-inset-top);
  }

  .container {
    padding-left: max(var(--spacing-sm), env(safe-area-inset-left));
    padding-right: max(var(--spacing-sm), env(safe-area-inset-right));
    padding-bottom: max(var(--spacing-sm), env(safe-area-inset-bottom));
  }

  .mobile-menu-toggle {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
  }
}

/* ═══════════════════════════════════════════════════════════
   PWA STANDALONE MODE
   ═══════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
  /* App installée comme PWA */

  body {
    user-select: none; /* Empêche sélection texte accidentelle */
    -webkit-user-select: none;
  }

  input,
  textarea {
    user-select: text; /* Réactiver pour inputs */
    -webkit-user-select: text;
  }
}

/* ═══════════════════════════════════════════════════════════
   PERFORMANCES MOBILE
   ═══════════════════════════════════════════════════════════ */

/* GPU acceleration pour animations fluides */
.menu-item,
button,
.card {
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Optimisation images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Lazy loading natif */
img[loading="lazy"] {
  content-visibility: auto;
}
