/* ════════════════════════════════════════════════════
   ProxiPass - Design System
   Variables, reset, utilitaires partagés
════════════════════════════════════════════════════ */

/* ── Google Fonts (DM Sans) ─────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&display=swap');

/* ── Variables CSS ───────────────────────────────── */
:root {
  /* Couleurs primaires */
  --color-primary:     #4F46E5;
  --color-primary-mid: #7C3AED;
  --color-primary-end: #9333EA;

  /* Gradient principal */
  --gradient-primary: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #9333EA 100%);
  --gradient-hero:    linear-gradient(160deg, #0F0F2D 0%, #1E1B4B 40%, #312E81 100%);
  --gradient-card:    linear-gradient(135deg, rgba(79,70,229,0.08) 0%, rgba(147,51,234,0.05) 100%);

  /* Accent */
  --color-accent:  #F59E0B;
  --color-accent2: #EC4899;

  /* Neutres */
  --color-bg:       #F8FAFC;
  --color-surface:  #FFFFFF;
  --color-border:   #E5E7EB;
  --color-border-s: #F1F5F9;

  /* Textes */
  --color-text:    #1E293B;
  --color-text-2:  #475569;
  --color-text-3:  #94A3B8;

  /* Sémantiques */
  --color-success: #10B981;
  --color-error:   #EF4444;
  --color-warning: #F59E0B;
  --color-info:    #3B82F6;

  /* Typographie */
  --font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs:  11px;
  --font-size-sm:  13px;
  --font-size-base: 14px;
  --font-size-md:  15px;
  --font-size-lg:  18px;
  --font-size-xl:  22px;
  --font-size-2xl: 28px;
  --font-size-3xl: 36px;

  /* Rayons */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Ombres */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.10);
  --shadow-glow: 0 4px 24px rgba(79,70,229,0.18);
  --shadow-card: 0 2px 12px rgba(79,70,229,0.08);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-mid:  250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --sidebar-width: 256px;
  --topbar-height: 64px;
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Typographie ─────────────────────────────────── */
h1 { font-size: var(--font-size-2xl); font-weight: 700; line-height: 1.2; letter-spacing: -0.5px; }
h2 { font-size: var(--font-size-xl);  font-weight: 700; line-height: 1.3; letter-spacing: -0.3px; }
h3 { font-size: var(--font-size-lg);  font-weight: 600; line-height: 1.4; }
h4 { font-size: var(--font-size-md);  font-weight: 600; }

.text-sm   { font-size: var(--font-size-sm); }
.text-xs   { font-size: var(--font-size-xs); }
.text-lg   { font-size: var(--font-size-lg); }
.text-xl   { font-size: var(--font-size-xl); }
.text-2xl  { font-size: var(--font-size-2xl); }
.text-muted { color: var(--color-text-3); }
.text-secondary { color: var(--color-text-2); }
.text-primary { color: var(--color-primary); }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ── Gradient text ───────────────────────────────── */
.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Boutons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(79,70,229,0.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(79,70,229,0.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 1.5px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-card);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-2);
}
.btn-ghost:hover { background: var(--color-border-s); color: var(--color-text); }

.btn-sm { padding: 6px 14px; font-size: var(--font-size-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 32px; font-size: var(--font-size-lg); border-radius: var(--radius-lg); }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── Formulaires ─────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-2);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-label .required { color: var(--color-error); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: white;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control::placeholder { color: var(--color-text-3); }
.form-control.error { border-color: var(--color-error); }

.form-hint {
  margin-top: 5px;
  font-size: var(--font-size-sm);
  color: var(--color-text-3);
}

/* Checkbox custom */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin-top: 2px;
}
.form-check-label { font-size: var(--font-size-sm); color: var(--color-text-2); line-height: 1.5; }

/* Color input */
input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border-s);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-s);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-s);
  background: var(--color-bg);
}

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-error   { background: rgba(239,68,68,0.12);  color: #DC2626; }
.badge-warning { background: rgba(245,158,11,0.12); color: #D97706; }
.badge-info    { background: rgba(59,130,246,0.12); color: #2563EB; }
.badge-primary { background: rgba(79,70,229,0.12);  color: var(--color-primary); }
.badge-neutral { background: var(--color-border-s); color: var(--color-text-2); }

/* ── Alerts ──────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: 16px;
}
.alert-success { background: rgba(16,185,129,0.1);  color: #065F46; border: 1px solid rgba(16,185,129,0.2); }
.alert-error   { background: rgba(239,68,68,0.1);   color: #991B1B; border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: rgba(245,158,11,0.1);  color: #92400E; border: 1px solid rgba(245,158,11,0.2); }
.alert-info    { background: rgba(59,130,246,0.1);  color: #1E40AF; border: 1px solid rgba(59,130,246,0.2); }

/* ── Tables ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border-s); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--color-bg); }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--color-border-s);
}
td {
  padding: 14px 16px;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-s);
  color: var(--color-text);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-bg); }

/* ── Utilitaires de layout ───────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }

.rounded    { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.overflow-hidden { overflow: hidden; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Avatar ──────────────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}
.avatar-lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }

/* ── Divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border-s);
  margin: 24px 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text-3);
  font-size: var(--font-size-sm);
  margin: 20px 0;
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Loading spinner ─────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(79,70,229,0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,15,45,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--transition-mid);
  pointer-events: none;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-mid);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-2);
  font-size: 18px;
}
.modal-close:hover { background: var(--color-border); }

/* ── Dropdown ────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: all var(--transition-fast);
}
.dropdown-menu.show { opacity: 1; transform: translateY(0); pointer-events: all; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--color-bg); }
.dropdown-item.danger { color: var(--color-error); }
.dropdown-divider { height: 1px; background: var(--color-border-s); margin: 4px 0; }

/* ── Stat card ───────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--color-border-s);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100px;
  background: var(--gradient-card);
  border-radius: 0 0 0 100%;
  opacity: 0.6;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 22px;
}
.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label { font-size: var(--font-size-sm); color: var(--color-text-3); }
.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin-top: 8px;
}
.stat-change.positive { color: var(--color-success); }
.stat-change.negative { color: var(--color-error); }

/* ── Flash message ───────────────────────────────── */
.flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flash {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  max-width: 380px;
}
.flash-success { background: white; border-left: 4px solid var(--color-success); color: var(--color-text); }
.flash-error   { background: white; border-left: 4px solid var(--color-error);   color: var(--color-text); }
.flash-warning { background: white; border-left: 4px solid var(--color-warning); color: var(--color-text); }

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

/* ── Pagination ──────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0;
}
.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  background: white;
  cursor: pointer;
  color: var(--color-text-2);
  text-decoration: none;
}
.page-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.page-btn.active { background: var(--gradient-primary); border-color: transparent; color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: var(--font-size-xl); }
  h2 { font-size: var(--font-size-lg); }
  .btn-lg { padding: 12px 24px; font-size: var(--font-size-md); }
}
