/* ─────────────────────────────────────────────────────────────
 * JURISTE.AI Notion Bridge — Style GTI v2
 * Genius Tech Intelligence – GTI Conseil SARL
 * Palette : rouge #C8102E, burnt-orange #D2691E, charcoal #2C2C2C
 * ────────────────────────────────────────────────────────────*/

:root {
  --gti-red: #C8102E;
  --gti-orange: #D2691E;
  --gti-charcoal: #2C2C2C;
  --gti-sand: #F5EFE6;
  --gti-success: #10B981;
  --gti-error: #EF4444;
  --gti-warn: #F59E0B;
  --transition: 200ms ease-out;
}

html {
  scroll-behavior: smooth;
}

html.dark {
  color-scheme: dark;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body,
html[dir="rtl"] body {
  font-family: 'Amiri', 'Traditional Arabic', serif;
}

/* ─── Scrollbar custom ─── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(44, 44, 44, 0.18); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200, 16, 46, 0.5); }
html.dark ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); }

/* ─── Loader initial ─── */
.spinner-bars { display: flex; gap: 4px; }
.spinner-bars span {
  width: 4px; height: 24px;
  background: linear-gradient(180deg, var(--gti-red), var(--gti-orange));
  border-radius: 2px;
  animation: bar-pulse 1.1s ease-in-out infinite;
}
.spinner-bars span:nth-child(2) { animation-delay: 0.15s; }
.spinner-bars span:nth-child(3) { animation-delay: 0.3s; }
.spinner-bars span:nth-child(4) { animation-delay: 0.45s; }

@keyframes bar-pulse {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ─── Spinner inline ─── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(200, 16, 46, 0.18);
  border-top-color: var(--gti-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.05) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 6px;
}
html.dark .skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Navigation links ─── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
  position: relative;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-link.active {
  background: linear-gradient(135deg, var(--gti-red), var(--gti-orange));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px -4px rgba(200, 16, 46, 0.55);
}
.nav-link .nav-counter {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
[dir="rtl"] .nav-link .nav-counter { margin-left: 0; margin-right: auto; }

/* ─── Cards ─── */
.gti-card {
  background: #fff;
  border-radius: 0.875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px -4px rgba(0, 0, 0, 0.06);
  transition: var(--transition);
}
.gti-card:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 8px 24px -8px rgba(0, 0, 0, 0.10); }
html.dark .gti-card { background: #18181b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--gti-orange); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--gti-red);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #a30c25; }

.btn-secondary {
  background: #e5e7eb;
  color: var(--gti-charcoal);
}
.btn-secondary:hover:not(:disabled) { background: #d1d5db; }
html.dark .btn-secondary { background: #3f3f46; color: #fafafa; }
html.dark .btn-secondary:hover:not(:disabled) { background: #52525b; }

.btn-ghost {
  background: transparent;
  color: var(--gti-charcoal);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.05); }
html.dark .btn-ghost { color: #f4f4f5; }
html.dark .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }

.btn-danger {
  background: var(--gti-error);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-icon {
  padding: 0.4rem;
  border-radius: 0.375rem;
  color: #6b7280;
  transition: var(--transition);
}
.btn-icon:hover { background: rgba(0, 0, 0, 0.06); color: var(--gti-charcoal); }
.btn-icon.danger:hover { background: rgba(200, 16, 46, 0.1); color: var(--gti-red); }
html.dark .btn-icon { color: #a1a1aa; }
html.dark .btn-icon:hover { background: rgba(255, 255, 255, 0.05); color: #f4f4f5; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f3f4f6;
  color: var(--gti-charcoal);
}
html.dark .badge { background: #3f3f46; color: #f4f4f5; }

.badge-tag    { background: rgba(210, 105, 30, 0.16); color: var(--gti-orange); }
.badge-status-ouvert    { background: rgba(16, 185, 129, 0.18); color: #047857; }
.badge-status-suspendu  { background: rgba(245, 158, 11, 0.2);  color: #b45309; }
.badge-status-juge      { background: rgba(99, 102, 241, 0.18); color: #4338ca; }
.badge-status-archive   { background: rgba(107, 114, 128, 0.22); color: #4b5563; }

/* ─── Form fields ─── */
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gti-charcoal);
  letter-spacing: 0.02em;
}
html.dark .form-field label { color: #d4d4d8; }

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  color: var(--gti-charcoal);
  transition: var(--transition);
}
html.dark .form-field input,
html.dark .form-field select,
html.dark .form-field textarea {
  background: #27272a; border-color: #3f3f46; color: #fafafa;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--gti-red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}

.form-field .field-error {
  font-size: 0.7rem;
  color: var(--gti-error);
  font-weight: 500;
}

/* ─── Table ─── */
.gti-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}
.gti-table thead th {
  background: var(--gti-charcoal);
  color: #fff;
  text-align: start;
  padding: 0.625rem 0.875rem;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
.gti-table thead th .sort-icon { opacity: 0.4; margin-inline-start: 4px; transition: var(--transition); }
.gti-table thead th[data-sort="asc"] .sort-icon,
.gti-table thead th[data-sort="desc"] .sort-icon { opacity: 1; color: var(--gti-orange); }

.gti-table tbody td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
html.dark .gti-table tbody td { border-color: #27272a; }

.gti-table tbody tr {
  transition: var(--transition);
}
.gti-table tbody tr:hover { background: rgba(210, 105, 30, 0.06); }
html.dark .gti-table tbody tr:hover { background: rgba(210, 105, 30, 0.10); }

.gti-table tbody tr.selected { background: rgba(200, 16, 46, 0.08); }

/* ─── Toasts ─── */
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  background: #fff;
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.25);
  border-inline-start: 4px solid var(--gti-red);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  animation: toast-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.success { border-inline-start-color: var(--gti-success); }
.toast.error   { border-inline-start-color: var(--gti-error); }
.toast.info    { border-inline-start-color: var(--gti-orange); }
html.dark .toast { background: #27272a; color: #fafafa; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
[dir="rtl"] .toast { animation-name: toast-in-rtl; }
@keyframes toast-in-rtl {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  animation: fade-in 0.2s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: #fff;
  border-radius: 0.875rem;
  box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
html.dark .modal-card { background: #18181b; color: #fafafa; }

.modal-card.size-sm { max-width: 28rem; }
.modal-card.size-md { max-width: 40rem; }
.modal-card.size-lg { max-width: 56rem; }
.modal-card.size-xl { max-width: 72rem; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Icônes Lucide auto-resize ─── */
[data-lucide] { width: 1em; height: 1em; }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #6b7280;
}
.empty-state .empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(210, 105, 30, 0.12);
  color: var(--gti-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

/* ─── Stat cards ─── */
.stat-card {
  position: relative;
  padding: 1.25rem;
  background: #fff;
  border-radius: 0.875rem;
  border: 1px solid rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: var(--transition);
}
html.dark .stat-card { background: #18181b; border-color: rgba(255, 255, 255, 0.05); }
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(210, 105, 30, 0.06));
  pointer-events: none;
}
.stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 0.5rem;
}
.stat-card .stat-icon {
  position: absolute;
  inset-inline-end: 1rem;
  top: 1rem;
  width: 36px; height: 36px;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 16, 46, 0.12);
  color: var(--gti-red);
}

/* ─── Tag input chips ─── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(210, 105, 30, 0.18);
  color: var(--gti-orange);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag-chip button {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: inherit;
  font-size: 0.875rem;
  line-height: 1;
}

/* ─── Search highlight ─── */
mark.gti-mark {
  background: rgba(245, 158, 11, 0.35);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* ─── Accessibilité ─── */
:focus-visible {
  outline: 2px solid var(--gti-orange);
  outline-offset: 2px;
}

.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;
}

/* ─── Responsive sidebar ─── */
@media (max-width: 768px) {
  #sidebar.collapsed-mobile {
    transform: translateX(-100%);
  }
  [dir="rtl"] #sidebar.collapsed-mobile {
    transform: translateX(100%);
  }
}
