/* ============================================
   VARIABLES & RESET
   ============================================ */

:root {
  --primary: #1a5fa8;
  --primary-dark: #144a87;
  --secondary: #6c757d;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --light: #f8f9fa;
  --dark: #2c3e50;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: var(--dark);
  line-height: 1.6;
}

/* ============================================
   PAGE DE CONNEXION
   ============================================ */

.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a5fa8 0%, #144a87 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  animation: slideUp 0.4s ease;
}

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

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header i {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--secondary);
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 24px;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
}

.login-form label i {
  margin-right: 8px;
  color: var(--primary);
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: var(--transition);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 168, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--secondary);
  cursor: not-allowed;
  transform: none;
}

.error-message {
  margin-top: 16px;
  padding: 12px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-message.hidden {
  display: none;
}

.login-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--secondary);
}

.login-footer p {
  margin: 4px 0;
}

.version {
  font-size: 12px;
  color: #aaa;
}

/* ============================================
   NAVIGATION ADMIN
   ============================================ */

.admin-nav {
  background: white;
  box-shadow: var(--shadow);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.nav-brand i {
  font-size: 24px;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--dark);
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a:hover {
  background: var(--light);
  color: var(--primary);
}

.nav-links a.active {
  background: var(--primary);
  color: white;
}

/* ============================================
   CONTENU PRINCIPAL
   ============================================ */

.admin-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

section {
  margin-bottom: 40px;
}

section h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

section h2 i {
  color: var(--primary);
}

/* ============================================
   STATISTIQUES
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  align-items: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.stat-icon.total { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.active { background: linear-gradient(135deg, #27ae60 0%, #219a52 100%); }
.stat-icon.expired { background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%); }
.stat-icon.revoked { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--secondary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--dark);
}

/* ============================================
   FORMULAIRES
   ============================================ */

.create-card,
.users-list {
  background: white;
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group label i {
  color: var(--primary);
}

.form-group input,
.form-group select {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 168, 0.1);
}

.btn-large {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-danger:hover {
  background: #c0392b;
}

/* ============================================
   RÉSULTAT GÉNÉRATION
   ============================================ */

.generated-result {
  margin-top: 32px;
  padding: 24px;
  background: #f0f9ff;
  border: 2px solid #3498db;
  border-radius: 12px;
}

.generated-result.hidden {
  display: none;
}

.result-success {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--success);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 24px;
}

.result-success i {
  font-size: 24px;
}

.result-field {
  margin-bottom: 20px;
}

.result-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}

.copy-field {
  display: flex;
  gap: 8px;
}

.copy-field input {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.btn-copy {
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy:hover {
  background: var(--primary-dark);
}

.qr-code {
  width: 250px;
  height: 250px;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin: 16px 0;
  display: block;
}

.result-info {
  margin-top: 20px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  font-size: 14px;
}

.result-info p {
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-info i {
  color: var(--info);
}

/* ============================================
   LISTE UTILISATEURS
   ============================================ */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.user-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.user-card:hover {
  box-shadow: var(--shadow-lg);
}

.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.user-email {
  font-weight: 600;
  font-size: 16px;
  color: var(--dark);
}

.user-status {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.status-active {
  background: #d4edda;
  color: #27ae60;
}

.status-expired {
  background: #fff3cd;
  color: #f39c12;
}

.status-revoked {
  background: #f8d7da;
  color: #e74c3c;
}

.user-info {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: 16px;
}

.user-info span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-info {
  background: #e3f2fd;
  color: #1976d2;
}

.btn-info:hover {
  background: #bbdefb;
}

.btn-warning {
  background: #fff3cd;
  color: #f39c12;
}

.btn-warning:hover {
  background: #ffe69c;
}

.btn-danger-outline {
  background: #f8d7da;
  color: #e74c3c;
}

.btn-danger-outline:hover {
  background: #f1aeb5;
}

/* ============================================
   FILTRES ET RECHERCHE
   ============================================ */

.filters-bar {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--secondary);
}

.search-box input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filters select {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

/* ============================================
   TABLEAU
   ============================================ */

.users-table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table thead {
  background: var(--light);
}

.users-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
  border-bottom: 2px solid var(--border);
}

.users-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.users-table tbody tr:hover {
  background: #f8f9fa;
}

.loading-row {
  text-align: center;
  padding: 40px !important;
  color: var(--secondary);
}

.token-display {
  font-family: monospace;
  font-size: 12px;
  color: var(--secondary);
  background: var(--light);
  padding: 4px 8px;
  border-radius: 4px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.btn-page {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-page:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-page:disabled {
  background: var(--secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

/* ============================================
   MODALS
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-small {
  max-width: 450px;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--light);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  padding: 24px;
}

.modal-form {
  padding: 24px;
}

.modal-actions {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.warning-text {
  padding: 12px;
  background: #fff3cd;
  border-left: 4px solid #f39c12;
  border-radius: 4px;
  margin: 16px 0;
  font-size: 14px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  padding: 16px 24px;
  background: var(--dark);
  color: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  z-index: 2000;
  animation: slideInRight 0.3s ease;
}

.toast.hidden {
  display: none;
}

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

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* ============================================
   LOADING
   ============================================ */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--secondary);
}

.fa-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .admin-nav {
    flex-direction: column;
    gap: 16px;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .admin-content {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
  }

  .users-table-container {
    overflow-x: auto;
  }

  .users-table {
    min-width: 800px;
  }
}
