/* ==========================================================================
   WIS CRM — thème "moderne épuré" (surcouche de style.css)
   Chargé après style.css : ne modifie aucun comportement, uniquement l'apparence.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e8eaee;
  --border-strong: #d5d9e0;
  --text: #15171c;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #2159d0;
  --primary-soft: #eef3ff;
  --sidebar-bg: #0f1117;
  --sidebar-text: #a9adbd;
  --sidebar-active: rgba(255, 255, 255, 0.08);
  --success: #12976a;  --success-bg: #e7f7f0;
  --warning: #b97d0c;  --warning-bg: #fdf4e3;
  --danger: #d23f2b;   --danger-bg: #fdecea;
  --info: #2f6fed;     --info-bg: #eef3ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.25);
  --ring: 0 0 0 3px rgba(47, 111, 237, 0.18);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.006em;
}
::selection { background: rgba(47, 111, 237, 0.18); }

/* Barres de défilement discrètes */
* { scrollbar-width: thin; scrollbar-color: #cdd2da transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d3d7de; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #b9bfc9; }

/* ---------------------------------------------------------------- Sidebar */
.sidebar { padding: 18px 10px; border-right: 1px solid rgba(255, 255, 255, 0.04); }
.sidebar nav, .sidebar .nav { scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 450;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #e8eaf2; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 550; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-group-header { font-size: 10.5px; letter-spacing: .7px; padding: 14px 12px 6px; color: rgba(169, 173, 189, .5); }
.nav-group-items { transition: opacity .2s var(--ease); }
.sidebar-search { border-radius: 9px; padding: 9px 11px; transition: background .15s, border-color .15s; }

/* ---------------------------------------------------------------- Contenu */
.content { padding: 32px 40px; }
.view { max-width: 1240px; }
.page-header, .detail-header { margin-bottom: 24px; gap: 16px; }
.page-header h2, .detail-header h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.page-header .sub { font-size: 13.5px; margin-top: 4px; }
.section-title { font-size: 11.5px; letter-spacing: .6px; font-weight: 650; color: #8a909c; }

/* Transition d'apparition des vues */
.view.wis-enter { animation: wisViewIn .28s var(--ease) both; }
@keyframes wisViewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Cartes */
.card, .stat-card {
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.card { overflow: hidden; }
.card-pad { padding: 20px 22px; }
.stat-grid { gap: 16px; }
.stat-card { padding: 18px 20px; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .label { font-size: 12.5px; font-weight: 500; }
.stat-card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Tableaux */
table { font-variant-numeric: tabular-nums; }
th {
  font-size: 11px; font-weight: 600; letter-spacing: .5px; color: #8a909c;
  padding: 11px 14px; background: #fafbfc; border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid #f0f1f4; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover td { background: #f8f9fc; }
tr[style*="cursor:pointer"]:hover td, tr[style*="cursor: pointer"]:hover td, tr.clickable:hover td { background: var(--primary-soft); }
.card > table th:first-child, .card > table td:first-child { padding-left: 20px; }
.card > table th:last-child, .card > table td:last-child { padding-right: 20px; }

/* ---------------------------------------------------------------- Boutons */
button, .btn-primary, .btn-secondary, .btn-danger, a.btn-secondary { cursor: pointer; }
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 8px 15px; border-radius: 9px; font-size: 13.5px; font-weight: 550;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease), color .15s;
}
.btn-primary { background: var(--primary); box-shadow: 0 1px 2px rgba(16,24,40,.08), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(47,111,237,.28); }
.btn-secondary { background: #fff; border: 1px solid var(--border-strong); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.btn-secondary:hover { background: #f8f9fb; border-color: #c3c8d1; }
.btn-danger:hover { background: #fadad5; }
.btn-primary:active, .btn-secondary:active, .btn-danger:active { transform: scale(.98); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn-icon { border-radius: 8px; transition: background .12s, color .12s; }
:focus-visible { outline: none; box-shadow: var(--ring) !important; border-radius: 8px; }

/* ---------------------------------------------------------------- Formulaires */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea {
  border: 1px solid var(--border-strong); border-radius: 9px; background-color: #fff; color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):hover, select:hover, textarea:hover { border-color: #b9bfc9; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ring);
}
/* Champs sans style dédié : taille confortable (spécificité nulle, les règles existantes priment) */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea) {
  padding: 8px 11px; min-height: 38px; box-sizing: border-box; font-size: 14px;
}
:where(textarea) { min-height: 72px; line-height: 1.5; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; vertical-align: middle; }
label { font-weight: 550; }
.form-row label, .settings-field label { font-size: 12.5px; color: #4b5260; }

/* ---------------------------------------------------------------- Badges & onglets */
.badge { padding: 3px 10px; font-weight: 600; font-size: 11.5px; letter-spacing: .1px; }
.tabs { gap: 2px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 14px; font-weight: 500; border-radius: 8px 8px 0 0; transition: color .15s, background .15s; }
.tab:hover { color: var(--text); background: rgba(16,24,40,.03); }

/* ---------------------------------------------------------------- Modales */
.modal-overlay {
  background: rgba(15, 17, 23, 0.42); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 6vh 20px; animation: wisFade .18s var(--ease) both;
}
.modal, .modal-content { border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid rgba(16,24,40,.06); animation: wisPop .22s var(--ease) both; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid #f0f1f4; }
.modal-header h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 14px 24px; background: #fafbfc; border-top: 1px solid #f0f1f4; border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.modal-overlay.wis-closing { animation: wisFadeOut .16s var(--ease) both; }
.modal-overlay.wis-closing .modal, .modal-overlay.wis-closing .modal-content { animation: wisPopOut .16s var(--ease) both; }
@keyframes wisFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wisFadeOut { to { opacity: 0; } }
@keyframes wisPop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes wisPopOut { to { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ---------------------------------------------------------------- États vides & chargement */
.empty-state { padding: 48px 20px; font-size: 13.5px; }
.empty-state.wis-loading {
  color: transparent; position: relative; min-height: 120px; padding: 18px 20px; text-align: left; user-select: none;
}
.empty-state.wis-loading::before {
  content: ""; position: absolute; inset: 18px 20px; border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent) 0 0 / 40% 100% no-repeat,
    repeating-linear-gradient(180deg, #eef0f3 0 14px, transparent 14px 30px);
  animation: wisShimmer 1.2s linear infinite;
}
td.empty-state.wis-loading::before { inset: 14px; }
@keyframes wisShimmer { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

/* ---------------------------------------------------------------- Toasts */
#wis-toasts {
  position: fixed; right: 20px; bottom: 92px; z-index: 10000; display: flex; flex-direction: column; gap: 10px;
  max-width: min(420px, calc(100vw - 32px)); pointer-events: none;
}
.wis-toast {
  pointer-events: auto; display: flex; gap: 12px; align-items: flex-start;
  background: #15171c; color: #f3f4f6; padding: 13px 16px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0,0,0,.28); white-space: pre-line; animation: wisToastIn .26s var(--ease) both;
}
.wis-toast .wis-toast-icon { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.wis-toast.ok .wis-toast-icon { background: #12976a; } .wis-toast.err .wis-toast-icon { background: #d23f2b; } .wis-toast.info .wis-toast-icon { background: #2f6fed; }
.wis-toast .wis-toast-close { margin-left: auto; background: none; border: none; color: #9ca3af; font-size: 16px; line-height: 1; padding: 0 0 0 6px; cursor: pointer; }
.wis-toast.out { animation: wisToastOut .2s var(--ease) both; }
@keyframes wisToastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes wisToastOut { to { opacity: 0; transform: translateX(16px); } }

/* Barre de progression en haut pendant les requêtes */
#wis-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 10001;
  background: linear-gradient(90deg, var(--primary), #7aa2ff); box-shadow: 0 0 8px rgba(47,111,237,.5);
  transition: width .35s var(--ease), opacity .3s; opacity: 0;
}
#wis-progress.on { opacity: 1; }

/* ---------------------------------------------------------------- Mobile */
@media (max-width: 780px) {
  .content { padding: 68px 14px 24px; }
  .view { padding: 0; }
  .page-header h2, .detail-header h2 { font-size: 20px; }
  .detail-header { flex-direction: column; gap: 12px; }
  .page-header > div:last-child, .detail-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .btn-primary, .btn-secondary, .btn-danger { min-height: 42px; padding: 10px 16px; }
  .nav-item { padding: 11px 12px; font-size: 14.5px; }
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { display: table; white-space: nowrap; }
  td, th { padding: 11px 12px; }
  .stat-card .value { font-size: 22px; }
  .modal, .modal-content { border-radius: 18px 18px 0 0; animation: wisSheet .26s var(--ease) both; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { height: auto; max-height: 94vh; display: flex; flex-direction: column; }
  .modal-body { max-height: none; flex: 1; overflow-y: auto; }
  .modal-footer { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-footer > button { flex: 1 1 auto; }
  #wis-toasts { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: none; }
  @keyframes wisSheet { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
