/* mobile.css - Styles optimisés pour mobile PWA GAIUS */

/* Responsive général */
@media (max-width: 768px) {
  body {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Ajuster les marges des containers */
  .MuiContainer-root {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  /* Boutons plus grands pour toucher mobile */
  .MuiButton-root {
    min-height: 44px !important;
    font-size: 14px !important;
  }

  /* Fab button positionnement */
  .MuiFab-root {
    position: fixed !important;
    bottom: 16px !important;
    right: 16px !important;
  }

  /* Tableaux scrollables horizontalement */
  .MuiDataGrid-root {
    font-size: 13px;
    overflow-x: auto;
  }

  /* Cards empilées avec espacement réduit */
  .MuiCard-root {
    margin-bottom: 12px;
  }

  /* AppBar fixe en haut */
  .MuiAppBar-root {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* Espacement pour AppBar fixe */
  body {
    padding-top: 64px;
  }

  /* Drawer fullscreen sur mobile */
  .MuiDrawer-paper {
    width: 85% !important;
    max-width: 300px !important;
  }

  /* Form fields plus grands */
  .MuiTextField-root {
    margin-bottom: 16px !important;
  }

  .MuiInputBase-input {
    font-size: 16px !important; /* Évite le zoom iOS */
  }

  /* Dialog fullscreen sur petit écran */
  .MuiDialog-paper {
    margin: 16px !important;
    max-height: calc(100% - 32px) !important;
  }

  /* Tabs scrollables */
  .MuiTabs-root {
    overflow-x: auto !important;
  }

  /* Liste items plus espacés */
  .MuiListItem-root {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  /* Chip plus petits */
  .MuiChip-root {
    font-size: 12px !important;
    height: 28px !important;
  }
}

/* iPhone safe area (encoche) */
@supports (padding: max(0px)) {
  body {
    padding-top: max(64px, env(safe-area-inset-top));
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  /* AppBar avec safe area */
  .MuiAppBar-root {
    padding-top: env(safe-area-inset-top) !important;
  }

  /* Bottom navigation avec safe area */
  .MuiBottomNavigation-root {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
}

/* Mode paysage */
@media (max-width: 768px) and (orientation: landscape) {
  body {
    padding-top: 48px; /* AppBar plus petite */
  }

  .MuiAppBar-root {
    min-height: 48px !important;
  }

  .MuiToolbar-root {
    min-height: 48px !important;
  }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Éléments cliquables plus grands */
  a, button, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects sur mobile */
  .MuiButtonBase-root:hover {
    background-color: transparent !important;
  }

  /* Active state visible */
  .MuiButtonBase-root:active {
    opacity: 0.7;
  }
}

/* Scroll comportement fluide */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Prévenir le zoom sur double-tap iOS */
* {
  touch-action: manipulation;
}

/* Loading skeletons */
.MuiSkeleton-root {
  background-color: rgba(0, 0, 0, 0.08);
}

/* Snackbar position mobile */
@media (max-width: 768px) {
  .MuiSnackbar-root {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
  }

  .MuiSnackbarContent-root {
    flex-grow: 1;
  }
}

/* Mode sombre (iOS) */
@media (prefers-color-scheme: dark) {
  /* Personnalisation future du mode sombre */
  body {
    background-color: #121212;
    color: #ffffff;
  }
}

/* Performance optimizations */
.MuiCard-root,
.MuiPaper-root {
  will-change: transform;
  backface-visibility: hidden;
}

/* Animation transitions fluides */
.MuiDrawer-paper {
  transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms !important;
}

/* Input focus visible */
.MuiInputBase-root.Mui-focused {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Pull to refresh indicator (optionnel) */
@media (max-width: 768px) {
  .ptr-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    color: #1976d2;
    z-index: 10;
    text-align: center;
    padding: 10px;
  }
}

/* Splash screen style (avant chargement) */
#root:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #1976d2;
}

#root:empty::after {
  content: "GAIUS";
  font-size: 32px;
  font-weight: bold;
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

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