/* Master Hub — feuille de style unique, sans dépendance. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --error: #b42318;
  --error-soft: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e6e8ec;
    --muted: #98a2b3;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #23264a;
    --on-accent: #0f1115;
    --success: #47cd89;
    --success-soft: #0e2a1d;
    --warning: #fdb022;
    --warning-soft: #2e2210;
    --error: #f97066;
    --error-soft: #2d1414;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
a { color: var(--accent); }
code, kbd {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05em .35em;
}
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Barre du haut ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 650; color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: .95rem;
}
.brand-mark-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 1.3rem; }
.topnav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.topnav a {
  padding: .4rem .7rem; border-radius: 8px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.logout { display: flex; align-items: center; gap: .5rem; margin: 0; }

/* ---------- Mise en page ---------- */

.container { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.guest { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ---------- Connexion ---------- */

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-head h1 { margin-top: .75rem; font-size: 1.35rem; }
.auth-head p { margin: 0; }

/* ---------- Formulaires ---------- */

label { display: flex; flex-direction: column; gap: .35rem; font-weight: 550; font-size: .92rem; }
label small { font-weight: 400; }
input[type="text"], input[type="password"], select, textarea {
  font: inherit; font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: 1rem; height: 1rem; accent-color: var(--accent); }
label.inline { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; }
label.inline select { width: auto; }
fieldset.options { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem 1rem; margin: 0; display: grid; gap: .55rem; }
fieldset.options legend { padding: 0 .35rem; font-weight: 600; font-size: .85rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 550;
  padding: .5rem .95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); padding: .45rem; }
.btn-block { width: 100%; padding: .65rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Messages ---------- */

.alert {
  border-radius: 8px;
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: .92rem;
}
.alert-info { background: var(--accent-soft); color: var(--text); border-color: var(--border); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--error-soft); color: var(--error); }

.status { min-height: 1.4em; font-size: .9rem; color: var(--muted); }
.status[data-kind="success"] { color: var(--success); }
.status[data-kind="warning"] { color: var(--warning); }
.status[data-kind="error"] { color: var(--error); }
progress { width: 100%; height: 6px; accent-color: var(--accent); }

.badge {
  display: inline-block; vertical-align: middle;
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  padding: .1rem .45rem; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
}

/* ---------- Accueil ---------- */

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.tool-card {
  display: flex; flex-direction: column; gap: .45rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
a.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card.is-soon { opacity: .6; }
.tool-icon {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: .35rem;
}
.tool-title { font-weight: 650; }
.tool-desc { color: var(--muted); font-size: .9rem; }

/* ---------- Outils ---------- */

.tool-layout { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 1.25rem; align-items: start; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  text-align: center;
  padding: 2rem 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 400;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { color: var(--accent); font-size: 1.8rem; line-height: 1; }

.output { min-height: 70vh; }
.output-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.output textarea {
  flex: 1;
  min-height: 55vh;
  resize: vertical;
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.6;
  background: var(--surface-2);
}

.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; }
.thumbs:empty { display: none; }
.thumbs img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 2px solid var(--border);
}
.thumbs img[data-state="pending"] { opacity: .5; }
.thumbs img[data-state="done"] { border-color: var(--success); }
.thumbs img[data-state="error"] { border-color: var(--error); }

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: .5rem 1rem; padding: .6rem 1rem; }
  .topnav { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .container { padding: 1.25rem 1rem 2rem; }
  .tool-layout { grid-template-columns: 1fr; }
  .output { min-height: 0; }
  .output textarea { min-height: 40vh; }
}
