/* =========================================================================
   CYBERGEAR ADMIN — ERGONOMIC OVERRIDE (v1 CONSERVATEUR — 2026-04-17)

   Cible: console admin.cybergear.re (Laravel + Bootstrap 4.6.2)
   PRINCIPE: additive uniquement. Aucun changement layout/couleur existant.
   Ameliorations: a11y, tap targets, focus visible, reduce-motion, perf.
   ========================================================================= */

/* ---------- 1. FOCUS VISIBLE (WCAG 2.4.7) ---------- */
/* Tres visible sur fond clair du dashboard (#eff6fa) */
*:focus-visible {
  outline: 3px solid #fdb61d;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(253, 182, 29, 0.25);
  border-radius: 4px;
}
*:focus:not(:focus-visible) {
  outline: none;
}
/* Assurer focus sur bouton primaire bootstrap */
.btn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #fdb61d;
  outline-offset: 2px;
}

/* ---------- 2. SKIP LINK ---------- */
.admin-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100000;
  background: #fdb61d;
  color: #000;
  padding: 12px 20px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 8px 0;
}
.admin-skip-link:focus {
  left: 0;
}

/* ---------- 3. TAP TARGETS (mobile) ---------- */
@media (max-width: 768px) {
  header a, header button,
  .menu a, .menu li,
  .navbar a, .navbar button,
  .btn-user, .cart-button,
  .navbar-button,
  footer a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  /* Tableaux pagination */
  .pagination .page-link, .pagination .page-item a, .pagination .page-item span {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Login card tappables (a, button, btn-close) */
  .card a:not(.btn), .card .btn-close, .toast .btn-close,
  .gradient-form a:not(.btn) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
  }
  /* Submit button on login: full-width + taller on mobile */
  .bouton-se-connecter, .btn-primary.btn-block {
    min-height: 48px;
    font-size: 16px;
  }
}

/* ---------- 4. FORM ACCESSIBILITY ---------- */
/* Inputs plus hauts pour bonne visibilite (login page, forms admin) */
input.form-control, select.form-control, textarea.form-control {
  min-height: 44px;
}
/* Checkbox: zone cliquable elargie sans changer aspect visuel */
.form-check-input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.form-check-label {
  cursor: pointer;
  padding-left: 4px;
}
/* Placeholder plus contraste (WCAG AA sur blanc: >4.5:1) */
::placeholder {
  color: #6c757d;
  opacity: 1;
}

/* Validation visuelle apres interaction utilisateur */
input:user-invalid, textarea:user-invalid, select:user-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}
input:user-valid[required], textarea:user-valid[required], select:user-valid[required] {
  border-color: #28a745;
}
@supports not selector(:user-invalid) {
  /* Pas de fallback agressif, car `:invalid` match au chargement */
  input:required:not(:placeholder-shown):invalid {
    border-color: #dc3545;
  }
  input:required:not(:placeholder-shown):valid {
    border-color: #28a745;
  }
}

/* ---------- 5. REDUCE MOTION (WCAG 2.3.3) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  /* Slick/Owl: desactiver autoplay/fade visuel */
  .slick-slide, .owl-item {
    transition: none !important;
  }
}

/* ---------- 6. BOOTSTRAP BUTTONS: tap + contrast ---------- */
.btn {
  min-height: 38px;
  font-weight: 500;
}
.btn-primary, .bouton-se-connecter {
  /* Assurer contraste WCAG AA */
  background-color: #fdb61d !important;
  border-color: #d99b12 !important;
  color: #000 !important;
}
.btn-primary:hover, .bouton-se-connecter:hover {
  background-color: #e6a317 !important;
  border-color: #b88409 !important;
  color: #000 !important;
}
.btn-primary:focus-visible {
  outline: 3px solid #000 !important;
  outline-offset: 2px !important;
}

/* ---------- 7. TABLES (admin dashboards) ---------- */
/* Zebras pour lisibilite sans modifier les colonnes */
.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.03);
}
.table th, .table td {
  vertical-align: middle;
  padding: 10px 12px;
}
/* Table responsive: horizontal scroll sur mobile */
@media (max-width: 768px) {
  .table-responsive, .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- 8. SCROLLBAR (UX sur panneaux longs) ---------- */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: #f1f1f1;
}
*::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 5px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* ---------- 9. LOADING PERFORMANCE ---------- */
/* Repeated list items: skip rendering off-screen */
.items > *, .table tbody tr, .list-group-item {
  content-visibility: auto;
  contain-intrinsic-size: 1px 60px;
}

/* ---------- 10. TOASTS/MODALS CONTRAST ---------- */
.toast-header strong, .modal-header .modal-title {
  color: #000;
  font-weight: 600;
}
.message-error {
  color: #dc3545;
  font-weight: 600;
}

/* ---------- 11. PRINT STYLES ---------- */
@media print {
  header, footer, .menu, .navbar, .pagination,
  .btn, .toast-container, nav {
    display: none !important;
  }
  body { background: white !important; color: #000 !important; }
  .table { border: 1px solid #000; }
  .table th, .table td { border: 1px solid #666; padding: 6px; }
}

/* ---------- 12. HIGH CONTRAST SUPPORT ---------- */
@media (prefers-contrast: more) {
  a, button, .btn {
    text-decoration: underline;
  }
  *:focus-visible {
    outline-width: 4px;
  }
  .message-error, .text-danger {
    color: #b00000;
    font-weight: 700;
  }
}

/* ---------- 13. REDUCE DATA (slow connexion) ---------- */
@media (prefers-reduced-data: reduce) {
  .items.slick-slider, .owl-carousel { display: none; }
  img[loading="lazy"] { image-rendering: pixelated; }
}

/* ---------- 14. SKELETON LOADER pour tables longues ---------- */
/* Classe .is-loading: applique un shimmer placeholder tant que data pas chargee */
.is-loading {
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: admin-shimmer 1.5s infinite;
  min-height: 24px;
  border-radius: 4px;
}
@keyframes admin-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .is-loading { animation: none; }
}

/* ---------- 15. AUTOCOMPLETE hints (browsers lisent autocomplete attr) ---------- */
/* Styliser input autocomplete confirme par le navigateur */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #fffbef inset !important;
  -webkit-text-fill-color: #000 !important;
}
