/**
 * ════════════════════════════════════════════════════════════════════════
 *  SIGP — Stylesheet INSTANT UI (Refonte UX, sensation Angular/React)
 * ════════════════════════════════════════════════════════════════════════
 *
 *  Apporte les améliorations perceptuelles « app native » :
 *   - Transitions globales fluides (sans en abuser)
 *   - États hover/focus visibles et instantanés
 *   - Animations subtiles sur composants UI
 *   - Réduction des reflows pendant navigation SPA
 *
 *  Aucune dépendance ; complémente Bootstrap.
 *  ════════════════════════════════════════════════════════════════════════
 */

/* ── 1) Transitions globales — 150ms partout ────────────────────────── */
* {
  -webkit-tap-highlight-color: transparent;
}

a, button, .btn, .form-control, .form-select, .form-check-input,
.nav-link, .dropdown-item, .nl, .nb, .ni, .card, .badge,
.list-group-item, [role="button"] {
  transition:
    background-color 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease,
    opacity 150ms ease !important;
}

/* ── 2) Hover plus visible sur liens/boutons ────────────────────────── */
a:hover:not([data-no-feedback]):not(.btn) {
  filter: brightness(1.1);
}

.btn:hover:not(:disabled):not(.sigp-submitting) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* ── 3) Inputs : focus ring marqué (vert ANDE) ──────────────────────── */
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #006B3F !important;
  box-shadow: 0 0 0 3px rgba(0, 107, 63, 0.18) !important;
  outline: none !important;
}

/* ── 4) Tables : surbrillance row hover instantanée ─────────────────── */
.table tbody tr {
  transition: background-color 80ms ease !important;
}

.table tbody tr:hover {
  background-color: rgba(0, 147, 213, 0.04) !important;
}

/* ── 5) Cards : élévation au hover si interactives ──────────────────── */
.card[data-interactive], .card.is-clickable, a > .card, button > .card {
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease !important;
}

.card[data-interactive]:hover, .card.is-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* ── 6) Modals : fade-in plus naturel ───────────────────────────────── */
.modal.fade .modal-dialog {
  transform: translate(0, 20px) scale(0.96) !important;
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.modal.show .modal-dialog {
  transform: none !important;
}

/* ── 7) Toasts : entrée plus douce ──────────────────────────────────── */
@keyframes sigpToastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.show, [role="alert"] {
  animation: sigpToastIn 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 8) Loading state global pour images en cours de chargement ─────── */
img:not([loading="eager"]) {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
}

img:not([loading="eager"]).loaded {
  background: transparent;
}

/* ── 9) Dropdowns : ouverture instantanée ───────────────────────────── */
.dropdown-menu {
  transition: opacity 100ms ease !important;
}

/* ── 10) Scroll smooth sur ancres internes ──────────────────────────── */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
  }
}

/* ── 11) Boutons primaires : effet « élévation » améliorée ──────────── */
.btn-primary, .btn-success, .btn-warning, .btn-danger, .btn-info {
  position: relative;
  overflow: hidden;
}

.btn-primary::before, .btn-success::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent);
  opacity: 0;
  transition: opacity 200ms ease;
}

.btn-primary:hover::before, .btn-success:hover::before {
  opacity: 1;
}

/* ── 12) Lien actif : indicateur visuel constant ────────────────────── */
.nav-link.active, .nb.on, .nl.on, .dropdown-item.active {
  font-weight: 700;
}

/* ── 13) Cursor pointer global pour éléments interactifs ────────────── */
[role="button"], button:not([disabled]), .clickable {
  cursor: pointer;
}

/* ── 14) Anti-flash blanc sur navigation (rendu pages plus doux) ────── */
body {
  background: #f8fafc;
}

/* ── 15) Améliorations sur formulaires longs (UX saisie) ────────────── */
form .form-control:not(:placeholder-shown):valid {
  border-color: #10b981;
}

form .form-control:not(:placeholder-shown):invalid:not(:focus) {
  border-color: #ef4444;
}

/* ── 16) Sticky toolbar/header lors du scroll ───────────────────────── */
.toolbar-sticky, .filter-bar-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── 17) Spinner global personnalisé (au lieu du browser default) ───── */
.sigp-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sigp-spin 0.7s linear infinite;
}

@keyframes sigp-spin { to { transform: rotate(360deg); } }

/* ── 18) Accent SIGP — contour vert ANDE pour focus actif (a11y) ────── */
:focus-visible {
  outline: 2px solid var(--ande-green, #006B3F) !important;
  outline-offset: 2px !important;
}
