/* ==========================================================================
   Phoenix Opsale — Base : reset, typographie, contrôles, utilitaires
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
h4 { font-size: 13.5px; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* Icônes */
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
.ico-xs { width: 13px; height: 13px; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
  white-space: nowrap; text-decoration: none !important;
}
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 14px rgba(40,100,239,.25); }
.btn-primary:hover { background: var(--brand-600); }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-50); }
.btn-flame { background: var(--flame); color: #fff; }
.btn-dark { background: var(--navy-800); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; font-size: 14.5px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .65; pointer-events: none; }

/* Champs */
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238392aa' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-sm, .select-sm { height: 34px; font-size: 13px; border-radius: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 11.5px; color: var(--muted); }
.input-icon { position: relative; }
.input-icon > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input, .cb { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; margin: 0; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-flush { padding: 0; }

/* Badges & puces */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--brand-50); color: var(--brand); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.bad { background: var(--bad-50); color: var(--bad); }
.badge.violet { background: var(--violet-50); color: var(--violet); }
.badge.teal { background: var(--teal-50); color: var(--teal); }
.badge.flame { background: var(--flame-50); color: var(--flame); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: .15s;
}
.chip:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--text); }
.chip.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
[data-theme="dark"] .chip.active { background: var(--brand); border-color: var(--brand); }
.chip .count { font-size: 11px; opacity: .65; font-weight: 700; }
.chip .ico { width: 14px; height: 14px; }

/* Avatars */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 800; color: #fff; flex: none; letter-spacing: .02em;
}
.avatar.xs { width: 22px; height: 22px; font-size: 9px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.lg { width: 50px; height: 50px; font-size: 16px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* Interrupteur, segmenté, onglets */
.switch { position: relative; width: 38px; height: 22px; border-radius: 22px; background: #cfd8e6; transition: .2s; flex: none; }
[data-theme="dark"] .switch { background: #2a3a58; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(16px); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { height: 30px; padding: 0 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,34,64,.1); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 11px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-color: var(--brand); }

/* Barres de progression */
.bar { height: 6px; border-radius: 9px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 9px; background: var(--brand); }

/* Utilitaires */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.c-ok { color: var(--ok); } .c-bad { color: var(--bad); } .c-warn { color: var(--warn); } .c-brand { color: var(--brand); } .c-violet { color: var(--violet); }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface); font-family: var(--font);
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--line); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts (partagés login + app) */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 400px; padding: 12px 14px; border-radius: 12px;
  background: var(--navy-800); color: #fff; box-shadow: var(--shadow-lg);
  font-size: 13px; animation: toastIn .25s ease-out;
}
[data-theme="dark"] .toast { background: #1b2c4b; }
.toast > .ico { color: #6ee7b7; }
.toast .toast-action { margin-left: auto; color: #9cc0ff; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* Barres de défilement */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

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