/*
 * WePropre Design System — wp-design.css
 * Principes : restrained, intentional, no AI slop
 * Inclure dans tous les templates : <link rel="stylesheet" href="{{ url_for('static', filename='css/wp-design.css') }}">
 */

/* ═══════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════ */
:root {
  /* Palette (ne pas toucher) */
  --c-navy:        #0B1E2D;
  --c-navy-mid:    #152A3E;
  --c-navy-light:  #1E3A52;
  --c-aqua:        #06B6D4;
  --c-aqua-dark:   #0891B2;
  --c-aqua-muted:  rgba(6,182,212,0.12);
  --c-emerald:     #10B981;
  --c-emerald-dark:#059669;
  --c-gold:        #F59E0B;
  --c-red:         #EF4444;

  /* Neutres */
  --c-white:       #FFFFFF;
  --c-off:         #F8FAFC;
  --c-border:      #E2E8F0;
  --c-border-dark: #CBD5E1;
  --c-grey-3:      #94A3B8;
  --c-grey-5:      #64748B;
  --c-grey-7:      #334155;

  /* Spacing — légèrement organique (pas multiples parfaits) */
  --sp-2:   2px;
  --sp-4:   4px;
  --sp-6:   6px;
  --sp-10:  10px;
  --sp-14:  14px;
  --sp-18:  18px;
  --sp-24:  24px;
  --sp-32:  32px;
  --sp-48:  48px;
  --sp-64:  64px;
  --sp-80:  80px;
  --sp-96:  96px;

  /* Typography scale (ratio 1.25) */
  --fs-xs:   0.75rem;   /* 12px */
  --fs-sm:   0.875rem;  /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-lg:   1.125rem;  /* 18px */
  --fs-xl:   1.25rem;   /* 20px */
  --fs-2xl:  1.5rem;    /* 24px */
  --fs-3xl:  1.875rem;  /* 30px */
  --fs-4xl:  2.25rem;   /* 36px */
  --fs-5xl:  3rem;      /* 48px */
  --fs-6xl:  3.75rem;   /* 60px */

  /* Shadows — basées sur navy, pas black */
  --sh-sm:  0 1px 2px rgba(11,30,45,0.06), 0 1px 3px rgba(11,30,45,0.04);
  --sh-md:  0 4px 6px rgba(11,30,45,0.07), 0 2px 4px rgba(11,30,45,0.05);
  --sh-lg:  0 10px 15px rgba(11,30,45,0.10), 0 4px 6px rgba(11,30,45,0.05);
  --sh-xl:  0 20px 25px rgba(11,30,45,0.12), 0 8px 10px rgba(11,30,45,0.06);
  --sh-focus: 0 0 0 3px rgba(6,182,212,0.35);

  /* Border radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Transitions — gstack motion philosophy */
  --t-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:   350ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════
   GRAIN TEXTURE — materiality (gstack principle)
   Évite le look "generic SaaS template flat"
═══════════════════════════════════════════════════ */
.wp-grain {
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='300' height='300' filter='url(%23n)' opacity='1'/></svg>");
  background-repeat: repeat;
  background-size: 300px 300px;
}

/* ═══════════════════════════════════════════════════
   RESET FOCUS — WCAG AA
   Tous les éléments interactifs ont un focus visible
═══════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--c-aqua);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ═══════════════════════════════════════════════════
   BUTTONS — système complet
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  padding: var(--sp-10) var(--sp-24);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast), color var(--t-fast);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.btn:focus-visible {
  box-shadow: var(--sh-focus);
  outline: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--c-emerald);
  color: white;
  border-color: var(--c-emerald);
  box-shadow: var(--sh-sm);
}
.btn-primary:hover {
  background: var(--c-emerald-dark);
  border-color: var(--c-emerald-dark);
  box-shadow: 0 4px 12px rgba(16,185,129,0.30);
  transform: translateY(-1px);
}
.btn-primary:active {
  background: var(--c-emerald-dark);
  box-shadow: var(--sh-sm);
}

/* Secondary */
.btn-secondary {
  background: var(--c-aqua);
  color: white;
  border-color: var(--c-aqua);
  box-shadow: var(--sh-sm);
}
.btn-secondary:hover {
  background: var(--c-aqua-dark);
  border-color: var(--c-aqua-dark);
  box-shadow: 0 4px 12px rgba(6,182,212,0.25);
  transform: translateY(-1px);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--c-navy);
  border-color: var(--c-border-dark);
}
.btn-outline:hover {
  background: var(--c-off);
  border-color: var(--c-grey-3);
}

/* Ghost (for nav/minimal) */
.btn-ghost {
  background: transparent;
  color: var(--c-grey-5);
  border-color: transparent;
  padding-left: var(--sp-14);
  padding-right: var(--sp-14);
}
.btn-ghost:hover {
  background: var(--c-off);
  color: var(--c-navy);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--c-red);
  border-color: var(--c-red);
}
.btn-danger:hover {
  background: var(--c-red);
  color: white;
}

/* Sizes */
.btn-sm { padding: var(--sp-6) var(--sp-14); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { padding: var(--sp-14) var(--sp-32); font-size: var(--fs-base); border-radius: var(--r-lg); }

/* Loading state */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: wp-spin 0.6s linear infinite;
  color: white;
}
@keyframes wp-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════ */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-24);
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
}
.card-hover:hover {
  box-shadow: var(--sh-lg);
  transform: translateY(-2px);
  border-color: var(--c-border-dark);
}
.card-flat {
  box-shadow: none;
  border: 1px solid var(--c-border);
}

/* Stat cards (dashboard) */
.stat-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-24);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-10);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c-aqua);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-card:hover::before { opacity: 1; }
.stat-value {
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--c-navy);
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-grey-5);
}
.stat-trend {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px var(--sp-6);
  border-radius: var(--r-sm);
  align-self: flex-start;
}
.stat-trend.up   { background: #D1FAE5; color: #065F46; }
.stat-trend.down { background: #FEE2E2; color: #991B1B; }
.stat-trend.flat { background: var(--c-off); color: var(--c-grey-5); }

/* ═══════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}
.field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-grey-7);
}
.field label .req {
  color: var(--c-red);
  margin-left: 2px;
}
.input {
  width: 100%;
  padding: var(--sp-10) var(--sp-14);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--c-navy);
  background: var(--c-white);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--c-grey-3); }
.input:hover { border-color: var(--c-border-dark); }
.input:focus {
  outline: none;
  border-color: var(--c-aqua);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
}
.input.is-error {
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}
.input.is-success {
  border-color: var(--c-emerald);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.field-hint {
  font-size: var(--fs-xs);
  color: var(--c-grey-3);
  margin-top: -2px;
}
.field-error {
  font-size: var(--fs-xs);
  color: var(--c-red);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-success {
  font-size: var(--fs-xs);
  color: var(--c-emerald);
}

/* Textarea */
textarea.input { resize: vertical; min-height: 100px; line-height: 1.5; }

/* Select */
select.input {
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2364748B' d='M6 8L1 3h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Checkbox / Radio */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  cursor: pointer;
}
.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 18px; height: 18px;
  border: 1.5px solid var(--c-border-dark);
  border-radius: var(--r-sm);
  cursor: pointer;
  accent-color: var(--c-emerald);
  flex-shrink: 0;
}
.check-row span {
  font-size: var(--fs-sm);
  color: var(--c-grey-7);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════
   BADGES / PILLS
═══════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-10);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-default  { background: var(--c-off); color: var(--c-grey-5); border: 1px solid var(--c-border); }
.badge-aqua     { background: rgba(6,182,212,0.10); color: var(--c-aqua-dark); border: 1px solid rgba(6,182,212,0.20); }
.badge-emerald  { background: rgba(16,185,129,0.10); color: var(--c-emerald-dark); border: 1px solid rgba(16,185,129,0.20); }
.badge-gold     { background: rgba(245,158,11,0.10); color: #92400E; border: 1px solid rgba(245,158,11,0.20); }
.badge-red      { background: rgba(239,68,68,0.10); color: #991B1B; border: 1px solid rgba(239,68,68,0.20); }
.badge-navy     { background: rgba(11,30,45,0.08); color: var(--c-navy); border: 1px solid rgba(11,30,45,0.15); }

/* Dot indicator */
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: none;
}
.badge.with-dot::before { display: block; }

/* ═══════════════════════════════════════════════════
   ALERTS / TOASTS
═══════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-14);
  padding: var(--sp-14) var(--sp-18);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.25); color: #164E63; }
.alert-success { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.25); color: #064E3B; }
.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); color: #78350F; }
.alert-error   { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); color: #7F1D1D; }

/* ═══════════════════════════════════════════════════
   EMPTY STATES
   "No items found." n'est pas un design. — gstack
═══════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-64) var(--sp-32);
  gap: var(--sp-18);
}
.empty-state-icon {
  width: 56px; height: 56px;
  background: var(--c-off);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-grey-3);
}
.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-navy);
}
.empty-state-desc {
  font-size: var(--fs-sm);
  color: var(--c-grey-5);
  max-width: 300px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-white);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  padding: var(--sp-10) var(--sp-18);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--c-grey-5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-off);
  white-space: nowrap;
}
.table th:first-child { border-radius: var(--r-lg) 0 0 0; }
.table th:last-child  { border-radius: 0 var(--r-lg) 0 0; }
.table td {
  padding: var(--sp-14) var(--sp-18);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-navy);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--t-fast);
}
.table tbody tr:hover { background: var(--c-off); }
.table a { color: var(--c-aqua-dark); font-weight: 500; }
.table a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════
   SIDEBAR — amélioration des hover states
═══════════════════════════════════════════════════ */
.wp-sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  padding: var(--sp-10) var(--sp-18);
  color: rgba(255,255,255,0.55);
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: 0;
  transition: color var(--t-fast), background var(--t-fast);
  text-decoration: none;
  position: relative;
}
.wp-sidebar-link:hover {
  color: rgba(255,255,255,0.90);
  background: rgba(255,255,255,0.06);
}
.wp-sidebar-link.active {
  color: white;
  background: rgba(6,182,212,0.15);
}
.wp-sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--c-aqua);
  border-radius: 0 2px 2px 0;
}

/* ═══════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(11,30,45,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-24);
  opacity: 0;
  transition: opacity var(--t-base);
}
.modal-backdrop.is-open {
  opacity: 1;
}
.modal {
  background: var(--c-white);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--t-base);
}
.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  padding: var(--sp-24) var(--sp-24) var(--sp-18);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-navy);
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--c-off);
  color: var(--c-grey-5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: var(--c-border); color: var(--c-navy); }
.modal-body { padding: var(--sp-24); }
.modal-footer {
  padding: var(--sp-18) var(--sp-24) var(--sp-24);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-10);
  border-top: 1px solid var(--c-border);
}

/* ═══════════════════════════════════════════════════
   SKELETON LOADERS
═══════════════════════════════════════════════════ */
@keyframes wp-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--c-border) 25%,
    var(--c-off) 50%,
    var(--c-border) 75%
  );
  background-size: 800px 100%;
  animation: wp-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skeleton-text  { height: 14px; margin-bottom: var(--sp-6); }
.skeleton-title { height: 22px; width: 60%; margin-bottom: var(--sp-10); }
.skeleton-card  { height: 120px; border-radius: var(--r-lg); }

/* ═══════════════════════════════════════════════════
   SCROLL REVEAL — réutilisable partout
═══════════════════════════════════════════════════ */
.wp-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4,0,0.2,1),
              transform 0.5s cubic-bezier(0.4,0,0.2,1);
}
.wp-reveal.in-view {
  opacity: 1;
  transform: none;
}
.wp-reveal-delay-1 { transition-delay: 80ms; }
.wp-reveal-delay-2 { transition-delay: 160ms; }
.wp-reveal-delay-3 { transition-delay: 240ms; }
.wp-reveal-delay-4 { transition-delay: 320ms; }

/* ═══════════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════════ */
.text-aqua    { color: var(--c-aqua); }
.text-emerald { color: var(--c-emerald); }
.text-gold    { color: var(--c-gold); }
.text-red     { color: var(--c-red); }
.text-muted   { color: var(--c-grey-5); }
.text-sm      { font-size: var(--fs-sm); }
.text-xs      { font-size: var(--fs-xs); }
.font-mono    { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-variant-numeric: tabular-nums; }

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

/* ═══════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════ */
@media print {
  .wp-grain, .sidebar, .nav { display: none !important; }
}
