/* =====================================================================
   TRAIVIS Studio — Design system "clair premium"
   Palette claire + accent teal, contrôles custom, ombres douces, micro-anim.
   Chaque vue n'ajoute que son spécifique dans assets/css/views/*.css.
   ===================================================================== */
:root {
  /* Surfaces & texte */
  --bg: #f5f7fa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #eef6f6 0%, rgba(245,247,250,0) 60%), var(--bg);
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --surface-3: #e9eef3;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e6eaf0;
  --border-2: #d7dee7;

  /* Accent teal */
  --accent: #0ea5a4;
  --accent-600: #0d9488;
  --accent-700: #0f766e;
  --accent-tint: #e6faf8;
  --accent-tint-2: #d2f3f0;
  --on-accent: #ffffff;

  /* Sémantique */
  --ok: #059669;       --ok-tint: #e7f7ef;
  --warn: #d97706;     --warn-tint: #fdf2e3;
  --danger: #e11d48;   --danger-tint: #fdeaef;
  --info: #2563eb;     --info-tint: #e8effe;

  /* Rayons & ombres */
  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow: 0 4px 14px rgba(15,23,42,.07), 0 2px 6px rgba(15,23,42,.04);
  --shadow-lg: 0 18px 50px rgba(15,23,42,.16);
  --ring: 0 0 0 4px rgba(14,165,164,.16);

  --nav-w: 248px;
  --ease: cubic-bezier(.16,.84,.44,1);

  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
body { background: var(--bg-grad); background-attachment: fixed; font-size: 14.5px; line-height: 1.5; }
a { color: var(--accent-600); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-700); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; letter-spacing: -.012em; color: var(--text); }
::selection { background: var(--accent-tint-2); }

/* --- Shell layout --------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.layout__main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: 30px 36px; max-width: 1240px; width: 100%; margin: 0 auto; animation: fadein .35s var(--ease); }
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Sidebar -------------------------------------------------------- */
.nav { background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.nav__brand { font-weight: 750; font-size: 16px; letter-spacing: -.02em; padding: 6px 12px 22px;
  display: flex; align-items: center; gap: 9px; }
.nav__brand::before { content: ""; width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--accent) 0%, #22d3c5 100%); box-shadow: 0 4px 12px rgba(14,165,164,.4); }
.nav__list { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav__section { color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; padding: 18px 12px 7px; }
.nav__link { display: block; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-size: 14px;
  font-weight: 500; margin-bottom: 2px; transition: background .15s var(--ease), color .15s var(--ease); position: relative; }
.nav__link:hover { background: var(--surface-2); color: var(--text); }
.nav__link--active { background: var(--accent-tint); color: var(--accent-700); font-weight: 600; }
.nav__link--active::before { content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav__footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }

/* --- Topbar --------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 36px;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,.8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20; }
.topbar__context { color: var(--muted); font-size: 13px; font-weight: 500; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__name { font-size: 14px; font-weight: 500; }
.topbar__logout { margin: 0; }

/* --- Boutons -------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px;
  border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 550; font-family: inherit; line-height: 1.2;
  transition: transform .12s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
  box-shadow: var(--shadow-sm); }
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-2); }
.btn:active { transform: translateY(0); }
.btn--primary { background: linear-gradient(180deg, #12b3b0 0%, var(--accent) 100%); border-color: var(--accent-600);
  color: var(--on-accent); box-shadow: 0 4px 14px rgba(14,165,164,.35); }
.btn--primary:hover { box-shadow: 0 8px 22px rgba(14,165,164,.45); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn--danger { background: var(--surface); border-color: var(--danger); color: var(--danger); box-shadow: var(--shadow-sm); }
.btn--danger:hover { background: var(--danger-tint); }
.btn--sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- Page header & toolbar ------------------------------------------ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { margin: 0; font-size: 25px; font-weight: 700; }
.page-head__sub { color: var(--muted); font-size: 14px; margin-top: 5px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }

/* --- Contrôles de formulaire (TOUT custom) -------------------------- */
/* Sélecteur LARGE : cible aussi les <input> sans attribut type (qui ne sont PAS
   matchés par input[type="text"]). On exclut cases à cocher / radios / boutons.
   Largeur auto par défaut (toolbars inline OK) ; plein-largeur en contexte form. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]),
select, textarea {
  padding: 10px 13px; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; line-height: 1.4;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease); max-width: 100%; }
input[type="file"] { border: 1px solid var(--border-2); border-radius: 10px; background: var(--surface);
  font-family: inherit; font-size: 14px; color: var(--text); }
.form__row input, .form__row select, .form__row textarea,
.login__form input, .login__input, textarea { width: 100%; }
.form__check input { width: auto; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:not([type="checkbox"]):not([type="radio"]):hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: var(--border-2); background: var(--surface-2); }
textarea { min-height: 104px; resize: vertical; }

/* Select custom (flèche SVG, pas de chrome natif) */
select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }

/* Fichier */
input[type="file"] { padding: 8px 12px; cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 550; cursor: pointer;
  font-family: inherit; transition: background .15s var(--ease); }
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }

/* Cases à cocher teintées */
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.form { max-width: 660px; }
.form__row { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.form__row label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.form__hint { color: var(--faint); font-size: 12.5px; }
.form__error { color: var(--danger); font-size: 13px; }
.form__actions { display: flex; gap: 10px; margin-top: 6px; }
.form__check { flex-direction: row; align-items: center; gap: 9px; }
.form__check label { font-weight: 500; color: var(--text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

/* --- Cartes & KPI --------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); gap: 18px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease); }
.card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent-tint-2); }
.card__title { font-weight: 650; margin-bottom: 12px; letter-spacing: -.01em; }
.card__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.card__client { color: var(--muted); font-size: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); transition: transform .16s var(--ease), box-shadow .16s var(--ease); }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi__value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; background: linear-gradient(135deg, var(--text) 0%, #334155 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi__label { color: var(--muted); font-size: 13px; margin-top: 5px; font-weight: 500; }

/* --- Tables --------------------------------------------------------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table__actions { display: flex; gap: 8px; justify-content: flex-end; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Badges (pills teintées) ---------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap; line-height: 1.5; }
.badge--ok, .badge--v-active, .badge--v-payee, .badge--v-livre, .badge--v-termine, .badge--v-client_admin {
  background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.badge--v-en_cours, .badge--v-staff { background: var(--info-tint); color: var(--info); border-color: transparent; }
.badge--v-super_admin { background: #fdf6e3; color: #b45309; border-color: transparent; }
.badge--v-en_pause, .badge--v-envoyee, .badge--v-bloque { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.badge--internal, .badge--v-en_retard, .badge--v-annulee, .badge--v-archived, .badge--v-archive {
  background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.badge--v-cadrage, .badge--v-brouillon, .badge--v-a_faire, .badge--v-invited, .badge--v-client_member {
  background: var(--surface-2); color: var(--muted); }

/* --- Onglets -------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
.tabs__link { padding: 11px 16px; color: var(--muted); font-size: 14px; font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s var(--ease), border-color .15s var(--ease); }
.tabs__link:hover { color: var(--text); text-decoration: none; }
.tabs__link--active { color: var(--accent-700); border-bottom-color: var(--accent); }

/* --- Flash ---------------------------------------------------------- */
.flash { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px;
  border: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow-sm);
  animation: fadein .3s var(--ease); }
.flash--success { background: var(--ok-tint); border-color: #b6e6cd; color: #066b4b; }
.flash--error { background: var(--danger-tint); border-color: #f6c7d3; color: #9f1239; }
.flash--info { background: var(--info-tint); border-color: #c7d8fb; color: #1e40af; }

/* --- Empty states --------------------------------------------------- */
.empty { text-align: center; padding: 56px 28px; border: 1px dashed var(--border-2); border-radius: var(--radius);
  color: var(--muted); background: var(--surface); }
.empty__title { font-weight: 650; color: var(--text); margin-bottom: 7px; font-size: 16px; }
.empty__msg { margin: 0 auto 18px; max-width: 440px; }

/* --- Modale --------------------------------------------------------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.4); backdrop-filter: blur(3px); animation: fadein .2s; }
.modal__dialog { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 26px; width: min(460px, 92vw); box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__message { color: var(--muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* --- Toasts --------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 70; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 17px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--success { border-left: 3px solid var(--ok); }

/* --- Pagination & divers ------------------------------------------- */
.pagination { display: flex; align-items: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 18px; }
.section-title { font-size: 17px; font-weight: 650; margin: 30px 0 14px; letter-spacing: -.01em; }
.error-page { text-align: center; padding-top: 14vh; }
.error-page h1 { font-size: 72px; margin: 0; font-weight: 800; background: linear-gradient(135deg, var(--accent) 0%, #22d3c5 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.error-page p { color: var(--muted); }

/* --- Responsive ----------------------------------------------------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .nav { flex-direction: row; align-items: center; height: auto; position: static; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border); padding: 10px 14px; }
  .nav__list { display: flex; gap: 4px; }
  .nav__section, .nav__footer, .nav__brand::before { display: none; }
  .nav__link--active::before { display: none; }
  .content { padding: 22px 18px; }
  .topbar { padding: 13px 18px; }
  .grid-2 { grid-template-columns: 1fr; }
}
