/* ============================================================
   Swiftflow — DA "Crimson Noir"
   Rouge sombre, surfaces charbon teintées, accents incandescents.
   ============================================================ */

:root {
  --bg: #0b0709;
  --bg2: #140d10;
  --bg3: #1d1216;
  --bg4: #251820;
  --line: #2f1c23;
  --line-soft: #26171d;
  --txt: #f4eef0;
  --muted: #9c8890;
  --accent: #ff2e4d;
  --accent-deep: #c11734;
  --accent-soft: rgba(255, 46, 77, .12);
  --ember: #ff7a45;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #ff5470;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --glow: 0 0 18px rgba(255, 46, 77, .35);
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(255, 46, 77, .07), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(193, 23, 52, .06), transparent 60%),
    var(--bg);
  color: var(--txt);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace; }

/* ---------- icônes SVG ---------- */
.i {
  width: 15px; height: 15px; flex-shrink: 0;
  vertical-align: -2px; display: inline-block;
}

/* ---------- boutons ---------- */
button {
  cursor: pointer; border: 0; border-radius: var(--radius-sm);
  padding: 9px 16px; font: 600 14px var(--font); color: var(--txt);
  background: var(--bg3);
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  transition: background .18s, color .18s, border-color .18s, transform .12s, box-shadow .25s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .35; cursor: not-allowed; }

button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 46, 77, .25);
}
button.primary:hover { box-shadow: var(--glow), 0 4px 18px rgba(255, 46, 77, .35); }

button.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); padding: 6px 12px;
}
button.ghost:hover { color: var(--txt); border-color: var(--accent); background: var(--accent-soft); }
button.icon-btn { padding: 7px 9px; }
button.icon-txt { gap: 6px; }
.wide { width: 100%; }

/* ---------- inputs ---------- */
input {
  background: var(--bg); border: 1px solid var(--line); color: var(--txt);
  border-radius: var(--radius-sm); padding: 11px 14px; font: 14px var(--font);
  width: 100%; transition: border-color .18s, box-shadow .18s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: #6b5a61; }

/* ============================================================ LOGIN */
.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: 20px; position: relative; overflow: hidden;
}
.login-glow {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(480px 320px at 50% 30%, rgba(255, 46, 77, .13), transparent 70%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: .7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
.login-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 38px 34px; width: 350px;
  display: flex; flex-direction: column; gap: 16px; text-align: center;
  box-shadow: var(--shadow);
  animation: cardIn .5s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 25px; font-weight: 700; letter-spacing: -.4px;
}
.logo em { font-style: normal; color: var(--accent); }
.logo-mark { width: 32px; height: 32px; color: var(--accent); filter: drop-shadow(0 0 8px rgba(255, 46, 77, .5)); }
.login .muted { margin: -8px 0 4px; font-size: 13px; }
.field { position: relative; display: flex; align-items: center; }
.field .i { position: absolute; left: 13px; color: var(--muted); }
.field input { padding-left: 38px; }
.error { color: var(--err); font-size: 13px; min-height: 16px; }

/* ============================================================ NAVBAR */
header {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 12px 26px;
  position: sticky; top: 0; z-index: 10;
  background: rgba(11, 7, 9, .78);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 17px; font-weight: 700; letter-spacing: -.3px;
}
.brand em { font-style: normal; color: var(--accent); }
.brand .logo-mark { width: 26px; height: 26px; }

.views {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg2); border: 1px solid var(--line-soft); border-radius: 12px;
}
.view-btn {
  background: transparent; color: var(--muted);
  padding: 7px 18px; border-radius: 9px; position: relative; font-weight: 600;
}
.view-btn:hover { color: var(--txt); }
.view-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; box-shadow: 0 3px 12px rgba(255, 46, 77, .3);
}

.header-right { display: flex; align-items: center; gap: 14px; }

/* ---------- jauge stockage VPS ---------- */
.storage {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--line-soft);
}
.storage .i { color: var(--muted); }
.st-body { display: flex; flex-direction: column; gap: 3px; }
.st-bar {
  width: 120px; height: 5px; background: var(--bg);
  border-radius: 10px; overflow: hidden;
}
.st-fill {
  height: 100%; width: 0; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width .5s ease, background .3s;
}
.storage.warn .st-fill { background: linear-gradient(90deg, #b45309, var(--warn)); }
.storage.crit .st-fill { background: var(--err); animation: badgeGlow 1.2s ease-in-out infinite; }
.st-txt { font-size: 10.5px; color: var(--muted); white-space: nowrap; line-height: 1; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--err); box-shadow: 0 0 8px var(--err);
  transition: background .3s, box-shadow .3s;
}
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--ok); }
  50% { box-shadow: 0 0 12px var(--ok); }
}

main { max-width: 920px; margin: 0 auto; padding: 28px 20px 70px; }
#view-jobs, #view-library { animation: viewIn .3s ease; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ PANEL AJOUT */
.panel {
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.add-panel { margin-bottom: 30px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; }
.tab:hover { color: var(--txt); }
.tab.active {
  background: var(--accent-soft); color: var(--accent);
  border-color: rgba(255, 46, 77, .3);
}

.drop {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 30px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  position: relative; overflow: hidden;
}
.drop::after {
  content: ""; position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(360px 160px at 50% 100%, var(--accent-soft), transparent 70%);
  transition: opacity .25s;
}
.drop:hover, .drop.hover { border-color: var(--accent); transform: translateY(-1px); }
.drop:hover::after, .drop.hover::after { opacity: 1; }
.drop-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.drop-icon {
  width: 34px; height: 34px; color: var(--accent); margin-bottom: 6px;
  filter: drop-shadow(0 0 10px rgba(255, 46, 77, .35));
}
.drop.hover .drop-icon { animation: bounce .5s ease infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-5px); } }

.or {
  display: flex; align-items: center; gap: 14px;
  margin: 16px 0 12px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .8px;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.magnet-row { display: flex; gap: 10px; }
.magnet-row button { white-space: nowrap; }

.warn {
  display: flex; align-items: center; gap: 8px;
  color: var(--warn); margin-top: 14px; font-size: 13px;
  background: rgba(251, 191, 36, .07); border: 1px solid rgba(251, 191, 36, .18);
  border-radius: var(--radius-sm); padding: 9px 13px;
}
.warn .i { color: var(--warn); }

.upbar {
  margin-top: 16px; height: 30px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  position: relative; overflow: hidden;
}
.upbar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width .2s;
}
.upbar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; }

/* ============================================================ JOBS */
.jobs-head { display: flex; align-items: baseline; gap: 12px; margin: 0 4px 14px; }
h2 { font-size: 16px; margin: 0; letter-spacing: -.2px; }
.empty { text-align: center; padding: 46px; }

.job {
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px;
  animation: jobIn .35s cubic-bezier(.2, .9, .3, 1.1);
  transition: border-color .2s;
}
.job:hover { border-color: var(--line); }
@keyframes jobIn {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.job-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.job-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.title-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.job-step { font-size: 13px; margin: 9px 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .4px;
  background: var(--bg4); color: var(--muted);
}
.badge .i { width: 12px; height: 12px; }
.badge.status.downloading, .badge.status.resolving { background: var(--accent-soft); color: var(--accent); }
.badge.status.encoding { background: rgba(255, 122, 69, .13); color: var(--ember); }
.badge.status.uploading { background: rgba(255, 46, 77, .1); color: #ff8fa3; }
.badge.status.done { background: rgba(74, 222, 128, .12); color: var(--ok); }
.badge.status.error { background: rgba(255, 84, 112, .13); color: var(--err); }
.badge.status.canceled { background: var(--bg4); color: var(--muted); }
.badge.status.encoding, .badge.status.downloading, .badge.status.resolving, .badge.status.uploading {
  animation: badgeGlow 2s ease-in-out infinite;
}
@keyframes badgeGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.25); } }

.bar {
  height: 8px; background: var(--bg);
  border: 1px solid var(--line-soft); border-radius: 20px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0; border-radius: 20px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent), var(--ember), var(--accent));
  background-size: 220% 100%;
  animation: flow 2.6s linear infinite;
  transition: width .35s ease;
  box-shadow: 0 0 10px rgba(255, 46, 77, .4);
}
@keyframes flow { from { background-position: 0% 0; } to { background-position: 220% 0; } }
.job.done .bar-fill { background: var(--ok); animation: none; box-shadow: none; }
.job.error .bar-fill { background: var(--err); animation: none; box-shadow: none; }
.job.canceled .bar-fill { background: var(--muted); animation: none; box-shadow: none; }

.job-meta {
  display: flex; gap: 18px; font-size: 12px; color: var(--muted);
  margin-top: 9px; flex-wrap: wrap;
}
.job-meta span { display: inline-flex; align-items: center; gap: 5px; }
.job-meta .i { width: 12px; height: 12px; }
.job-meta .pct { color: var(--txt); font-weight: 700; }

.outputs { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; }
.outputs .out {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--ok);
}
.outputs .out .i { width: 13px; height: 13px; }

.logs {
  margin-top: 12px; background: #070405;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 12px; max-height: 260px; overflow: auto;
  font: 12px/1.5 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  white-space: pre-wrap; color: #c9b8be;
}
.logs::-webkit-scrollbar { width: 8px; }
.logs::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }

/* ============================================================ BIBLIOTHÈQUE */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 4px 0 16px; font-size: 14px;
}
.breadcrumb a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); cursor: pointer; padding: 4px 9px; border-radius: 7px;
  transition: color .15s, background .15s;
}
.breadcrumb a:hover { color: var(--accent); background: var(--accent-soft); }
.breadcrumb a:last-child { color: var(--txt); }
.breadcrumb .sep { color: var(--line); }
.breadcrumb .i { width: 13px; height: 13px; }

.lib-list { display: flex; flex-direction: column; gap: 7px; }
.lib-row {
  display: flex; align-items: center; gap: 13px; padding: 12px 16px;
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  animation: jobIn .3s ease backwards;
  transition: border-color .18s, transform .15s;
}
.lib-row:nth-child(2) { animation-delay: .02s; }
.lib-row:nth-child(3) { animation-delay: .04s; }
.lib-row:nth-child(4) { animation-delay: .06s; }
.lib-row:nth-child(5) { animation-delay: .08s; }
.lib-row .ic { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.lib-row.dir { cursor: pointer; }
.lib-row.dir:hover { border-color: var(--accent); transform: translateX(3px); }
.lib-row.dir:hover .ic, .lib-row.dir:hover .chev { color: var(--accent); }
.lib-row.file .ic { color: var(--accent); }
.lib-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lib-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.chev { width: 15px; height: 15px; color: var(--muted); transition: color .15s; }
.lib-row .actions { display: flex; gap: 7px; }
.lib-row a.dl { text-decoration: none; }

/* ============================================================ responsive */
@media (max-width: 640px) {
  header { padding: 10px 14px; flex-wrap: wrap; }
  .views { order: 3; width: 100%; justify-content: center; }
  main { padding: 20px 12px 60px; }
  .job-actions { flex-wrap: wrap; justify-content: flex-end; }
  .lib-row .actions { flex-direction: column; }
}
