/* ===========================================
   e-Navette - Référentiel SI Styles
   =========================================== */

/* Variables */
:root {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --panel: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --header-height: 56px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Main */
.referentiel-main {
  padding: 1.5rem 2rem;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  max-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
}

/* ===========================================
   Import Section
   =========================================== */
.import-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.import-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.import-info {
  flex: 0 0 auto;
}

.import-info h1 {
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.import-info h1 i {
  color: var(--accent);
}

.import-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.import-right {
  flex: 0 0 auto;
}

.btn-import,
.btn-sync {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.75rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-import {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--text);
}

.btn-import:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
}

.btn-import i {
  color: #a78bfa;
}

.btn-sync {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease, background 0.2s, border-color 0.2s;
}

.btn-sync.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.btn-sync:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn-sync i {
  color: #60a5fa;
}

/* ===========================================
   Filters Section
   =========================================== */
.filters-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-box i {
  color: var(--text-muted);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter-group select {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

/* Filter Tags */
.filter-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-tag:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.filter-tag i {
  font-size: 0.7rem;
}

.filter-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Tag variants */
.filter-tag.tag-to-sync.active {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-color: transparent;
}

.filter-tag.tag-pending.active {
  background: #f97316;
  border-color: #f97316;
}

.filter-tag.tag-new.active {
  background: #3b82f6;
  border-color: #3b82f6;
}

.filter-tag.tag-modified.active {
  background: var(--warning);
  border-color: var(--warning);
  color: #1e293b;
}

.filter-tag.tag-not-synced.active {
  background: #64748b;
  border-color: #64748b;
}

.filter-tag.tag-synced.active {
  background: var(--success);
  border-color: var(--success);
}

.filter-tag.tag-notified.active {
  background: var(--success);
  border-color: var(--success);
}

.filter-tag.tag-not-notified.active {
  background: #ef4444;
  border-color: #ef4444;
}

.filter-tag.tag-notes.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1e293b;
}

/* Switch Notification (3 positions) */
.notif-switch-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s ease;
}

.notif-switch-container:hover {
  border-color: var(--accent);
}

.notif-switch-container .switch-label {
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

/* Couleurs par défaut des icônes */
.notif-switch-container .switch-label-no {
  color: var(--accent);
}

.notif-switch-container .switch-label-yes {
  color: var(--success);
}

.notif-switch-container .switch-track {
  position: relative;
  width: 44px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  transition: background 0.2s ease;
}

.notif-switch-container .switch-thumb {
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s ease;
}

/* État neutre (tous) - curseur au centre */
.notif-switch-container.neutral .switch-thumb {
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-muted);
}

/* État "Notifié" - curseur à droite, vert */
.notif-switch-container.active-notified .switch-track {
  background: rgba(34, 197, 94, 0.3);
}
.notif-switch-container.active-notified .switch-thumb {
  left: calc(100% - 19px);
  transform: translateX(0);
  background: var(--success);
}
.notif-switch-container.active-notified .switch-label-yes {
  color: var(--success);
}

/* État "Non notifié" - curseur à gauche, bleu */
.notif-switch-container.active-not-notified .switch-track {
  background: rgba(59, 130, 246, 0.3);
}
.notif-switch-container.active-not-notified .switch-thumb {
  left: 3px;
  transform: translateX(0);
  background: var(--accent);
}

.filter-stats {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter-sync {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
}

.filter-stats .separator {
  color: var(--border);
}

/* Largeurs fixes pour éviter le décalage lors du changement singulier/pluriel */
#statsTotal {
  min-width: 45px;
  text-align: right;
}

#statsSynced {
  min-width: 95px;
  text-align: center;
}

#statsSelected {
  min-width: 85px;
  text-align: left;
}

/* ===========================================
   Table Section
   =========================================== */
.table-section {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
}

/* Custom scrollbar */
.table-container::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Firefox scrollbar */
.table-container {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
  z-index: 10;
}

th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable i {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.5;
}

th.sortable.asc i::before {
  content: "\f0de";
}

th.sortable.desc i::before {
  content: "\f0dd";
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

tr.selected {
  background: rgba(59, 130, 246, 0.1);
}

/* Lignes non éligibles à la synchronisation */
tr.no-sync {
  cursor: default;
  opacity: 0.7;
}

tr.no-sync:hover {
  background: transparent;
}

.checkbox-placeholder {
  display: inline-block;
  width: 16px;
  height: 16px;
}

.action-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--success);
  opacity: 0.6;
}

.action-placeholder i {
  font-size: 0.9rem;
}

/* Column widths */
.col-checkbox { width: 40px; text-align: center; }
.col-checkbox input[type="checkbox"] { cursor: pointer; }
.col-status {
  width: 100px;
  position: relative;
}
.col-si { width: 170px; }
.col-atlas { width: 110px; }
.col-botid { width: 80px; }
.col-owner { width: 225px; }
.col-siglum { width: 80px; }
.col-site { width: 100px; }
.col-category { width: 120px; }
.col-lifecycle { width: 160px; font-size: 0.8rem; }
.col-date { width: 90px; font-size: 0.8rem; color: var(--text-muted); }
.col-notes { width: 60px; text-align: center; }
.col-modified { width: 120px; font-size: 0.8rem; color: var(--text-muted); }
.col-notified { width: 80px; text-align: center; }
.col-actions { width: 100px; text-align: center; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-synced {
  background: var(--success-bg);
  color: var(--success);
}

.status-not-synced {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
}

.status-changed {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-pending {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.status-new {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

/* Indicateur NEW pour les nouveaux SI */
.new-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 1px 4px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  font-size: 0.5rem;
  font-weight: 700;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
  animation: newPulse 2s ease-in-out infinite;
  z-index: 1;
}

@keyframes newPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Bouton appliquer changements */
.btn-apply-changes {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  background: var(--success-bg);
  color: var(--success);
}

.btn-apply-changes:hover {
  background: var(--success);
  color: white;
}

/* Notification icons (paper plane) */
.notif-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.9rem;
  border: none;
  background: transparent;
}

.notif-icon.notified {
  background: var(--success-bg);
  color: var(--success);
}

.notif-icon.not-notified {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.notif-icon.not-notified:hover {
  background: rgba(59, 130, 246, 0.15);
  transform: scale(1.1);
}

.notif-icon.disabled {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  opacity: 0.5;
}

/* Email cell */
.email-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.email-cell .email-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-cell .email-original {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.15rem;
}

.btn-edit-email {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}

tr:hover .btn-edit-email {
  opacity: 1;
}

.btn-edit-email:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* BotId cell */
.botid-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.botid-cell .botid-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-edit-botid {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}

tr:hover .btn-edit-botid {
  opacity: 1;
}

.btn-edit-botid:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Action buttons */
.btn-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-row-action:hover {
  background: rgba(59, 130, 246, 0.15);
  transform: scale(1.1);
}

.btn-row-action.synced {
  border-color: var(--success);
  color: var(--success);
}

/* Actions group */
.actions-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* Notify button */
.btn-notify {
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  color: #3b82f6;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn-notify:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

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

/* Desync button */
.btn-desync {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1.5px solid #f59e0b;
  border-radius: 8px;
  color: #f59e0b;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-desync:hover {
  background: rgba(245, 158, 11, 0.15);
  transform: scale(1.1);
}

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

/* Empty states */
.empty-state,
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state.hidden,
.no-results.hidden {
  display: none;
}

.empty-state i,
.no-results i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state .hint {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ===========================================
   Modals
   =========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.modal-header i {
  font-size: 1.25rem;
  color: var(--warning);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

/* Changes modal */
.changes-intro {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.changes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.change-item {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.change-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.change-si-name {
  font-weight: 600;
  color: var(--text);
}

.change-field {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: 4px;
}

.change-values {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.change-old {
  color: var(--danger);
  text-decoration: line-through;
}

.change-arrow {
  color: var(--text-muted);
}

.change-new {
  color: var(--success);
}

/* Confirm modal list */
.confirm-list {
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.confirm-list.hidden {
  display: none;
}

.confirm-list-item {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
}

/* Edit email modal */
.modal-edit-email .modal-header i {
  color: var(--accent);
}

.edit-si-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

/* Modal édition ID BoT */
.modal-edit-botid {
  max-width: 360px;
}

.modal-edit-botid .modal-header {
  justify-content: center;
}

.modal-edit-botid .modal-header i {
  color: var(--warning);
}

.modal-edit-botid .modal-body {
  text-align: center;
}

.modal-edit-botid .modal-footer {
  justify-content: center;
}

.botid-input-group {
  margin-bottom: 1rem;
}

.botid-input-group label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.botid-input-group input {
  width: 120px;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.75rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  letter-spacing: 0.3rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.botid-input-group input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.botid-input-group input:focus {
  border-color: var(--accent);
}

.botid-input-group input::selection {
  background: transparent;
  color: var(--text);
}

.botid-input-group input.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.botid-error {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--danger);
}

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

.botid-current {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Bouton notes dans la colonne */
.btn-edit-notes {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  opacity: 0.3;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

tr:hover .btn-edit-notes {
  opacity: 0.7;
}

.btn-edit-notes:hover {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  opacity: 1;
}

.btn-edit-notes.has-notes {
  color: #f59e0b;
  opacity: 1;
  background: rgba(245, 158, 11, 0.15);
}

.btn-edit-notes.has-notes:hover {
  background: rgba(245, 158, 11, 0.25);
  transform: scale(1.1);
}

/* Modale édition notes */
.modal-edit-notes {
  max-width: 480px;
}

.modal-edit-notes .modal-header i {
  color: #f59e0b;
}

.modal-edit-notes textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.modal-edit-notes textarea:focus {
  border-color: var(--accent);
}

.modal-edit-notes textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.email-input-group {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.email-input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.email-domain {
  padding: 0.75rem 1rem;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.email-original {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.email-original span,
.email-current span {
  color: var(--text);
}

.email-current {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Contact select */
.contact-select-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contact-select-group label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.contact-select-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.contact-select-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.contact-select-group select option {
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem;
}

/* Sync errors modal */
.modal-sync-errors {
  max-width: 550px;
}

.modal-sync-errors .modal-header.error {
  background: rgba(239, 68, 68, 0.1);
  border-bottom-color: rgba(239, 68, 68, 0.3);
}

.modal-sync-errors .modal-header.error i {
  color: var(--danger);
}

.modal-sync-errors .modal-header.error h3 {
  color: var(--danger);
}

.sync-summary {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.sync-summary .success-count {
  color: var(--success);
  font-weight: 600;
}

.sync-summary .error-count {
  color: var(--danger);
  font-weight: 600;
}

.sync-errors-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sync-error-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
}

.sync-error-item i {
  color: var(--danger);
  margin-top: 2px;
  flex-shrink: 0;
}

.sync-error-item .error-content {
  flex: 1;
  min-width: 0;
}

.sync-error-item .error-si {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.sync-error-item .error-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-word;
}

/* ===========================================
   Validation Errors Modal
   =========================================== */
.modal-validation-errors {
  max-width: 650px;
}

.modal-validation-errors .modal-header.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border-bottom-color: rgba(239, 68, 68, 0.3);
}

.modal-validation-errors .modal-header.error i {
  color: var(--danger);
  font-size: 1.3rem;
}

.modal-validation-errors .modal-header.error h3 {
  color: var(--danger);
}

.validation-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  margin-bottom: 1.25rem;
}

.validation-summary i {
  color: var(--danger);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.validation-summary p {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
}

.validation-summary strong {
  color: var(--danger);
}

.validation-section {
  margin-bottom: 1.25rem;
}

.validation-section h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.validation-section h4 i {
  font-size: 0.85rem;
}

.validation-section h4 .fa-clone {
  color: var(--accent);
}

.validation-section h4 .fa-exclamation-triangle {
  color: var(--warning);
}

.validation-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.validation-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.validation-item.duplicate {
  border-left: 3px solid var(--accent);
}

.validation-item.missing {
  border-left: 3px solid var(--warning);
}

.validation-item.format {
  border-left: 3px solid var(--error);
}

.validation-item i {
  flex-shrink: 0;
  font-size: 0.8rem;
}

.validation-item.duplicate i {
  color: var(--accent);
}

.validation-item.missing i {
  color: var(--warning);
}

.validation-item.format i {
  color: var(--error);
}

.validation-item .line-num {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 55px;
}

.validation-item .error-text {
  color: var(--text);
  flex: 1;
  word-break: break-word;
}

.validation-item .error-text strong {
  color: var(--accent);
}

.validation-hint {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.validation-hint i {
  color: var(--accent);
  font-size: 1rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #475569;
}

/* Modal buttons - style discret */
.btn-modal-cancel,
.btn-modal-save {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-modal-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-modal-cancel:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-modal-save {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
}

.btn-modal-save:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.15);
}

.btn-modal-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-muted);
}

/* ===========================================
   Loading Overlay
   =========================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* ===========================================
   Toast
   =========================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 3000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

/* ===========================================
   Pagination
   =========================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  margin-top: auto;
  flex-shrink: 0;
}

.pagination.hidden {
  display: none;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 120px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0.5rem;
}

.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.pagination-page:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination-page.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pagination-ellipsis {
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-size select {
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 1024px) {
  .referentiel-main {
    padding: 1rem;
  }

  .filters-section {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .filter-stats {
    margin-left: 0;
    justify-content: center;
  }
}
