/* ================================================================
   ImageForge — Feuille de styles principale
   Auteur  : ImageForge
   Version : 1.0
================================================================ */

/* ── Variables CSS ── */
:root {
  --bg:           #0c0c14;
  --surface:      rgba(255, 255, 255, 0.04);
  --surface-hover:rgba(255, 255, 255, 0.07);
  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --accent:       #8b5cf6;
  --accent-end:   #c026d3;
  --accent-glow:  rgba(139, 92, 246, 0.25);
  --text:         #f0f0f8;
  --text-muted:   #6b7280;
  --text-secondary: #9ca3af;
  --success:      #10b981;
  --error:        #ef4444;
  --warning:      #f59e0b;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ── */
html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 70% 50% at 15% 40%, rgba(139, 92, 246, 0.09) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 15%, rgba(192, 38, 211, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 50% 90%, rgba(59, 130, 246, 0.05) 0%, transparent 60%);
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(1.5);
  background: rgba(12, 12, 20, 0.75);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border);
}

.nav-active {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.25);
}

.logo-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.logo-name {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #ddd6fe, #f5d0fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* .logo-tag conservé pour rétrocompatibilité éventuelle */
.logo-tag {
  display: none;
}

/* ── Layout principal ── */
.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px;
  display: grid;
  grid-template-columns: 1fr 370px;
  gap: 20px;
}

@media (max-width: 880px) {
  .main { grid-template-columns: 1fr; }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  backdrop-filter: blur(12px);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Zone de dépôt ── */
.drop-zone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  opacity: 0;
  transition: opacity 0.25s;
}

.drop-zone:hover,
.drop-zone.over {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.3), 0 0 40px rgba(139, 92, 246, 0.1);
}

.drop-zone.over { transform: scale(1.01); }
.drop-zone.over::before { opacity: 0.07; }
.drop-zone > * { position: relative; z-index: 1; }

.drop-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(192, 38, 211, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.drop-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.drop-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.drop-types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.type-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* ── En-tête liste ── */
.file-list-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.file-list-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.file-list-title span { color: var(--accent); font-weight: 600; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-ghost:hover { border-color: rgba(239, 68, 68, 0.4); color: var(--error); }

/* ── Liste des fichiers ── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.file-list::-webkit-scrollbar { width: 5px; }
.file-list::-webkit-scrollbar-track { background: transparent; }
.file-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 11px;
  transition: background 0.2s;
}

.file-item:hover { background: rgba(255, 255, 255, 0.055); }

.file-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.thumb-placeholder {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.new-name-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* ── Badges de statut ── */
.status-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.s-pending { background: rgba(107, 114, 128, 0.15); color: #6b7280; }
.s-loading { background: rgba(245, 158, 11, 0.15);  color: #f59e0b; }
.s-done    { background: rgba(16, 185, 129, 0.15);   color: #10b981; }
.s-error   { background: rgba(239, 68, 68, 0.15);    color: #ef4444; }

.btn-remove {
  background: none;
  border: none;
  padding: 5px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

.btn-remove:hover { color: var(--error); }

/* ── Colonne paramètres ── */
.settings { display: flex; flex-direction: column; gap: 18px; }

/* ── Grille des formats ── */
.format-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.fmt-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 11px 6px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  transition: all 0.2s;
  position: relative;
}

.fmt-btn:hover:not(.fmt-disabled) {
  border-color: rgba(139, 92, 246, 0.45);
  color: var(--text);
  background: rgba(139, 92, 246, 0.07);
}

.fmt-btn.fmt-active {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.15);
}

.fmt-btn.fmt-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Badge indiquant traitement PHP côté serveur */
.fmt-badge-srv {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(16, 185, 129, 0.9);
  color: #000;
  padding: 1px 5px;
  border-radius: 20px;
}

/* Badge format non disponible */
.fmt-badge-na {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(107, 114, 128, 0.9);
  color: #fff;
  padding: 1px 5px;
  border-radius: 20px;
}

/* ── Qualité ── */
.quality-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quality-label { font-size: 13px; color: var(--text-secondary); }
.quality-val   { font-size: 13px; font-weight: 700; color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  cursor: pointer;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── Zone de mots-clés ── */
.keywords-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 13px;
  transition: border-color 0.2s;
  cursor: text;
}

.keywords-box:focus-within { border-color: rgba(139, 92, 246, 0.5); }

.kw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.28);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  animation: tagIn 0.2s ease;
}

@keyframes tagIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.kw-tag-del {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.kw-tag-del:hover { opacity: 1; }

.kw-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  min-width: 160px;
}

.kw-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.combo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Bouton de sélection de dossier (conservé pour rétrocompat CSS) ── */
.folder-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 12px 15px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  transition: all 0.2s;
}

.folder-btn:hover:not(.f-zip)  { border-color: var(--border-hover); color: var(--text); }
.folder-btn.f-selected         { border-color: rgba(16, 185, 129, 0.35); color: var(--success); }
.folder-btn.f-zip              { border-color: rgba(139, 92, 246, 0.25); color: var(--accent); opacity: 0.85; }

.folder-ico   { font-size: 22px; flex-shrink: 0; }
.folder-label { font-size: 13px; font-weight: 500; }

.folder-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* ── Mode de téléchargement ── */
.dl-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dl-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all 0.2s;
}

.dl-mode-btn:hover:not(.dl-mode-active) {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.05);
}

.dl-mode-btn.dl-mode-active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.14);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.12);
}

.dl-mode-ico {
  font-size: 24px;
}

.dl-mode-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.dl-mode-btn.dl-mode-active .dl-mode-label {
  color: var(--accent);
}

.dl-mode-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.api-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.12);
  border-radius: 8px;
  line-height: 1.5;
}

/* ── Barre de stats ── */
.stats-row {
  display: none;
  gap: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}

.stat {
  flex: 1;
  padding: 10px 14px;
  border-right: 1px solid var(--border);
}

.stat:last-child { border-right: none; }

.stat-lbl { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.stat-val  { font-size: 14px; font-weight: 600; }

/* ── Progression ── */
.progress-wrap         { display: none; }
.progress-wrap.visible { display: block; }

.progress-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-end));
  border-radius: 20px;
  transition: width 0.35s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 7px;
}

/* ── Bouton principal ── */
.convert-btn {
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 22px rgba(139, 92, 246, 0.3);
}

.convert-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 7px 30px rgba(139, 92, 246, 0.4);
}

.convert-btn:active:not(:disabled) { transform: translateY(0); }

.convert-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Toasts ── */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 12px;
  min-width: 260px;
  max-width: 360px;
  background: rgba(18, 18, 28, 0.96);
  border: 1px solid var(--border);
  font-size: 13px;
  backdrop-filter: blur(16px);
  animation: toastIn 0.3s ease;
}

.toast.t-success { border-color: rgba(16, 185, 129, 0.35); }
.toast.t-error   { border-color: rgba(239, 68, 68, 0.35); }
.toast.t-info    { border-color: rgba(139, 92, 246, 0.35); }
.toast.leaving   { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn  {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(16px); opacity: 0; }
}

/* ── Utilitaires ── */
.action-col { display: flex; flex-direction: column; gap: 12px; }

.empty-hint {
  text-align: center;
  padding: 28px 20px;
  font-size: 13px;
  color: var(--text-muted);
}

@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut   { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp   { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
