/**
 * ============================================================
 * ACCESSIBILITE CSS - CarteDesFid
 * ============================================================
 * Ce fichier contient les styles pour l'accessibilite WCAG 2.1 AA
 * - Skip links
 * - Focus visible
 * - Contrastes ameliores
 * - Aria live regions
 * ============================================================
 */

/* ============================================================
   SKIP LINK
   ============================================================ */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-600);
  color: #fff;
  padding: 12px 24px;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  z-index: 10000;
  transition: top 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--primary-500);
  outline-offset: 2px;
}

.skip-link:hover {
  background: var(--primary-700);
  color: #fff;
  text-decoration: none;
}

/* ============================================================
   FOCUS VISIBLE - Styles ameliores pour navigation clavier
   ============================================================ */

/* Focus visible pour tous les elements interactifs */
*:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-600) 20%, transparent) !important;
}

/* Boutons - Focus visible */
.btn:focus-visible,
button:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-600) 20%, transparent) !important;
}

/* Liens - Focus visible */
a:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
  border-radius: 2px;
}

/* Inputs et selects - Focus visible */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 0 !important;
  border-color: var(--primary-600) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-600) 15%, transparent) !important;
}

/* Checkboxes et radios */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
}

/* Cards cliquables */
.card:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
}

/* Navigation sidebar - Focus visible */
.pc-link:focus-visible,
.pc-item a:focus-visible {
  outline: 3px solid var(--primary-500) !important;
  outline-offset: -2px !important;
  background-color: color-mix(in srgb, var(--primary-600) 10%, transparent) !important;
}

/* Modals - Focus visible sur elements interactifs */
.modal .btn:focus-visible,
.modal a:focus-visible,
.modal input:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
}

/* Bouton close - Focus visible */
.btn-close:focus-visible {
  outline: 3px solid var(--primary-600) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-600) 20%, transparent) !important;
}

/* Dropdown items */
.dropdown-item:focus-visible {
  outline: none !important;
  background-color: color-mix(in srgb, var(--primary-600) 5%, transparent) !important;
  color: var(--primary-700) !important;
}

/* Fallback pour navigateurs sans support :focus-visible */
@supports not selector(:focus-visible) {
  *:focus {
    outline: 3px solid var(--primary-600);
    outline-offset: 2px;
  }
}

/* ============================================================
   CONTRASTES AMELIORES
   ============================================================ */

/* Texte muted avec meilleur contraste (4.5:1 minimum) */
.text-muted {
  color: #5a6268 !important; /* Ratio ~5.5:1 sur blanc */
}

/* Sur fond light, encore plus sombre */
.bg-light .text-muted,
.card .text-muted {
  color: #495057 !important; /* Ratio ~7:1 sur #f8f9fa */
}

/* Small text muted - contraste renforce */
small.text-muted,
.small.text-muted {
  color: #495057 !important;
}

/* Placeholders avec meilleur contraste */
::placeholder {
  color: #6c757d !important; /* Ratio ~4.5:1 */
  opacity: 1 !important;
}

::-webkit-input-placeholder {
  color: #6c757d !important;
}

::-moz-placeholder {
  color: #6c757d !important;
}

:-ms-input-placeholder {
  color: #6c757d !important;
}

/* Labels de formulaire */
.form-label,
label {
  color: var(--bs-dark, #114b5f);
  font-weight: 500;
}

/* Help text */
.form-text,
.help-text {
  color: #5a6268 !important;
}

/* Badge secondary avec meilleur contraste */
.badge.bg-secondary {
  background-color: #5a6268 !important;
  color: #fff !important;
}

/* Liens dans le texte */
p a,
.text-muted a {
  color: var(--primary-600);
  text-decoration: underline;
}

p a:hover,
.text-muted a:hover {
  color: var(--primary-700);
}

/* ============================================================
   ARIA LIVE REGIONS
   ============================================================ */

/* Zone pour les annonces dynamiques (lecteurs d'ecran) */
.sr-announcer,
[aria-live="polite"],
[aria-live="assertive"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Container pour notifications dynamiques visibles */
#live-notifications {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  max-width: 400px;
}

/* ============================================================
   TOUCH TARGETS - Taille minimum 48x48px
   ============================================================ */

/* Boutons sur mobile */
@media (max-width: 768px) {
  .btn,
  button {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }

  .btn-sm {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
  }

  /* Liens de navigation */
  .pc-link,
  .nav-link {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  /* Checkboxes et radios */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
  }

  /* Icons cliquables */
  .btn-icon,
  [role="button"] i,
  a > i:only-child {
    padding: 12px;
  }
}

/* ============================================================
   ANIMATIONS - Respect prefers-reduced-motion
   ============================================================ */

@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;
  }

  .skip-link {
    transition: none;
  }
}

/* ============================================================
   SCREEN READER ONLY (ameliore Bootstrap)
   ============================================================ */

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

.sr-only-focusable:focus,
.sr-only-focusable:active,
.visually-hidden-focusable:focus,
.visually-hidden-focusable:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* ============================================================
   FORMULAIRES - Ameliorations accessibilite
   ============================================================ */

/* Champs obligatoires */
.required-field::after,
label.required::after {
  content: " *";
  color: var(--bs-danger, #dc3545);
  font-weight: bold;
}

/* Erreurs de formulaire */
.is-invalid,
.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--bs-danger, #dc3545) !important;
  border-width: 2px !important;
}

.invalid-feedback,
.error-message {
  color: var(--bs-danger, #dc3545);
  font-weight: 500;
  margin-top: 4px;
}

/* Succes de formulaire */
.is-valid {
  border-color: var(--bs-success, #00C853) !important;
}

.valid-feedback {
  color: var(--bs-success, #00C853);
  font-weight: 500;
}

/* ============================================================
   PROTECTION DOUBLE-SUBMIT
   ============================================================ */

/* Bouton en cours de soumission */
.btn-submitting,
.btn[disabled][data-submitting="true"] {
  pointer-events: none;
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-submitting .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
  margin-right: 8px;
}

/* ============================================================
   HEADINGS - Structure semantique
   ============================================================ */

/* Assurer une hierarchie visuelle coherente */
h1, .h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2, .h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.875rem;
}

h3, .h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

h4, .h4 {
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

h5, .h5 {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

h6, .h6 {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

/* ============================================================
   COULEURS UTILITAIRES SUPPLEMENTAIRES
   ============================================================ */

/* Icone premium/couronne (gold) */
.text-gold,
.text-premium {
  color: #FFD700 !important;
}

/* Couleurs reseaux sociaux */
.bg-linkedin {
  background-color: #0077b5 !important;
}

.bg-twitter {
  background-color: #1da1f2 !important;
}

.bg-facebook {
  background-color: #1877f2 !important;
}

.bg-whatsapp {
  background-color: #25d366 !important;
}

/* ============================================================
   SKELETON LOADERS (P4.2)
   ============================================================ */

/* Animation de base pour skeletons */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton-container {
  pointer-events: none;
}

.skeleton-loader {
  padding: 10px 0;
}

/* Elements skeleton de base */
.skeleton-text,
.skeleton-title,
.skeleton-image,
.skeleton-avatar,
.skeleton-row,
.skeleton-chart {
  background: linear-gradient(
    90deg,
    var(--bs-gray-200) 0%,
    var(--bs-gray-100) 50%,
    var(--bs-gray-200) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--bs-border-radius-sm);
}

.skeleton-text {
  height: 16px;
  margin-bottom: 10px;
  width: 100%;
}

.skeleton-text-short {
  width: 60%;
}

.skeleton-title {
  height: 24px;
  margin-bottom: 12px;
  width: 80%;
}

.skeleton-title-short {
  width: 50%;
}

/* Skeleton Card */
.skeleton-card {
  display: flex;
  flex-direction: column;
}

.skeleton-image {
  height: 150px;
  margin-bottom: 16px;
  border-radius: var(--bs-border-radius);
}

.skeleton-content {
  flex: 1;
}

/* Skeleton Avatar Group */
.skeleton-avatar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Skeleton Table */
.skeleton-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-row {
  height: 40px;
}

/* Skeleton Chart */
.skeleton-chart {
  height: 200px;
  border-radius: var(--bs-border-radius);
}

/* ============================================================
   LOADING OVERLAY (P4.2)
   ============================================================ */

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: inherit;
  backdrop-filter: blur(2px);
}

.loading-overlay.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.loading-spinner {
  text-align: center;
}

.loading-message {
  color: var(--bs-dark);
  font-weight: 500;
  font-size: 0.9rem;
}

/* ============================================================
   TRANSITIONS DE PAGE (P4.3)
   ============================================================ */

/* Animation d'entree de page */
.page-enter {
  animation: pageEnter 0.3s ease-out;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation de sortie de page */
.page-exit {
  animation: pageExit 0.2s ease-in forwards;
}

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

/* Respecter prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .page-enter,
  .page-exit {
    animation: none;
  }

  .skeleton-text,
  .skeleton-title,
  .skeleton-image,
  .skeleton-avatar,
  .skeleton-row,
  .skeleton-chart {
    animation: none;
  }
}

/* ============================================================
   STEP PROGRESS / WIZARD (P4.4)
   ============================================================ */

.step-progress {
  padding: 20px 0;
}

.step-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}

.step-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}

/* Step Marker (cercle avec numero) */
.step-marker {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 8px;
  background: var(--bs-gray-200);
  color: var(--bs-gray-600);
  border: 2px solid var(--bs-gray-300);
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

/* Step actif */
.step-item.step-active .step-marker {
  background: var(--primary-600);
  color: #fff;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-600) 20%, transparent);
}

/* Step complete */
.step-item.step-completed .step-marker {
  background: var(--bs-success);
  color: #fff;
  border-color: var(--bs-success);
}

.step-item.step-completed .step-marker i {
  font-size: 1.1rem;
}

/* Contenu du step */
.step-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-title {
  font-weight: 600;
  color: var(--bs-gray-600);
  font-size: 0.875rem;
  transition: color 0.3s ease;
}

.step-item.step-active .step-title {
  color: var(--primary-600);
}

.step-item.step-completed .step-title {
  color: var(--bs-success);
}

.step-description {
  font-size: 0.75rem;
  color: var(--bs-gray-500);
}

/* Connecteur entre steps */
.step-connector {
  position: absolute;
  top: 20px;
  left: calc(50% + 25px);
  width: calc(100% - 50px);
  height: 2px;
  background: var(--bs-gray-300);
  transition: background 0.3s ease;
}

.step-connector.completed {
  background: var(--bs-success);
}

/* Responsive: Vertical sur mobile */
@media (max-width: 576px) {
  .step-list {
    flex-direction: column;
    gap: 20px;
  }

  .step-item {
    flex-direction: row;
    text-align: left;
    gap: 12px;
  }

  .step-connector {
    display: none;
  }

  .step-marker {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .step-content {
    align-items: flex-start;
  }
}

/* ============================================================
   ANIMATIONS UTILITAIRES
   ============================================================ */

/* Fade in */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Slide in from bottom */
.slide-up {
  animation: slideUp 0.3s ease-out;
}

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

/* Pulse pour attirer attention */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Shake pour erreur */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* ============================================================
   MEGA MENU - Header dropdown Solutions
   ============================================================ */

/* Desktop styles */
.mega-menu {
  min-width: 850px;
  border: none;
  margin-top: 10px;
  left: 50% !important;
  transform: translateX(-50%) !important;
}
.mega-menu .row.g-4 {
  --bs-gutter-x: 2rem;
  flex-wrap: nowrap;
}
.mega-menu .col-lg-4 {
  flex: 0 0 auto;
  width: 270px;
}
.mega-menu .dropdown-item {
  transition: background-color 0.2s ease, transform 0.2s ease;
  white-space: normal;
}
.mega-menu .dropdown-item:hover {
  background-color: rgba(40, 82, 56, 0.05);
  transform: translateX(4px);
}
.mega-menu .dropdown-item:hover .avtar {
  transform: scale(1.1);
}
.mega-menu .avtar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px;
  transition: transform 0.2s ease;
}
.mega-menu .avtar i {
  margin: 0 !important;
  line-height: 1;
}

/* Mobile styles */
@media (max-width: 767.98px) {
  .navbar .nav-item.dropdown {
    position: static !important;
  }
  .navbar .dropdown-menu.mega-menu {
    position: fixed !important;
    top: auto !important;
    width: 100vw;
    min-width: unset;
    max-width: none;
    max-height: 80vh;
    overflow-y: auto;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    margin-top: 0 !important;
    padding: 1.5rem !important;
    border-radius: 0 !important;
    z-index: 1050;
  }
  .mega-menu .row {
    flex-direction: column;
    gap: 0 !important;
  }
  .mega-menu .col-md-6,
  .mega-menu .col-lg-4 {
    width: 100%;
    padding: 1rem 0;
    border-bottom: 1px solid var(--bs-gray-200);
  }
  .mega-menu .col-lg-4:last-child {
    border-bottom: none;
  }
  .mega-menu .dropdown-item {
    padding: 0.75rem !important;
    margin-bottom: 0.5rem;
  }
  .mega-menu h6 {
    font-size: 0.75rem;
    margin-bottom: 0.75rem !important;
  }
  .mega-menu .avtar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .mega-menu .avtar i {
    margin: 0 !important;
    line-height: 1;
  }
  .mega-menu .bg-light-primary {
    padding: 1rem !important;
    margin-top: 0.75rem !important;
  }
}
