html {
  font-size: 16px; /* Augmenté de 14px pour meilleure lisibilité mobile */
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ========================================
   🎯 RESPONSIVE MOBILE - OPTIMISATIONS GLOBALES
   ======================================== */

/* Conteneur principal responsive */
.container, .container-fluid {
  padding-left: 15px !important;
  padding-right: 15px !important;
}

/* Navigation mobile améliorée */
@media (max-width: 767px) {
  /* Taille de police augmentée pour mobile */
  html {
    font-size: 18px;
  }

  /* Navbar optimisée pour mobile */
  .navbar {
    padding: 10px 15px;
  }

  .navbar-brand {
    font-size: 1.2rem;
  }

  .navbar-collapse {
    background: white;
    padding: 15px;
    margin-top: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }

  .nav-link {
    padding: 12px 15px !important;
    font-size: 1rem;
    border-bottom: 1px solid #f0f0f0;
  }

  .nav-link:last-child {
    border-bottom: none;
  }

  /* Boutons de navigation plus grands */
  .navbar-nav .btn {
    width: 100%;
    margin: 8px 0;
    padding: 12px;
    font-size: 1rem;
  }

  /* Dropdown menu mobile */
  .dropdown-menu {
    position: static !important;
    transform: none !important;
    width: 100%;
    border: none;
    box-shadow: none;
    background: #f8f9fa;
    margin-top: 5px;
  }

  .dropdown-item {
    padding: 12px 20px;
    font-size: 1rem;
  }

  /* Formulaires responsive */
  form[method="get"] {
    display: block !important;
  }

  form[method="get"] > div {
    flex-direction: column !important;
    gap: 15px !important;
  }

  form[method="get"] > div > div {
    flex: none !important;
    width: 100% !important;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    width: 100% !important;
    padding: 14px !important;
    font-size: 16px !important; /* Évite le zoom auto sur iOS */
    border-radius: 8px !important;
    box-sizing: border-box !important;
  }

  /* Boutons responsive */
  button,
  .btn,
  a.btn {
    min-height: 44px; /* Taille tactile recommandée */
    padding: 12px 20px;
    font-size: 1rem;
    width: 100%;
    margin: 8px 0;
  }

  /* Grilles responsive */
  .stats-container,
  .actions-grid,
  .row,
  [style*="display: grid"],
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
  }

  .col-md-3,
  .col-md-4,
  .col-md-6,
  .col-md-8,
  .col-md-12 {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* Cartes responsive */
  .stat-card,
  .dashboard-card,
  .employee-card,
  .pharmacie-card,
  .action-btn {
    width: 100% !important;
    margin-bottom: 15px !important;
    min-width: auto !important;
  }

  /* Texte responsive */
  h1, .hero-title {
    font-size: 2rem !important;
  }

  h2 {
    font-size: 1.5rem !important;
  }

  h3 {
    font-size: 1.3rem !important;
  }

  h4 {
    font-size: 1.1rem !important;
  }

  p, span, div {
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }

  /* Tableaux responsive avec défilement horizontal */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
  }

  table {
    min-width: 100%;
    font-size: 0.9rem;
  }

  th, td {
    padding: 12px 8px !important;
    white-space: nowrap;
  }

  /* Badges et labels */
  .badge,
  .score-badge,
  .stat-change {
    font-size: 0.9rem !important;
    padding: 6px 12px !important;
  }

  /* Actions groupées */
  .d-flex {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .d-flex.gap-2 > *,
  .d-flex[style*="gap"] > * {
    width: 100% !important;
    margin: 5px 0 !important;
  }

  /* Marges et paddings ajustés */
  [style*="padding: 30px"],
  [style*="padding: 40px"] {
    padding: 20px !important;
  }

  [style*="padding: 50px"] {
    padding: 25px !important;
  }

  /* Stats cards empilées */
  .stats-card {
    margin-bottom: 12px !important;
  }

  /* Actions rapides */
  .actions-section {
    padding: 0 15px !important;
  }

  /* Ajustement des grilles inline */
  [style*="display: flex; gap"] {
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Meilleure gestion des images */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Footer responsive */
  .footer {
    padding: 20px 15px;
    font-size: 0.9rem;
    text-align: center;
  }

  /* Masquer les éléments décoratifs sur mobile */
  .floating-elements,
  .floating-element {
    display: none !important;
  }

  /* Live indicator repositionné */
  .live-indicator {
    position: fixed;
    top: auto;
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    padding: 8px 12px;
    z-index: 9999;
  }

  /* Hero section ajustée */
  .hero-section {
    padding: 20px 0 !important;
  }

  .hero-subtitle {
    font-size: 1rem !important;
  }

  /* Meilleure gestion du scroll */
  body {
    overflow-x: hidden;
  }

  /* Cards avec overflow */
  .pharmacie-card,
  .employee-card,
  .dashboard-card {
    overflow: hidden;
    word-wrap: break-word;
  }

  /* Boutons d'action côte à côte si nécessaire */
  .btn-group-mobile {
    display: flex;
    flex-direction: row;
    gap: 8px;
  }

  .btn-group-mobile > * {
    flex: 1;
    width: auto !important;
  }

  /* Amélioration de la zone de clic */
  a, button, .btn, input[type="submit"], input[type="button"] {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  }

  /* Espacement vertical entre sections */
  section, .section, .card, .dashboard-card {
    margin-bottom: 20px;
  }

  /* Typographie améliorée */
  * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Fix pour les modales */
  .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .modal-body {
    padding: 20px 15px;
  }

  /* Fix pour les alertes */
  .alert {
    margin: 15px 10px;
    padding: 15px;
    font-size: 1rem;
  }
}

/* ========================================
   📱 TABLETTES (768px - 991px)
   ======================================== */
@media (min-width: 768px) and (max-width: 991px) {
  .col-md-3 {
    width: 50% !important;
  }

  .col-md-6 {
    width: 100% !important;
  }

  .stats-container,
  .actions-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ========================================
   🎨 AMÉLIORATIONS ACCESSIBILITÉ
   ======================================== */

/* Meilleur contraste pour les liens */
a {
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover, a:focus {
  text-decoration: underline;
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Focus visible pour navigation clavier */
*:focus-visible {
  outline: 3px solid #007bff;
  outline-offset: 2px;
}

/* Amélioration des transitions */
* {
  transition: all 0.2s ease;
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* ========================================
   🔐 BOUTONS MOT DE PASSE (CADENAS) - OPTIMISATION MOBILE
   ======================================== */

/* Conteneur du champ mot de passe avec bouton */
.password-field-container {
  position: relative;
  width: 100%;
}

/* Style de base pour les inputs de mot de passe */
.password-input {
  width: 100% !important;
  padding: 12px 65px 12px 12px !important; /* Desktop: 65px à droite pour le bouton */
  border-radius: 8px !important;
  font-size: 16px !important; /* Évite le zoom auto sur iOS */
  box-sizing: border-box !important;
  transition: all 0.3s ease;
}

/* Bouton toggle password - Style de base (Desktop) */
.toggle-password-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -22px; /* Remplace transform pour éviter les artefacts */
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;  /* Taille tactile recommandée */
  height: 44px; /* Taille tactile recommandée */
  min-width: 44px;
  min-height: 44px;
  color: #6c757d;
  z-index: 100;
  pointer-events: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.toggle-password-btn:hover {
  background: rgba(255, 255, 255, 1);
  border-color: #007bff;
  color: #007bff;
  transform: scale(1.05);
}

.toggle-password-btn:active {
  transform: scale(0.95);
  background: rgba(0, 123, 255, 0.1);
}

/* ========================================
   📱 RESPONSIVE MOBILE - BOUTONS CADENAS
   ======================================== */

/* Smartphones et petits écrans (< 768px) */
@media (max-width: 767px) {
  /* Input avec padding optimisé pour mobile */
  .password-input {
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 14px !important;
    padding-right: 90px !important; /* Mobile: 90px à droite - TRÈS LARGE ESPACE */
    font-size: 16px !important; /* CRUCIAL pour éviter le zoom iOS */
    box-sizing: border-box !important;
  }

  /* Bouton cadenas optimisé pour mobile - COLLÉ AU BORD DROIT */
  .toggle-password-btn {
    right: 2px !important; /* COLLÉ au bord droit */
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin-top: -22px !important;
    font-size: 20px !important;
    border: 2px solid #999 !important; /* Bordure bien visible */
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important; /* Ombre forte */
    background: #ffffff !important; /* Fond blanc pur */
  }

  /* Amélioration du hover/tap sur mobile */
  .toggle-password-btn:hover,
  .toggle-password-btn:active {
    background: #e3f2fd !important;
    border-color: #007bff !important;
    color: #007bff !important;
    box-shadow: 0 3px 12px rgba(0, 123, 255, 0.5) !important;
  }
}

/* Très petits écrans (< 375px) - Ex: iPhone SE */
@media (max-width: 374px) {
  .password-input {
    padding-right: 85px !important; /* Padding augmenté pour petits écrans */
  }

  .toggle-password-btn {
    right: 2px !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    margin-top: -21px !important;
    font-size: 18px !important;
  }
}

/* Écrans moyens (375px - 480px) - Ex: iPhone 12, 13, 14 */
@media (min-width: 375px) and (max-width: 480px) {
  .password-input {
    padding-right: 92px !important;
  }

  .toggle-password-btn {
    right: 2px !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    margin-top: -23px !important;
    font-size: 22px !important;
  }
}

/* ========================================
   🎯 CLASSES SUPPLÉMENTAIRES POUR VARIANTS
   ======================================== */

/* Variant pour pages de changement de mot de passe (3 champs) */
.password-input-change {
  width: 100% !important;
  padding: 12px 65px 12px 12px !important;
  border-radius: 8px !important;
  font-size: 16px !important;
  box-sizing: border-box !important;
  transition: all 0.3s ease;
}

@media (max-width: 767px) {
  .password-input-change {
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 14px !important;
    padding-right: 90px !important; /* Cohérent avec .password-input */
    box-sizing: border-box !important;
  }
}

@media (max-width: 374px) {
  .password-input-change {
    padding-right: 85px !important;
  }
}

@media (min-width: 375px) and (max-width: 480px) {
  .password-input-change {
    padding-right: 92px !important;
  }
}

/* Variant pour le bouton sur pages de changement de mot de passe */
.toggle-password-btn-change {
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -22px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  color: #6c757d;
  z-index: 100;
  pointer-events: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
  .toggle-password-btn-change {
    right: 2px !important; /* COLLÉ au bord droit */
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin-top: -22px !important;
    font-size: 20px !important;
    border: 2px solid #999 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
    background: #ffffff !important;
  }
}

@media (max-width: 374px) {
  .toggle-password-btn-change {
    right: 2px !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    margin-top: -21px !important;
    font-size: 18px !important;
  }
}

@media (min-width: 375px) and (max-width: 480px) {
  .toggle-password-btn-change {
    right: 2px !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    margin-top: -23px !important;
    font-size: 22px !important;
  }
}

/* Hover states pour tous les variants */
.toggle-password-btn-change:hover {
  background: rgba(255, 255, 255, 1);
  border-color: #007bff;
  color: #007bff;
  transform: scale(1.05);
}

.toggle-password-btn-change:active {
  transform: scale(0.95);
  background: rgba(0, 123, 255, 0.1);
}