/* ==========================================================================
   Gestion des projets — espace développeur et propriétaire (portail.js : softwareProjectsView)
   Reprend les maquettes fournies : cartes de statistiques, recherche arrondie, onglets en pilules,
   cartes projet avec barre d'actions (Aperçu, Gérer, Versions, Options), fenêtre « Nouvelle version
   disponible », paramètres de visibilité à interrupteurs et schéma d'importation.
   Couleurs : variables du portail (--p-*), donc thème clair / sombre synchronisé. Aucun style en ligne (CSP).
   ========================================================================== */
.pj { display: grid; gap: 16px; }
.pj-crumb { margin: 0; color: var(--p-muted); font-size: 13px; }
.pj-crumb a { color: inherit; }
.pj-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pj-head h1 { margin: 0; font-size: 28px; line-height: 1.2; }
.pj-import { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 0;
    background: #0f172a; color: #fff; font: 600 14px/1 inherit; cursor: pointer; transition: background-color 160ms ease; }
.pj-import:hover { background: #1e293b; }
:root[data-theme="dark"] .pj-import { background: #f8fafc; color: #0f172a; }
.pj svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.pj-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pj-stat { padding: 16px 18px; border: 1px solid var(--p-line); border-radius: 12px; background: var(--p-card); }
.pj-stat small { display: block; color: var(--p-muted); font-size: 14px; margin-bottom: 6px; }
.pj-stat strong { font-size: 26px; font-weight: 700; letter-spacing: .02em; }

.pj-search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 18px; border: 1px solid var(--p-line); border-radius: 999px; background: var(--p-card); color: var(--p-muted); }
.pj-search:focus-within { border-color: var(--p-accent); }
.pj-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--p-text); font: inherit; font-size: 15px; }

.pj-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.pj-tab { flex-shrink: 0; min-height: 38px; padding: 0 16px; border-radius: 999px; border: 0; background: transparent; color: var(--p-text);
    font: 600 14px/1 inherit; cursor: pointer; transition: background-color 160ms ease, color 160ms ease; }
.pj-tab:hover { background: var(--p-hover); }
.pj-tab[aria-pressed="true"] { background: #0f172a; color: #fff; }
:root[data-theme="dark"] .pj-tab[aria-pressed="true"] { background: #f8fafc; color: #0f172a; }
.pj-tab .pj-count { margin-left: 6px; font-weight: 700; opacity: .7; }

.pj-list { display: grid; gap: 14px; }
.pj-card { border: 1px solid var(--p-line); border-radius: 14px; background: var(--p-card); transition: border-color 160ms ease, box-shadow 160ms ease; animation: pj-in 200ms ease both; }
.pj-card:hover { border-color: color-mix(in srgb, var(--p-accent) 35%, var(--p-line)); box-shadow: 0 10px 30px -24px rgba(15, 23, 42, .5); }
@keyframes pj-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pj-card__top { display: flex; align-items: flex-start; gap: 14px; padding: 18px 18px 12px; }
.pj-card__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: color-mix(in srgb, var(--p-accent) 10%, var(--p-card)); color: var(--p-accent); flex-shrink: 0; }
.pj-card__title { flex: 1; min-width: 0; }
.pj-card__title strong { display: block; font-size: 17px; }
.pj-card__title small { color: var(--p-muted); font-size: 14px; }
.pj-badge { flex-shrink: 0; height: 24px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    background: color-mix(in srgb, var(--p-muted) 14%, transparent); color: var(--p-text); }
.pj-badge--publie { background: #dcfce7; color: #15803d; }
.pj-badge--corbeille { background: #fee2e2; color: #b91c1c; }
:root[data-theme="dark"] .pj-badge--publie { background: rgba(34, 197, 94, .16); color: #86efac; }
:root[data-theme="dark"] .pj-badge--corbeille { background: rgba(239, 68, 68, .16); color: #fca5a5; }
.pj-update { display: flex; align-items: center; gap: 6px; margin: 0 18px 12px 76px; color: #d97706; font-size: 13.5px; font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; }
.pj-update svg { width: 16px; height: 16px; }
.pj-meta { margin: 0 18px 12px 76px; color: var(--p-muted); font-size: 13px; }
.pj-actions { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--p-line); }
.pj-action { display: grid; justify-items: center; gap: 4px; padding: 12px 6px; border: 0; background: transparent; color: var(--p-text); font: 500 14px/1.2 inherit; cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease; }
.pj-action:hover { background: var(--p-hover); color: var(--p-accent); }
.pj-action:first-child { border-bottom-left-radius: 14px; } .pj-action:last-child { border-bottom-right-radius: 14px; }
.pj-action svg { width: 18px; height: 18px; }
.pj-empty { padding: 32px; text-align: center; color: var(--p-muted); border: 1px dashed var(--p-line); border-radius: 14px; }

/* ---------- Fenêtres ---------- */
.pj-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--p-line); border-radius: 16px;
    background: var(--p-card); color: var(--p-text); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55); }
.pj-dialog[open] { animation: pj-pop 200ms ease both; }
@keyframes pj-pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.pj-dialog::backdrop { background: rgba(2, 6, 23, .55); }
.pj-dialog__inner { display: grid; gap: 16px; padding: 24px; max-height: calc(100dvh - 34px); overflow-y: auto; }
.pj-dialog__head { display: flex; align-items: flex-start; gap: 14px; }
.pj-dialog__head .pj-card__icon { width: 48px; height: 48px; }
.pj-dialog__head h2 { margin: 0; font-size: 20px; }
.pj-dialog__head small { color: var(--p-muted); font-size: 14px; }
.pj-close { margin-left: auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--p-muted); cursor: pointer; font-size: 20px; }
.pj-close:hover { background: var(--p-hover); color: var(--p-text); }
.pj-versions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pj-version { padding: 16px; border-radius: 10px; background: color-mix(in srgb, var(--p-muted) 10%, var(--p-card)); }
.pj-version small { display: block; color: var(--p-muted); margin-bottom: 8px; }
.pj-version strong { font-size: 22px; }
.pj-box { padding: 16px; border: 1px solid var(--p-line); border-radius: 10px; }
.pj-box h3 { margin: 0 0 10px; font-size: 16px; }
.pj-change { display: grid; gap: 2px; margin-bottom: 10px; }
.pj-change svg { width: 18px; height: 18px; }
.pj-change--add { color: #16a34a; } .pj-change--mod { color: #2563eb; } .pj-change--del { color: #dc2626; }
.pj-change span { color: var(--p-text); }
.pj-files { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; font: 12.5px/1.5 Consolas, "Cascadia Mono", monospace; max-height: 220px; overflow: auto; }
.pj-files .add { color: #16a34a; } .pj-files .mod { color: #2563eb; } .pj-files .del { color: #dc2626; text-decoration: line-through; }
.pj-choice { display: grid; gap: 8px; }
.pj-choice label { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border: 1px solid var(--p-line); border-radius: 10px; cursor: pointer; }
.pj-choice label:has(input:checked) { border-color: var(--p-accent); background: color-mix(in srgb, var(--p-accent) 8%, transparent); }
.pj-row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pj-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--p-line);
    background: transparent; color: var(--p-text); font: 600 14px/1 inherit; cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease; }
.pj-btn:hover { border-color: var(--p-accent); }
.pj-btn--primary { background: var(--p-button); border-color: var(--p-button); color: var(--p-button-text); }
.pj-btn--primary:hover { background: var(--p-button-hover); }
.pj-btn--danger { color: var(--p-danger); border-color: color-mix(in srgb, var(--p-danger) 40%, var(--p-line)); }
.pj-btn:disabled { opacity: .55; cursor: not-allowed; }
.pj-error { margin: 0; color: var(--p-danger); font-size: 14px; }

/* Interrupteurs « Paramètres de visibilité » */
.pj-toggles { display: grid; }
.pj-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--p-line); }
.pj-toggle:last-child { border-bottom: 0; }
.pj-toggle strong { display: block; font-size: 15px; }
.pj-toggle small { color: var(--p-muted); font-size: 13.5px; }
.pj-switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; appearance: none; margin: 0; border-radius: 999px; background: #94a3b8; cursor: pointer; transition: background-color 160ms ease; }
.pj-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 160ms ease; }
.pj-switch:checked { background: #2563eb; }
.pj-switch:checked::after { transform: translateX(18px); }
.pj-switch:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }
.pj-switch:disabled { opacity: .5; cursor: not-allowed; }

/* Schéma d'importation */
.pj-flow { display: grid; gap: 8px; justify-items: stretch; text-align: center; }
.pj-flow__node { display: grid; justify-items: center; gap: 4px; padding: 16px; border: 1px solid var(--p-line); border-radius: 12px; }
.pj-flow__node svg { width: 26px; height: 26px; color: var(--p-accent); }
.pj-flow__node strong { font-size: 15px; }
.pj-flow__node small { color: var(--p-muted); font-size: 13px; }
.pj-flow__arrow { color: var(--p-muted); font-size: 13px; }
.pj-flow__split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pj-steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.pj-steps li { padding: 4px 10px; border-radius: 999px; font-size: 12.5px; background: color-mix(in srgb, var(--p-muted) 12%, transparent); color: var(--p-muted); }
.pj-steps li[aria-current="step"] { background: var(--p-button); color: var(--p-button-text); }
.pj-form { display: grid; gap: 14px; }
.pj-form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.pj-form input:not([type="radio"]):not([type="checkbox"]), .pj-form select, .pj-form textarea { min-height: 44px; padding: 0 12px; border: 1px solid var(--p-line); border-radius: 10px; background: var(--p-card); color: var(--p-text); font: inherit; }
.pj-form textarea { padding: 10px 12px; min-height: 80px; }
.pj-drop { display: grid; justify-items: center; gap: 6px; padding: 22px; border: 2px dashed var(--p-line); border-radius: 12px; text-align: center; color: var(--p-muted); }
.pj-drop.is-over { border-color: var(--p-accent); background: color-mix(in srgb, var(--p-accent) 6%, transparent); }
.pj-progress { height: 8px; border-radius: 999px; background: var(--p-line); overflow: hidden; }
.pj-progress span { display: block; height: 100%; width: 0; background: var(--p-accent); transition: width 160ms ease; }
.pj-progress.is-indeterminate span { width: 30%; animation: pj-indet 1.2s ease-in-out infinite; }
@keyframes pj-indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.pj-report { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.pj-preview { width: 100%; height: min(70dvh, 640px); border: 1px solid var(--p-line); border-radius: 10px; background: #fff; }
.pj-menu { display: grid; gap: 4px; }
.pj-menu button { justify-content: flex-start; }

@media (max-width: 640px) {
    .pj-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .pj-stat { padding: 12px; } .pj-stat strong { font-size: 22px; }
    .pj-update, .pj-meta { margin-left: 18px; }
    .pj-versions, .pj-flow__split { grid-template-columns: 1fr; }
    .pj-dialog__inner { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { .pj-card, .pj-dialog[open] { animation: none; } .pj-switch, .pj-switch::after { transition: none; } }
