/* shadcn-inspired design tokens and primitives */
:root {
  --background: 255 255 255;
  --foreground: 17 24 39; /* gray-900 */
  --muted: 249 250 251; /* gray-50 */
  --muted-foreground: 75 85 99; /* gray-600 - meilleur contraste */
  --card: 255 255 255;
  --card-foreground: 17 24 39;
  --border: 229 231 235; /* gray-200 */
  --input: 243 244 246; /* gray-100 */
  --ring: 59 130 246; /* blue-500 */
  --primary: 29 78 216; /* blue-700 */
  --primary-foreground: 255 255 255;
  --secondary: 243 244 246; /* gray-100 */
  --secondary-foreground: 17 24 39; /* gray-900 */
  --destructive: 220 38 38; /* red-600 */
  --destructive-foreground: 255 255 255;
  --radius: 0.5rem; /* rounded-md */

  /* Couleurs Dropzone - Fichiers (bleu) */
  --drop-files-bg: hsl(210 40% 98%);
  --drop-files-bg-hover: hsl(213.1 93.9% 95%);
  --drop-files-bg-active: hsl(221.2 83.2% 53.3%);
  --drop-files-border: hsl(221.2 83.2% 53.3%);
  --drop-files-text: hsl(221.2 83.2% 53.3%);

  /* Couleurs Dropzone - Dossiers (orange) */
  --drop-folder-bg: hsl(48 96% 97%);
  --drop-folder-bg-hover: hsl(48 96% 92%);
  --drop-folder-bg-active: hsl(32.1 94.6% 43.7%);
  --drop-folder-border: hsl(32.1 94.6% 43.7%);
  --drop-folder-text: hsl(32.1 94.6% 43.7%);

  /* Couleurs Dropzone - État neutre/inconnu (violet) */
  --drop-unknown-bg: hsl(270 50% 98%);
  --drop-unknown-bg-hover: hsl(270 50% 95%);
  --drop-unknown-bg-active: hsl(262.1 83.3% 57.8%);
  --drop-unknown-border: hsl(262.1 83.3% 57.8%);
  --drop-unknown-text: hsl(262.1 83.3% 57.8%);
}

/* Mode sombre - activé via classe .dark sur html ou via préférences système */
.dark,
:root.dark {
  --background: 17 24 39; /* gray-900 */
  --foreground: 243 244 246; /* gray-100 */
  --muted: 31 41 55; /* gray-800 */
  --muted-foreground: 156 163 175; /* gray-400 */
  --card: 31 41 55; /* gray-800 */
  --card-foreground: 243 244 246; /* gray-100 */
  --border: 55 65 81; /* gray-700 */
  --input: 55 65 81; /* gray-700 */
  --ring: 96 165 250; /* blue-400 */
  --primary: 59 130 246; /* blue-500 */
  --primary-foreground: 255 255 255;
  --secondary: 55 65 81; /* gray-700 */
  --secondary-foreground: 243 244 246; /* gray-100 */
  --destructive: 248 113 113; /* red-400 */
  --destructive-foreground: 255 255 255;

  /* Couleurs Dropzone - Mode sombre */
  --drop-files-bg: hsl(217 33% 17%);
  --drop-files-bg-hover: hsl(217 33% 22%);
  --drop-files-bg-active: hsl(217 91% 60%);
  --drop-folder-bg: hsl(35 25% 15%);
  --drop-folder-bg-hover: hsl(35 30% 20%);
  --drop-folder-bg-active: hsl(32.1 94.6% 50%);
  --drop-unknown-bg: hsl(270 25% 15%);
  --drop-unknown-bg-hover: hsl(270 30% 20%);
  --drop-unknown-bg-active: hsl(262.1 83.3% 65%);
}

/* Préférences système automatiques (si pas de classe .dark/.light) */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --background: 17 24 39;
    --foreground: 243 244 246;
    --muted: 31 41 55;
    --muted-foreground: 156 163 175;
    --card: 31 41 55;
    --card-foreground: 243 244 246;
    --border: 55 65 81;
    --input: 55 65 81;
    --ring: 96 165 250;
    --primary: 59 130 246;
    --primary-foreground: 255 255 255;
    --secondary: 55 65 81;
    --secondary-foreground: 243 244 246;
    --destructive: 248 113 113;
    --destructive-foreground: 255 255 255;
    --drop-files-bg: hsl(217 33% 17%);
    --drop-files-bg-hover: hsl(217 33% 22%);
    --drop-folder-bg: hsl(35 25% 15%);
    --drop-folder-bg-hover: hsl(35 30% 20%);
    --drop-unknown-bg: hsl(270 25% 15%);
    --drop-unknown-bg-hover: hsl(270 30% 20%);
  }
}

html, body {
  background-color: rgb(var(--background));
  color: rgb(var(--foreground));
}

/* Card wrapper */
.card {
  background-color: rgb(var(--card));
  color: rgb(var(--card-foreground));
  border: 1px solid rgb(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  padding: 1rem;
}

/* Inputs */
.input, .textarea {
  width: 100%;
  background-color: rgb(var(--input));
  color: rgb(var(--foreground));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  font-size: 0.875rem; /* text-sm */
  padding: 0.625rem 0.75rem; /* p-2.5 */
  outline: none;
  transition: box-shadow .2s, border-color .2s, background-color .2s;
}
.input:focus, .textarea:focus {
  border-color: rgb(var(--ring));
  box-shadow: 0 0 0 4px rgba(59,130,246,.15);
  background-color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 2.5rem; /* h-10 */
  padding: 0 1rem; /* px-4 */
  border-radius: var(--radius);
  font-weight: 500; /* font-medium */
  font-size: 0.875rem; /* text-sm */
  border: 1px solid rgb(var(--border));
  background-color: rgb(var(--muted));
  color: rgb(var(--foreground));
  transition: background-color .2s, color .2s, border-color .2s, opacity .2s;
  cursor: pointer;
}
.btn:hover { background-color: #eef2ff; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background-color: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
  border-color: rgb(var(--primary));
}
.btn-primary:hover {
  background-color: rgb(37 99 235); /* blue-600 */
  border-color: rgb(37 99 235);
}

/* Secondary / Ghost / Outline / Danger variants (shadcn-like) */
.btn-ghost {
  background-color: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background-color: rgb(var(--muted));
  border-color: rgb(var(--border));
}
.btn-outline {
  background-color: transparent;
  border-color: rgb(var(--border));
}
.btn-outline:hover {
  background-color: #eef2ff;
}
.btn-danger, .btn-destructive {
  background-color: rgb(var(--destructive));
  color: rgb(var(--destructive-foreground));
  border-color: rgb(var(--destructive));
}
.btn-danger:hover, .btn-destructive:hover {
  background-color: rgb(185 28 28); /* red-700 */
  border-color: rgb(185 28 28);
}

/* Toast */
.toast {
  display: flex;
  align-items: center;
  gap: .5rem;
  background-color: #eff6ff; /* blue-50 */
  color: #1d4ed8; /* blue-700 */
  border: 1px solid #bfdbfe; /* blue-200 */
  border-radius: var(--radius);
  padding: .5rem .75rem;
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

/* Toast stack and variants */
.toast-stack {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  z-index: 9999;
  pointer-events: none; /* ne bloque pas les interactions de la page */
}
.toast-stack > .toast { pointer-events: auto; }
.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.is-hiding {
  opacity: 0;
  transform: translateY(8px);
}

/* largeur max responsive pour pile centrée */
.toast {
  max-width: min(92vw, 560px);
}
.toast--success {
  background-color: #ecfdf5; /* emerald-50 */
  color: #047857; /* emerald-700 */
  border-color: #a7f3d0; /* emerald-200 */
}
.toast--error {
  background-color: #fef2f2; /* red-50 */
  color: #b91c1c; /* red-700 */
  border-color: #fecaca; /* red-200 */
}
.toast--info {
  background-color: #eff6ff; /* blue-50 */
  color: #1d4ed8; /* blue-700 */
  border-color: #bfdbfe; /* blue-200 */
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 .5rem;
  height: 1.25rem; /* h-5 */
  border-radius: 9999px; /* rounded-full */
  font-size: .75rem; /* text-xs */
  border: 1px solid rgb(var(--border));
  background-color: rgb(var(--muted));
  color: rgb(var(--foreground));
}
.badge-primary {
  background-color: rgb(219 234 254); /* blue-100 */
  color: rgb(30 64 175); /* blue-800 */
  border-color: rgb(191 219 254); /* blue-200 */
}
.badge-success {
  background-color: rgb(236 253 245); /* emerald-50 */
  color: rgb(4 120 87); /* emerald-700 */
  border-color: rgb(167 243 208); /* emerald-200 */
}
.badge-danger {
  background-color: rgb(254 242 242); /* red-50 */
  color: rgb(185 28 28); /* red-700 */
  border-color: rgb(254 202 202); /* red-200 */
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: .5rem 1rem;
  border-bottom: 1px solid rgb(var(--border));
  text-align: left;
}
.table thead th {
  font-size: .75rem; /* text-xs */
  color: rgb(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Dropzone */
.dropzone {
  border: 2px dashed rgb(var(--border));
  background-color: rgb(var(--muted));
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  color: rgb(var(--muted-foreground));
  transition: background-color .2s, border-color .2s;
  cursor: pointer;
}
.dropzone.dragover {
  border-color: rgb(var(--ring));
  background-color: #f8fafc;
}

/* Progress bar */
.progress {
  width: 100%;
  height: 8px;
  background-color: rgb(var(--input));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background-color: rgb(var(--primary));
  transition: width .2s ease;
}

/* Text truncation utility */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Masked sensitive text (e.g., passwords) */
.masked {
  filter: blur(10px);
  user-select: none;
}

/* Optional animated Lion constellation background */
/* Enable by adding class="lion-constellation" on <body> */
.lion-constellation {
  background-color: #0b1020;
  color: #e5e7eb; /* keep text readable on dark */
}
.lion-constellation::before,
.lion-constellation::after {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
}
/* starfield */
.lion-constellation::before {
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.8), rgba(255,255,255,0)) 0 0/200px 200px,
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,.7), rgba(255,255,255,0)) 0 0/250px 250px,
    radial-gradient(1px 1px at 40% 80%, rgba(255,255,255,.6), rgba(255,255,255,0)) 0 0/180px 180px,
    radial-gradient(1px 1px at 85% 25%, rgba(255,255,255,.5), rgba(255,255,255,0)) 0 0/220px 220px,
    radial-gradient(2px 2px at 60% 10%, rgba(255,255,255,.9), rgba(255,255,255,0)) 0 0/260px 260px;
  opacity: .7;
  animation: twinkle 6s linear infinite;
}
/* subtle nebula */
.lion-constellation::after {
  background: radial-gradient(600px 400px at 70% 30%, rgba(99,102,241,.15), rgba(99,102,241,0)),
              radial-gradient(500px 300px at 20% 70%, rgba(16,185,129,.12), rgba(16,185,129,0));
  opacity: .4;
  animation: drift 30s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}

@keyframes drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(-10px, -10px, 0) scale(1.02); }
}
