/**
 * DESIGN SYSTEM V2 - Ultra-Moderne
 * ADN Catalogue - Background blur + Interactions fluides
 * Inspiré des designs professionnels
 * © 2026 - Altiplano
 */

:root {
  /* === BASE === */
  --bg: #f5f7fa;
  --ink: #1a202c;
  --ink-light: #4a5568;
  --ink-muted: #718096;
  --muted: #a0aec0;

  /* === PALETTE === */
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-dark: #d97706;

  /* === SURFACES === */
  --card: rgba(255, 255, 255, 0.85);
  --card-hover: rgba(255, 255, 255, 0.95);
  --stroke: rgba(15, 23, 42, 0.08);
  --stroke-hover: rgba(15, 23, 42, 0.14);
  --surface: rgba(79, 70, 229, 0.04);
  --surface-hover: rgba(79, 70, 229, 0.08);

  /* === STATUS === */
  --success: #10b981;
  --success-light: #34d399;
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --error: #ef4444;
  --error-light: #f87171;
  --info: #3b82f6;
  --info-light: #60a5fa;

  /* === SHADOWS === */
  --shadow-xs: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.10);
  --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.12);

  /* === BORDER RADIUS === */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* === SPACING === */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;

  /* === LAYOUT === */
  --sidebar-w: 280px;
  --sidebar-w-collapsed: 72px;
  --navbar-h: 64px;
  --content-max-w: 1440px;
  --page-padding: 24px;

  /* === MOTION === */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;

  /* === Z-INDEX === */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* === RESET & BASE === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === BACKGROUND BLUR SYSTEM === */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 20% 12%, rgba(72,97,165,.22), transparent 60%),
    radial-gradient(900px 500px at 78% 18%, rgba(238,218,198,.55), transparent 62%),
    radial-gradient(1100px 600px at 55% 70%, rgba(106,123,209,.12), transparent 64%),
    linear-gradient(180deg, #f7f8fc 0%, #eef1f7 45%, #edf1f8 100%);
  filter: saturate(1.05);
}

.app-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background-image: url("../images/background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.03);
  filter: blur(18px) brightness(.96) saturate(1.02);
  will-change: transform, filter;
  pointer-events: none;
}

.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.7) 26%,
    rgba(255, 255, 255, 0.30) 82%
  );
  mix-blend-mode: normal;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--ink);
}

h1 { font-size: clamp(32px, 4vw, 48px); font-weight: 800; }
h2 { font-size: clamp(24px, 3vw, 36px); font-weight: 700; }
h3 { font-size: clamp(20px, 2.5vw, 28px); font-weight: 700; }
h4 { font-size: clamp(18px, 2vw, 24px); font-weight: 600; }
h5 { font-size: clamp(16px, 1.8vw, 20px); font-weight: 600; }
h6 { font-size: clamp(14px, 1.6vw, 18px); font-weight: 600; }

p {
  margin: 0 0 1em;
  line-height: 1.6;
  color: var(--ink-light);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-default);
}

a:hover {
  color: var(--primary-light);
}

/* === HERO SECTION === */
.hero {
  padding: var(--space-6) var(--page-padding);
  background: 
    linear-gradient(135deg, rgba(79, 70, 229, 0.02) 0%, rgba(245, 158, 11, 0.02) 100%),
    var(--card);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.hero h1 {
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-3);
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: clamp(16px, 1.5vw, 18px);
  color: var(--ink-muted);
  margin-bottom: 0;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-default);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg,
.btn i {
  font-size: 16px;
  transition: transform var(--duration-base) var(--ease-default);
}

.btn:hover svg,
.btn:hover i {
  transform: scale(1.1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 0 0 rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: var(--ink);
  box-shadow: var(--shadow-sm), 0 0 0 0 rgba(245, 158, 11, 0.4);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(245, 158, 11, 0.1);
}

.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-ghost:hover {
  background: var(--card-hover);
  border-color: var(--stroke-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

/* === CARDS === */
.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-base) var(--ease-default);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--stroke-hover);
  background: var(--card-hover);
}

.card-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.4) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-4);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.card-body {
  padding: var(--space-4);
}

.card-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--stroke);
  margin: var(--space-4) calc(var(--space-4) * -1) calc(var(--space-4) * -1);
}

/* === FORMS === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(250,250,252,.94);
  color: var(--ink);
  font-weight: 600;
  font-family: inherit;
  outline: none;
  transition:
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: rgba(15,23,42,.36);
  font-weight: 600;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(106,123,209,.85);
  box-shadow: 0 6px 30px rgba(72,97,165,.08);
  transform: translateY(-1px);
}

/* Input avec icon */
.input-icon {
  position: relative;
}

.input-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  opacity: .55;
  pointer-events: none;
}

.input-icon input {
  padding-left: 40px;
}

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.78);
  font-weight: 800;
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
}

.badge-primary {
  background: rgba(72,97,165,.12);
  border-color: rgba(72,97,165,.20);
  color: var(--primary);
}

.badge-accent {
  background: rgba(244,178,60,.18);
  border-color: rgba(245,158,11,.26);
  color: var(--accent-2);
}

.badge-ok {
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.20);
  color: var(--ok);
}

.badge-warn {
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.20);
  color: var(--warn);
}

.badge-bad {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.20);
  color: var(--bad);
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--stroke);
}

tbody tr {
  transition: background var(--fast) var(--ease);
}

tbody tr:hover {
  background: var(--surface);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  color: var(--ink);
}

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.w-100 { width: 100%; }

/* === ANIMATIONS === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.fade-in {
  animation: fadeIn 0.5s var(--ease);
}

.slide-in {
  animation: slideIn 0.4s var(--ease);
}

/* === LOADING === */
.loader {
  border: 4px solid rgba(72, 97, 165, 0.1);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

.loader-lg {
  width: 56px;
  height: 56px;
  border-width: 6px;
}

/* === RESPONSIVE === */
@media (max-width: 980px) {
  :root {
    --pad-4: 18px;
    --pad-5: 24px;
  }
  
  h1 { font-size: clamp(24px, 5vw, 32px); }
  h2 { font-size: clamp(20px, 4vw, 28px); }
}

@media (max-width: 640px) {
  .btn {
    padding: 10px 14px;
    font-size: 12px;
  }
  
  .card {
    padding: 18px;
  }
}

/* === CHIP === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--card);
  border: 1px solid var(--stroke);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-default);
}

.chip:hover {
  background: var(--card-hover);
  box-shadow: var(--shadow-sm);
}

.chip svg,
.chip i {
  font-size: 14px;
  color: var(--ink-muted);
}

.dot-primary {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-base) var(--ease-default);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-default);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: var(--card-hover);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--surface);
  color: var(--primary);
  transition: all var(--duration-base) var(--ease-default);
}

.stat-card:hover .stat-icon {
  transform: scale(1.1);
  background: var(--surface-hover);
}

.stat-icon.primary {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.stat-icon.accent {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent);
}

.stat-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-value {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: var(--space-2);
  line-height: 1;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.stat-trend.up {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.stat-trend.down {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* === HOVER & INTERACTION UTILITIES === */
.hover-lift {
  transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

.active-scale:active {
  transform: scale(0.97);
}

/* === ANIMATIONS UTILITIES === */
.animate-fade-up {
  animation: fadeIn 0.6s var(--ease);
}

.delay-100 {
  animation-delay: 0.1s;
}

.delay-200 {
  animation-delay: 0.2s;
}

.delay-300 {
  animation-delay: 0.3s;
}

/* === PAGE ENTER ANIMATION === */
.page-enter {
  animation: fadeIn 0.5s var(--ease);
}

/* =========================================================
   ADDON DESIGN SYSTEM (Harmony Pack) - à coller en BAS
   ========================================================= */

:root{
  /* Brand harmony (Altiplano vibe) */
  --primary: #2a4597;
  --primary-2: #4861a5;
  --primary-light: #4861a5;
  --primary-dark: #1f3577;

  --accent: #ffaf1e;
  --accent-2: #ffd17a;
  --accent-light: #ffd17a;
  --accent-dark: #d97706;

  /* Alias status (compat) */
  --ok: var(--success);
  --warn: var(--warning);
  --bad: var(--error);

  /* Alias motion (compat avec navbar/sidebar) */
  --ease: var(--ease-default);
  --fast: var(--duration-fast);
  --med: var(--duration-base);
  --slow: var(--duration-slow);

  /* Alias layout (compat sidebar css) */
  --maxw: var(--content-max-w);
  --pad-page: var(--page-padding);

  /* Focus ring */
  --ring: rgba(72, 97, 165, 0.22);
  --ring-strong: rgba(72, 97, 165, 0.32);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

/* Pills réutilisables (pour contenu + topbar) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.62);
  color: rgba(15,23,42,0.78);
  font-weight: 800;
  transition: transform var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
}
.pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pill.is-active {
  background: linear-gradient(135deg, rgba(72,97,165,0.12), rgba(255,175,30,0.14));
  border-color: rgba(72,97,165,0.28);
  color: rgba(15,23,42,0.92);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 10px rgba(72,97,165,0.35);
}

/* Compat "stat-change" utilisé dans accueil.php */
.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  background: rgba(15,23,42,0.04);
  color: rgba(15,23,42,0.72);
}
.stat-change.positive { background: rgba(16,185,129,0.10); color: var(--success); }
.stat-change.negative { background: rgba(239,68,68,0.10); color: var(--error); }

/* Unifier badges bootstrap -> design system */
.badge-success { background: rgba(16,185,129,0.14) !important; color: var(--success) !important; }
.badge-warning { background: rgba(245,158,11,0.14) !important; color: var(--warning) !important; }
.badge-danger  { background: rgba(239,68,68,0.14) !important; color: var(--error) !important; }
.badge-info    { background: rgba(59,130,246,0.14) !important; color: var(--info) !important; }
.badge-secondary { background: rgba(15,23,42,0.10) !important; color: rgba(15,23,42,0.75) !important; }
