/* =============================================
   Admin Panel Styles
   ============================================= */

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.admin-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 24px;
}

/* ---- Stats Grid ---- */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.admin-stat-card {
  background: white;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.admin-stat-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: #146356;
  line-height: 1;
  margin-bottom: 6px;
}

.admin-stat-label {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

/* ---- Section Titles ---- */
.admin-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 14px;
}

/* ---- Table ---- */
.admin-table-wrapper {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
  margin-bottom: 32px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  background: #f9fafb;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.admin-table tbody tr:hover {
  background: #f9fafb;
}

/* User cell */
.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.admin-user-avatar-ph {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #146356;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.credits-zero-text {
  color: #B91C1C;
}

/* ---- Credits Input ---- */
.admin-credits-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.credits-input {
  width: 56px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: center;
}

.credits-input:focus {
  outline: none;
  border-color: #146356;
  box-shadow: 0 0 0 2px rgba(6,95,70,0.15);
}

.admin-add-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #146356;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.admin-add-btn:hover {
  background: #146356;
}

.admin-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Log Tabs ---- */
.admin-log-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.admin-log-tab {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-log-tab:hover {
  background: #e5e7eb;
  color: #374151;
}

.admin-log-tab.active {
  background: #146356;
  color: white;
}

/* ---- Log Table Extras ---- */
.log-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}

.log-query-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: #6b7280;
}

.log-error-text {
  color: #B91C1C;
}

/* ---- Logs Content ---- */
.admin-logs-wrapper {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
}

/* ---- Section Header ---- */
.admin-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-section-header .admin-section-title { margin: 0; }

.admin-user-count {
  font-size: 0.8rem;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 2px 10px;
  border-radius: 10px;
}

/* ---- Status Pills ---- */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Un seul état coloré : désactivé (vrai problème) — actif reste neutre. */
.status-active { background: #f1f5f9; color: #475569; }
.status-disabled { background: #fee2e2; color: #B91C1C; }

.text-red { color: #B91C1C; }

.user-inactive td { opacity: 0.5; }
.user-inactive td:last-child { opacity: 1; }

/* ---- Role Pills ---- */
.role-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
}
/* user/manager restent neutres ; seuls les rôles à privilèges élevés
   (admin/super_admin) ressortent, en rouge — un seul accent plutôt que 4. */
.role-pill.role-admin, .role-pill.role-super { background: #FEF2F2; color: #B91C1C; }

/* ---- Role Select ---- */
.role-select {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
  background: white;
  cursor: pointer;
  color: #374151;
}
.role-select:focus {
  outline: none;
  border-color: #146356;
  box-shadow: 0 0 0 2px rgba(6,95,70,0.15);
}
.role-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Plan Pills / Select ---- */
.plan-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
}
/* Premium = accent ambre dédié (déjà utilisé pour signaler "premium" ailleurs
   dans l'app) — distinct du rouge réservé aux rôles à privilèges élevés. */
.plan-pill.plan-premium { background: var(--accent-light, #FBEEE3); color: var(--accent, #C6741F); }

.plan-select {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
  background: white;
  cursor: pointer;
  color: #374151;
}
.plan-select:focus {
  outline: none;
  border-color: #146356;
  box-shadow: 0 0 0 2px rgba(6,95,70,0.15);
}
.plan-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Action Cells ---- */
.admin-actions-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-action-btns {
  display: flex;
  gap: 4px;
}

.admin-btn {
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  color: #374151;
}

.admin-btn:hover { background: #f3f4f6; }
.admin-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.admin-btn-add { background: #dcfce7; color: #0D9488; border-color: #bbf7d0; }
.admin-btn-add:hover { background: #bbf7d0; }

.admin-btn-remove { background: #fee2e2; color: #B91C1C; border-color: #fecaca; }
.admin-btn-remove:hover { background: #fecaca; }

.admin-btn-toggle { font-size: 0.72rem; }

/* ---- Log badge colors ---- */
/* Un seul accent (rouge = action destructrice/critique), le reste neutre —
   plus de vert/bleu/orange pour chaque verbe d'action. */
.log-badge-green, .log-badge-blue { background: #f1f5f9; color: #475569; }
.log-badge-red { background: #fee2e2; color: #B91C1C; }
.log-badge-orange { background: #f1f5f9; color: #475569; }

/* ---- Severity pills ---- */
.severity-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.severity-info, .severity-warning { background: #f1f5f9; color: #475569; }
.severity-critical { background: #fee2e2; color: #B91C1C; }

/* ---- Alert stat card flash ---- */
.admin-stat-alert {
  border: 2px solid #fca5a5;
  animation: alertPulse 2s infinite;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
  50% { box-shadow: 0 0 12px rgba(239,68,68,0.3); }
}

/* ---- Critical row highlight ---- */
.alert-row-critical {
  background: #fef2f2 !important;
}
.alert-row-critical:hover {
  background: #fee2e2 !important;
}

/* ---- Devices button ---- */
.admin-btn-devices {
  font-size: 0.72rem;
  background: #E3F1EE;
  color: #146356;
  border-color: #A7F3D0;
}
.admin-btn-devices:hover { background: #D7EAE6; }

/* ---- Modal ---- */
.admin-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

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

.admin-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  min-width: 500px;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.admin-modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.admin-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #9ca3af;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.admin-modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.admin-modal-body {
  padding: 16px 24px 24px;
}

.admin-modal-body code {
  font-size: 0.8rem;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  color: #6b7280;
}

/* ---- Projects button ---- */
.admin-btn-projects {
  font-size: 0.72rem;
  background: #f0fdf4;
  color: #0D9488;
  border-color: #bbf7d0;
}
.admin-btn-projects:hover { background: #dcfce7; }

/* ---- Wide modal for projects ---- */
.admin-modal-wide {
  min-width: 600px;
  max-width: 850px;
}

/* ---- Projects modal ---- */
.admin-projects-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-projects-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.admin-badge-active {
  background: #f1f5f9;
  color: #475569;
}

/* Seul badge de compte/projet qui reste coloré : suppression (destructif). */
.admin-badge-deleted {
  background: #fee2e2;
  color: #B91C1C;
}

/* Mode de recherche le plus utilisé (modale Statistiques) — seul accent vert. */
.admin-badge-highlight {
  background: var(--primary-light, #E3F1EE);
  color: var(--primary, #146356);
}

.admin-stats-hint {
  font-size: 0.82rem;
  color: #64748b;
  margin: 6px 0 0;
}

.admin-project-deleted-row {
  background: #fef2f2 !important;
}

.admin-project-deleted-row:hover {
  background: #fee2e2 !important;
}

.admin-text-strikethrough {
  text-decoration: line-through;
  opacity: 0.6;
}

.admin-text-muted {
  color: #d1d5db;
}

.text-orange {
  color: #d97706;
}

/* ---- Loading/Error ---- */
.admin-loading { text-align: center; padding: 24px; color: #9ca3af; }
.admin-error { text-align: center; padding: 24px; color: #B91C1C; }

/* Skeleton — même principe que .si-skeleton-block/.si-skeleton-line
   (public/css/styles-search-ia.css) : pulse neutre, pour les tableaux dont le
   chargement est perceptible (Users, Logs, Analytics). */
.admin-skeleton-block { padding: 18px 22px; }
.admin-skeleton-line {
  height: 12px; border-radius: 6px; margin-bottom: 10px;
  background: linear-gradient(90deg, #e2e8f0 25%, #eef2f7 37%, #e2e8f0 63%);
  background-size: 400% 100%;
  animation: admin-skeleton-shimmer 1.4s ease infinite;
}
.admin-skeleton-line:last-child { margin-bottom: 0; }
@keyframes admin-skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---- Recherche utilisateurs ---- */
.admin-user-search {
  padding: 8px 12px; border: 1px solid #e2e5e1; border-radius: 8px;
  font-size: 0.85rem; font-family: inherit; width: 220px;
}
.admin-user-search:focus { outline: none; border-color: #146356; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-modal-wide { min-width: auto; margin: 16px; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
  .admin-modal { min-width: auto; margin: 16px; }
}

@media (max-width: 480px) {
  .admin-stats-grid { grid-template-columns: 1fr; }
}

/* ---- Main Tabs (Data / Analytics) ---- */
.admin-main-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
}

.admin-main-tab {
  flex: 1;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: #6b7280;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.admin-main-tab:hover {
  color: #374151;
}

.admin-main-tab.active {
  background: white;
  color: #146356;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ---- Load More ---- */
.admin-load-more-wrap {
  text-align: center;
  padding: 16px;
}

.admin-load-more-btn {
  padding: 8px 28px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #E3F1EE;
  color: #146356;
  border: 1px solid #A7F3D0;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-load-more-btn:hover {
  background: #D7EAE6;
}

/* ---- Analytics Dashboard ---- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.analytics-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.analytics-card-wide {
  grid-column: 1 / -1;
}

.analytics-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 14px;
}

/* Bar Chart */
.analytics-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding-top: 10px;
}

.analytics-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.analytics-bar-value {
  font-size: 0.68rem;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 4px;
}

.analytics-bar {
  width: 100%;
  max-width: 36px;
  background: #146356;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.analytics-bar-label {
  font-size: 0.62rem;
  color: #9ca3af;
  margin-top: 6px;
  white-space: nowrap;
}

/* Rank List */
.analytics-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.analytics-rank-item:last-child {
  border-bottom: none;
}

.analytics-rank-pos {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #E3F1EE;
  color: #146356;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.analytics-rank-name {
  flex: 1;
  font-size: 0.82rem;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-rank-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}

/* Mini Bar */
.analytics-mini-bar {
  flex: 1;
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
}

.analytics-mini-bar-fill {
  height: 100%;
  background: #146356;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Search Types */
.analytics-donut-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analytics-type-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.analytics-type-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-type-label {
  flex: 1;
  font-size: 0.85rem;
  color: #374151;
}

/* Security Summary */
.analytics-security-summary {
  display: flex;
  gap: 20px;
}

.analytics-security-stat {
  text-align: center;
  flex: 1;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
}

.analytics-security-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: #146356;
  line-height: 1;
}

.analytics-security-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

/* Login List */
.analytics-login-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.analytics-login-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 0.82rem;
}

.analytics-login-email {
  font-weight: 600;
  color: #1f2937;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-login-date {
  color: #6b7280;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.analytics-login-details {
  color: #9ca3af;
  font-size: 0.72rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .analytics-card-wide {
    grid-column: 1;
  }
  .analytics-bars {
    height: 120px;
  }
}

/* ---- Admin archive badges and rows ---- */
.admin-badge-archived {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.admin-project-archived-row {
  background: #fffbeb;
}

.status-archived {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
