/* ═══════════════════════════════════════════════════════════════
   PLCORP NEXUS — Design System v1.6.0
   Stack : HTMX + Tailwind CDN + Django Templates
   Principe : Marché de confiance — orange Harmattan, navy béton
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. TOKENS ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --pl-orange:        #E8660A;
  --pl-orange-hover:  #C85500;
  --pl-orange-light:  rgba(232, 102, 10, 0.08);
  --pl-orange-mid:    rgba(232, 102, 10, 0.16);
  --pl-navy:          #1A1A2E;
  --pl-navy-light:    rgba(26, 26, 46, 0.06);

  /* Surfaces (élévation croissante) */
  --pl-bg:        #F8F9FA;   /* canvas */
  --pl-surface:   #FFFFFF;   /* cartes */
  --pl-surface-2: #F1F3F5;   /* inputs, hover */
  --pl-surface-dark: #121212;

  /* Texte (4 niveaux) */
  --pl-text-1: #1A1A2E;   /* principal */
  --pl-text-2: #4A4A6A;   /* secondaire */
  --pl-text-3: #6B6B8D;   /* muet — WCAG AA 4.6:1 sur blanc */
  --pl-text-4: #BBBBCC;   /* placeholder */

  /* Bordures (3 niveaux) */
  --pl-border:        rgba(26, 26, 46, 0.07);
  --pl-border-medium: rgba(26, 26, 46, 0.12);
  --pl-border-strong: rgba(26, 26, 46, 0.20);

  /* Sémantique */
  --pl-success:       #28A745;
  --pl-success-light: rgba(40, 167, 69, 0.08);
  --pl-warning:       #E8A00A;
  --pl-warning-light: rgba(232, 160, 10, 0.10);
  --pl-error:         #DC3545;
  --pl-error-light:   rgba(220, 53, 69, 0.08);

  /* Géométrie */
  --pl-r-xs:   3px;
  --pl-r-sm:   6px;
  --pl-r-md:   10px;
  --pl-r-lg:   14px;
  --pl-r-xl:   20px;
  --pl-r-full: 9999px;

  /* Ombres — diffusion subtile teintée navy */
  --pl-shadow-xs: 0 1px 2px rgba(26, 26, 46, 0.05);
  --pl-shadow-sm: 0 1px 4px rgba(26, 26, 46, 0.07), 0 1px 2px rgba(26, 26, 46, 0.04);
  --pl-shadow-md: 0 4px 16px rgba(26, 26, 46, 0.08), 0 2px 4px rgba(26, 26, 46, 0.04);
  --pl-shadow-lg: 0 8px 32px rgba(26, 26, 46, 0.10), 0 4px 8px rgba(26, 26, 46, 0.05);

  /* Transitions */
  --pl-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pl-t:    0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --pl-t-slow: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}


/* ── 2. BASE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--pl-bg);
  color: var(--pl-text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .pl-heading {
  font-family: 'Montserrat', system-ui, sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

a { color: inherit; }
img { display: block; max-width: 100%; }

/* Sélection — orange brand */
::selection { background: var(--pl-orange-light); color: var(--pl-navy); }


/* ── 3. HTMX ────────────────────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.htmx-request .htmx-indicator { opacity: 1; }


/* ── 4. ANIMATIONS ──────────────────────────────────────────── */
@keyframes pl-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pl-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pl-pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.pl-fade-in    { animation: pl-fade-in    0.25s var(--pl-ease) both; }
.pl-slide-down { animation: pl-slide-down 0.20s ease-out both; }

body > main { animation: pl-fade-in 0.2s var(--pl-ease); }

/* Scrollbar invisible */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }


/* ── 5. BOUTONS ─────────────────────────────────────────────── */
.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 22px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--pl-r-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--pl-t);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.pl-btn:active { transform: translateY(1px) scale(0.985); }
.pl-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.pl-btn-primary {
  background: var(--pl-orange);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232,102,10,0.20);
}
.pl-btn-primary:hover {
  background: var(--pl-orange-hover);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232,102,10,0.30);
}

.pl-btn-secondary {
  background: var(--pl-navy);
  color: #fff;
}
.pl-btn-secondary:hover { opacity: 0.88; color: #fff; }

.pl-btn-ghost {
  background: transparent;
  color: var(--pl-text-2);
  border: 1px solid var(--pl-border-medium);
}
.pl-btn-ghost:hover {
  border-color: var(--pl-orange);
  color: var(--pl-orange);
  background: var(--pl-orange-light);
}

.pl-btn-subtle {
  background: var(--pl-surface-2);
  color: var(--pl-text-2);
}
.pl-btn-subtle:hover {
  background: var(--pl-orange-light);
  color: var(--pl-orange);
}

.pl-btn-danger {
  background: var(--pl-error-light);
  color: var(--pl-error);
}
.pl-btn-danger:hover {
  background: var(--pl-error);
  color: #fff;
}

.pl-btn-pill { border-radius: var(--pl-r-full); }
.pl-btn-sm   { padding: 7px 16px; font-size: 12px; }
.pl-btn-lg   { padding: 14px 32px; font-size: 16px; font-weight: 600; }

/* Spinner dans bouton */
.pl-btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── 6. CARTES ──────────────────────────────────────────────── */
.pl-card {
  background: var(--pl-surface);
  border-radius: var(--pl-r-lg);
  border: 1px solid var(--pl-border);
  box-shadow: var(--pl-shadow-sm);
}
.pl-card-hover {
  transition: box-shadow var(--pl-t), transform var(--pl-t), border-color var(--pl-t);
}
.pl-card-hover:hover {
  box-shadow: var(--pl-shadow-md);
  border-color: var(--pl-border-medium);
  transform: translateY(-1px);
}


/* ── 7. BADGES ──────────────────────────────────────────────── */
.pl-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--pl-r-full);
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pl-badge-orange { background: var(--pl-orange-light);  color: var(--pl-orange);  }
.pl-badge-green  { background: var(--pl-success-light); color: var(--pl-success); }
.pl-badge-yellow { background: var(--pl-warning-light); color: var(--pl-warning); }
.pl-badge-red    { background: var(--pl-error-light);   color: var(--pl-error);   }
.pl-badge-navy   { background: var(--pl-navy-light);    color: var(--pl-navy);    }
.pl-badge-gray   { background: rgba(136,136,170,0.10);  color: var(--pl-text-3);  }


/* ── 8. FORMULAIRES ─────────────────────────────────────────── */
.pl-input {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--pl-text-1);
  background: var(--pl-surface);
  border: 1px solid var(--pl-border-medium);
  border-radius: var(--pl-r-sm);
  transition: border-color var(--pl-t), box-shadow var(--pl-t);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.pl-input:focus {
  border-color: var(--pl-orange);
  box-shadow: 0 0 0 3px var(--pl-orange-light);
}
.pl-input::placeholder { color: var(--pl-text-4); }
.pl-input:disabled     { opacity: 0.5; cursor: not-allowed; }

.pl-label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--pl-text-2);
  margin-bottom: 6px;
}

.pl-field-error {
  font-size: 12px;
  color: var(--pl-error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pl-field-hint {
  font-size: 12px;
  color: var(--pl-text-3);
  margin-top: 4px;
}


/* ── 9. SIGNATURE — Marqueur de chantier ────────────────────── */
/* Bordure gauche orange 3px = état actif / titre de section */
.pl-section-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--pl-text-1);
  padding-left: 12px;
  border-left: 3px solid var(--pl-orange);
  line-height: 1.3;
}

.pl-accent-left {
  border-left: 3px solid var(--pl-orange);
  padding-left: 12px;
}

/* KPI / métrique */
.pl-kpi {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--pl-text-1);
  letter-spacing: -0.03em;
  line-height: 1;
}
.pl-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--pl-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Prix */
.pl-price {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--pl-orange);
  letter-spacing: -0.02em;
}
.pl-price-lg { font-size: 24px; }
.pl-price-xl { font-size: 32px; }


/* ── 10. NAVIGATION ─────────────────────────────────────────── */
.pl-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pl-text-2);
  text-decoration: none;
  padding: 5px 0;
  position: relative;
  transition: color var(--pl-t);
}
/* Underline orange — signature horizontale */
.pl-nav-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--pl-orange);
  border-radius: 2px;
  transition: width var(--pl-t-slow);
}
.pl-nav-link:hover { color: var(--pl-orange); }
.pl-nav-link:hover::after { width: 100%; }
.pl-nav-link.active { color: var(--pl-navy); font-weight: 600; }
.pl-nav-link.active::after { width: 100%; }

/* Mobile nav — bordure gauche orange (signature verticale) */
.pl-mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--pl-text-2);
  text-decoration: none;
  border-radius: var(--pl-r-md);
  border-left: 3px solid transparent;
  transition: all var(--pl-t);
}
.pl-mobile-nav-link:hover {
  background: var(--pl-orange-light);
  color: var(--pl-orange);
  border-left-color: var(--pl-orange-mid);
}
.pl-mobile-nav-link.active {
  background: var(--pl-orange-light);
  color: var(--pl-navy);
  font-weight: 600;
  border-left-color: var(--pl-orange);
}


/* ── 11. STATUS DOT ─────────────────────────────────────────── */
.pl-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pl-dot-green  { background: var(--pl-success); animation: pl-pulse-dot 2s ease-in-out infinite; }
.pl-dot-orange { background: var(--pl-orange); }
.pl-dot-red    { background: var(--pl-error); }
.pl-dot-gray   { background: var(--pl-text-4); }


/* ── 12. MESSAGES / ALERTES ─────────────────────────────────── */
.pl-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--pl-r-md);
  font-size: 14px;
  line-height: 1.5;
}
.pl-alert-success { background: var(--pl-success-light); color: #1a6630; border: 1px solid rgba(40,167,69,0.18); }
.pl-alert-warning { background: var(--pl-warning-light); color: #7a5200; border: 1px solid rgba(232,160,10,0.20); }
.pl-alert-error   { background: var(--pl-error-light);   color: #a01020; border: 1px solid rgba(220,53,69,0.18); }
.pl-alert-info    { background: rgba(26,26,46,0.05);     color: var(--pl-text-1); border: 1px solid var(--pl-border-medium); }


/* ── 13. DIVIDER ────────────────────────────────────────────── */
.pl-divider {
  width: 100%;
  height: 1px;
  background: var(--pl-border);
  margin: 0;
  border: none;
}


/* ── 14. SKELETON ───────────────────────────────────────────── */
@keyframes pl-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.pl-skeleton {
  background: linear-gradient(
    90deg,
    var(--pl-surface-2) 25%,
    #e8e8f0 50%,
    var(--pl-surface-2) 75%
  );
  background-size: 800px 100%;
  animation: pl-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--pl-r-sm);
}
