/**
 * app-unified.css - Styles pour l'application unifiée e-Navette
 */

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-darker: #151f2e;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3a9d93;
  --accent-light: #5eead4;
  --nav: #3b82f6;
  --danger: #dc3545;
  --success: #22c55e;
  --warning: #ffc107;
  --info: #0d6efd;

  --sidebar-width: 280px;
  --sidebar-collapsed: 0px;
  --header-height: 56px;
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--panel-darker);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

::-webkit-scrollbar-corner {
  background: var(--panel-darker);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--panel-darker);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  height: var(--header-height);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.header-brand:hover {
  opacity: 0.85;
}

.header-brand i {
  font-size: 1.5rem;
}

/* Bouton pour ouvrir la sidebar (visible quand sidebar fermée) */
.sidebar-open-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 16px;
  transition: all 0.2s;
}

.sidebar-open-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--accent);
}

.sidebar-open-btn i {
  margin-right: 8px;
}

/* Afficher le bouton quand sidebar est fermée */
.si-sidebar.collapsed ~ .main-content .sidebar-open-btn,
body.sidebar-collapsed .sidebar-open-btn {
  display: inline-flex;
  align-items: center;
}

/* Titre central dans le header (admin) */
.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.admin-header-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-center h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-center h1 i {
  color: var(--accent);
}

/* View Toggle (Dashboard/Kanban) */
.view-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  gap: 4px;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.view-toggle-btn.active {
  background: var(--accent);
  color: white;
}

/* Survol Admin (inactif) = style card avec bordure cyan */
a.view-toggle-btn[href="admin.html"]:not(.active):hover {
  background: rgba(58, 157, 147, 0.08);
  box-shadow: inset 0 0 0 1px rgba(58, 157, 147, 0.5);
}

/* Survol Kanban (inactif) = style card avec bordure bleue */
a.view-toggle-btn[href="kanban.html"]:not(.active):hover {
  background: rgba(59, 130, 246, 0.08);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.5);
}

/* Navigation SI dans le header */
.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  margin-left: 20px;
}

.header-si-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
  padding: 6px 14px;
  background: rgba(58, 157, 147, 0.15);
  border-radius: 6px;
  border: 1px solid rgba(58, 157, 147, 0.3);
  margin-right: 24px;
}

.nav-sections {
  display: flex;
  gap: 32px;
  flex: 1;
  justify-content: center;
}

.nav-section {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 4px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nav-section:hover {
  color: var(--text);
}

.nav-section.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.nav-section i {
  font-size: 1rem;
  color: inherit;
}

.nav-section.active i {
  color: var(--accent-light);
}

/* Bouton Discussions avec layout 3 colonnes : [pastille bleue] [icone+texte] [pastille rouge] */
.nav-section.nav-discussions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-discussions-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Style commun des pastilles header */
.nav-discussions .nav-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 9px;
  color: white;
}

/* Pastille bleue (nouveaux topics) - colonne gauche */
.nav-badge.nav-badge-topic {
  background: #3b82f6;
  animation: navBadgePulseBlue 2s ease-in-out infinite;
}

/* Pastille rouge (réponses) - colonne droite */
.nav-badge.nav-badge-msg {
  background: var(--danger);
  animation: navBadgePulseRed 2s ease-in-out infinite;
}

@keyframes navBadgePulseRed {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 8px 2px rgba(220, 53, 69, 0.3);
    transform: scale(1.05);
  }
}

@keyframes navBadgePulseBlue {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.3);
    transform: scale(1.05);
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.user-badge:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
}

.user-badge i {
  font-size: 1.2rem;
  color: var(--accent);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ============================================================
   BOUTONS ADMIN DIRECT (mode détail SI)
   ============================================================ */
.admin-direct-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-direct-actions.hidden {
  display: none;
}

.btn-save-changes,
.btn-close-window {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-save-changes:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn-save-changes:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-close-window {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-close-window:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* Mode admin direct: désactiver le lien logo */
body.admin-direct-mode .header-brand {
  pointer-events: none;
  cursor: default;
}

body.admin-direct-mode .header-brand:hover {
  opacity: 1;
}

/* Bouton Retour Admin (mode view) */
.admin-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.admin-back-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.admin-back-btn.hidden {
  display: none;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.si-sidebar {
  width: var(--sidebar-width);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.si-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

/* Sidebar complètement masquée (admin accédant directement à un SI) */
.si-sidebar.hidden {
  display: none;
}

/* Le bouton "Liste des SI" doit aussi être masqué */
body.sidebar-hidden .sidebar-open-btn {
  display: none !important;
}

.si-sidebar.collapsed .sidebar-title,
.si-sidebar.collapsed .sidebar-search input,
.si-sidebar.collapsed .si-card-info,
.si-sidebar.collapsed .si-card-notifications,
.si-sidebar.collapsed .sidebar-message span {
  display: none;
}

.si-sidebar.collapsed .sidebar-header h2 {
  justify-content: center;
}

.si-sidebar.collapsed .sidebar-search {
  padding: 8px;
  justify-content: center;
}

.si-sidebar.collapsed .si-card {
  padding: 12px 8px;
  justify-content: center;
}

.si-sidebar.collapsed .si-card-icon {
  margin-right: 0;
}

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

.sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.sidebar-header h2 i {
  color: var(--accent);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.si-sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-search input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--nav);
}

/* Croix de réinitialisation du champ de recherche (rouge) */
.sidebar-search input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f87171'%3E%3Cpath d='M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z'/%3E%3C/svg%3E") center/contain no-repeat;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sidebar-search input[type="search"]::-webkit-search-cancel-button:hover {
  opacity: 1;
}

.sidebar-message {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-message.error {
  color: var(--danger);
}

/* ============================================================
   SIDEBAR FILTERS (Admin)
   ============================================================ */
.sidebar-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.filter-row {
  margin-bottom: 8px;
}

.filter-row:last-of-type {
  margin-bottom: 0;
}

.filter-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  padding-right: 32px;
}

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

.filter-select option {
  background: var(--panel);
  color: var(--text);
}

.filter-count {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

#filteredCount {
  color: var(--accent-light);
  font-weight: 600;
}

.clear-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 4px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-filter-btn:hover {
  background: #ef4444;
  transform: scale(1.1);
}

.clear-filter-btn.hidden {
  display: none;
}

/* ============================================================
   SIDEBAR ACTIONS (Admin)
   ============================================================ */
.sidebar-actions {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
}

.sidebar-action-btn:hover {
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  transform: translateY(-1px);
}

.sidebar-action-btn.secondary {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.sidebar-action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--accent);
  transform: none;
}

/* ============================================================
   SI LIST & CARDS
   ============================================================ */
.si-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.si-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  background: var(--panel-darker);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.si-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}

.si-card.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--nav);
}

.si-card-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.si-card-info {
  flex: 1;
  min-width: 0;
}

.si-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-card-project {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.si-card-responsable {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.si-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.si-card-cat {
  font-size: 0.65rem;
  color: var(--primary);
  background: rgba(139, 92, 246, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
}

.si-card-assets {
  font-size: 0.65rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.si-card-assets i {
  font-size: 0.6rem;
}

.si-card-status {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}

/* Statuts onboarding avec couleurs correspondantes aux stat-cards */
.si-card-status.status-preparation {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

.si-card-status.status-validation {
  background: rgba(147, 197, 253, 0.2);
  color: #93c5fd;
}

.si-card-status.status-flux {
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
}

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

.si-card-status.status-sft {
  background: rgba(37, 99, 235, 0.2);
  color: #2563eb;
}

.si-card-status.status-onboarded {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

/* Notifications badges on SI card */
.si-card-notifications {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.notif-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  color: white;
  font-weight: 600;
}

.notif-badge.support { background: var(--danger); }
.notif-badge.evolution { background: var(--warning); color: #1e293b; }
.notif-badge.libre { background: var(--info); }

.notif-badge i {
  font-size: 0.6rem;
}

/* Pastille de notification changement de statut (SI Owner/Délégation) */
.si-card-status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  animation: statusBadgePulse 2s ease-in-out infinite;
}

.si-card-status-badge.status-badge-forward {
  background: #22c55e; /* Vert - progression positive */
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.si-card-status-badge.status-badge-backward {
  background: #ef4444; /* Rouge - régression */
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

@keyframes statusBadgePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
}

/* Pastilles de notifications messages non lus */
/* Pastille rouge (réponse à topic) - à droite */
.si-card-msg-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
  animation: msgBadgePulseRed 2s ease-in-out infinite;
}

/* Pastille bleue (nouveau topic) - à gauche */
.si-card-topic-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #3b82f6;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
  animation: msgBadgePulseBlue 2s ease-in-out infinite;
}

@keyframes msgBadgePulseRed {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  }
}

@keyframes msgBadgePulseBlue {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
  }
}

/* ============================================================
   SIDEBAR DRAG & DROP (ordre personnalisé SI)
   ============================================================ */
.si-card[draggable="true"] {
  cursor: grab;
}

.si-card[draggable="true"]:active {
  cursor: grabbing;
}

.si-card.dragging {
  opacity: 0.5;
  background: rgba(59, 130, 246, 0.2);
  border: 2px dashed var(--nav);
  cursor: grabbing;
}

.si-card-placeholder {
  height: 70px;
  margin-bottom: 6px;
  background: rgba(59, 130, 246, 0.1);
  border: 2px dashed var(--nav);
  border-radius: 10px;
  transition: all 0.15s ease;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 1rem;
}

/* ============================================================
   WELCOME PAGE (User)
   ============================================================ */
.welcome-user {
  background: linear-gradient(180deg, var(--bg) 0%, var(--panel-darker) 100%);
  flex-direction: row;
  gap: 60px;
}

/* Flèche animée vers la sidebar */
.welcome-arrow {
  display: flex;
  align-items: center;
  margin-top: -70px;
  animation: bounce-left 1.5s ease-in-out infinite;
}

.welcome-arrow i {
  font-size: 4rem;
  color: var(--accent);
  opacity: 0.8;
}

@keyframes bounce-left {
  0%, 100% {
    transform: translateX(0);
    opacity: 0.8;
  }
  50% {
    transform: translateX(-20px);
    opacity: 1;
  }
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-icon {
  width: 150px;
  height: 150px;
  min-width: 150px;
  min-height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #2dd4bf 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(58, 157, 147, 0.3);
}

.welcome-icon i {
  font-size: 5rem;
  color: white;
  opacity: 1;
  margin: 0;
  width: auto;
  height: auto;
}

.welcome-user h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.welcome-subtitle {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 0 !important;
}

/* Responsive: flèche au-dessus sur mobile */
@media (max-width: 768px) {
  .welcome-user {
    flex-direction: column;
    gap: 30px;
  }

  .welcome-arrow {
    animation: bounce-up 1.5s ease-in-out infinite;
  }

  .welcome-arrow i {
    transform: rotate(90deg);
  }

  @keyframes bounce-up {
    0%, 100% {
      transform: translateY(0);
      opacity: 0.8;
    }
    50% {
      transform: translateY(-15px);
      opacity: 1;
    }
  }
}

/* ============================================================
   SI CONTENT
   ============================================================ */
.si-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.si-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.si-info h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.si-project {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ============================================================
   TABS
   ============================================================ */
.si-tabs {
  display: flex;
  gap: 4px;
}

.si-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.si-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.si-tab.active {
  background: var(--nav);
  color: white;
}

.si-tab i {
  font-size: 1rem;
}

.tab-badge {
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.si-tab.active .tab-badge {
  background: white;
  color: var(--nav);
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  gap: 10px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

/* ============================================================
   IFRAME CONTAINERS (pour Cartographie et Discussions)
   ============================================================ */
.tab-iframe-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.tab-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

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

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

.loading-text {
  color: var(--muted);
  margin: 0;
}

/* ============================================================
   TAB CONTENT STYLES
   ============================================================ */

/* Error state */
.tab-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--danger);
  font-size: 1rem;
}

/* ============================================================
   REFERENCES PAGE - NEW RESPONSIVE LAYOUT
   ============================================================ */

.references-page {
  padding: 32px 40px;
  height: 100%;
  overflow-y: auto;
}

/* Grille 2x2 */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}

/* Historique - largeur normale (1 colonne) */
.ref-card-history {
  grid-column: span 1;
}

/* Cards */
.ref-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}

.ref-card-empty {
  opacity: 0.7;
}

.ref-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  height: 60px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.ref-card-header i {
  color: var(--accent);
  font-size: 1.1rem;
}

.ref-card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.ref-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ref-tag.optional {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.ref-tag.required {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.ref-tag.readonly {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ref-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.ref-card-body {
  padding: 20px 22px;
  flex: 1;
}

/* Items de données */
.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ref-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ref-item-required:last-child {
  margin-bottom: 10px;
}

.ref-item:first-child {
  padding-top: 0;
}

.ref-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.ref-value {
  font-size: 0.95rem;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.ref-value.ref-email {
  color: var(--accent-light) !important;
  font-size: 0.9rem;
}

/* Emails dans la section Notification */
.ref-notification-grid .ref-value.ref-email {
  color: var(--accent-light) !important;
}

/* Bouton de copie pour les emails */
.ref-copyable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  color: var(--accent-light);
  opacity: 1;
  background: rgba(94, 234, 212, 0.1);
}

.copy-btn.copied {
  color: var(--success);
  opacity: 1;
}

.copy-btn.copied i::before {
  content: "\f00c"; /* fa-check */
}

/* Notice vide */
.ref-empty-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.ref-empty-notice i {
  font-size: 2.5rem;
  opacity: 0.3;
}

.ref-empty-notice span {
  font-size: 0.9rem;
}

/* Notification grid - le conteneur utilise la grille CSS via ref-view-mode/ref-edit-mode */
.ref-notification-grid {
  /* Les enfants (ref-view-mode, ref-edit-mode) gèrent leur propre grille */
}

.ref-item-wide {
  grid-column: span 2;
}

/* Bouton d'édition */
.ref-edit-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ref-edit-btn:hover {
  background: rgba(58, 157, 147, 0.15);
  color: var(--accent-light);
}

.ref-edit-btn.hidden {
  display: none;
}

/* Validation erreur sur input */
.ref-edit-field input.input-error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.ref-edit-field input.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.field-error {
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 6px;
}

/* Hints et indicateurs obligatoires */
.ref-required-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--warning, #f59e0b);
  margin-top: 4px;
}

.ref-required-hint i {
  font-size: 0.75rem;
}

.ref-required-star {
  color: var(--danger);
  font-weight: 600;
}

.ref-field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Aligner les hauteurs des cards sur la première ligne */
#infoSICard,
#ownerCard {
  min-height: auto;
  overflow: visible;
}

#infoSICard .ref-card-body {
  padding-bottom: 48px !important;
  overflow: visible !important;
}

#infoSICard .ref-view-mode {
  overflow: visible;
}

/* Forcer une seule colonne pour Informations SI */
#infoSICard .ref-view-mode:not(.hidden),
#infoSICard .ref-edit-mode:not(.hidden) {
  display: block !important;
  grid-template-columns: unset !important;
}

/* Répartir les lignes SI Owner sur toute la hauteur */
#ownerCard {
  display: flex;
  flex-direction: column;
}

#ownerCard .ref-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
}

#ownerCard .ref-card-body > .ref-item {
  flex: 1;
  display: flex;
  align-items: center;
}

/* Champ obligatoire avec tag inline */
.ref-item-required {
  background: rgba(239, 68, 68, 0.05);
  border-radius: 8px;
  padding: 12px !important;
  border: 1px dashed rgba(239, 68, 68, 0.3);
  margin: 0 -12px 20px -12px;
}

/* Valeur requise : tag et bouton à droite */
.ref-value-required {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ref-value-required .ref-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
}

/* Bouton crayon inline (dans le label) */
.ref-edit-btn-inline {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.ref-edit-btn-inline:hover {
  background: rgba(58, 157, 147, 0.15);
  color: var(--accent-light);
}

/* Card en mode édition */
.ref-card.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(58, 157, 147, 0.2);
  overflow: visible;
}

/* Mode admin direct : champs toujours éditables */
.ref-card.always-edit-mode {
  border-color: var(--border);
}

.ref-card.always-edit-mode .ref-edit-mode {
  display: grid !important;
}

/* Modes view/edit */
.ref-view-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  grid-column: span 2;
}

.ref-edit-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  grid-column: span 2;
}

.ref-view-mode.hidden,
.ref-edit-mode.hidden,
.ref-delegation-edit.hidden {
  display: none !important;
}

/* Délégation view/edit modes */
.ref-delegation-view {
  display: flex;
  flex-direction: column;
}

.ref-delegation-edit {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Liste des membres de délégation (mode lecture) */
.delegation-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.delegation-member {
  padding: 10px 12px;
  background: var(--panel-darker);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.delegation-member-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.delegation-member-name {
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
}

.delegation-member-email {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.delegation-member-siglum {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}

/* Mode édition - section membres sélectionnés */
.delegation-members-section {
  margin-top: 16px;
}

.delegation-members-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.delegation-edit-members {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delegation-edit-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--panel-darker);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.delegation-edit-member-name {
  font-size: 0.9rem;
  color: var(--text);
}

.delegation-remove-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.delegation-remove-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.delegation-empty-edit {
  text-align: center;
  color: var(--muted);
  padding: 12px;
  font-size: 0.85rem;
  font-style: italic;
}

/* Sélecteur dropdown */
.ref-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ref-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 157, 147, 0.15);
}

.ref-select option {
  background: var(--panel);
  color: var(--text);
}

/* Delegation Combobox */
.delegation-combobox {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: visible;
  position: relative;
}

.delegation-combobox-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.delegation-combobox-input i {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.delegation-combobox-input input::placeholder {
  color: var(--muted);
}

.delegation-combobox-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 350px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.delegation-combobox-list.hidden {
  display: none;
}

.delegation-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.delegation-option:last-child {
  border-bottom: none;
}

.delegation-option:hover {
  background: rgba(58, 157, 147, 0.1);
}

.delegation-option-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.delegation-option-email {
  font-size: 0.8rem;
  color: var(--muted);
}

.delegation-no-results {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Items dans view-mode - layout standard (label gauche, valeur droite) */
.ref-view-mode .ref-item {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ref-view-mode .ref-item:last-child {
  border-bottom: none;
}

.ref-view-mode .ref-item .ref-value {
  text-align: right;
}

/* Layout linéaire (une colonne, pas de grille) - spécifique pour #notificationCard */
/* Utiliser :not(.hidden) pour ne pas overrider la classe .hidden */
#notificationCard .ref-view-mode:not(.hidden),
#notificationCard .ref-edit-mode:not(.hidden),
#notificationCard.always-edit-mode .ref-edit-mode:not(.hidden) {
  display: block !important;
  grid-template-columns: unset !important;
}

/* Items dans la carte notification : label à gauche, valeur à droite */
#notificationCard .ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

#notificationCard .ref-item:last-child {
  border-bottom: none;
}

#notificationCard .ref-label {
  color: var(--muted);
  font-size: 0.9rem;
}

#notificationCard .ref-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* Champs d'édition dans #notificationCard */
#notificationCard .ref-edit-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

#notificationCard .ref-edit-field:last-of-type {
  border-bottom: none;
}

#notificationCard .ref-edit-field label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

#notificationCard .ref-edit-field input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

#notificationCard .ref-edit-field input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Champs d'édition */
.ref-edit-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}

.ref-edit-field:first-child {
  padding-top: 0;
}

.ref-edit-field label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ref-edit-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ref-edit-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 157, 147, 0.15);
}

.ref-edit-field input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* Actions d'édition */
.ref-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  grid-column: span 2;
}

.ref-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.ref-btn-cancel {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.ref-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

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

.ref-btn-save:hover {
  background: var(--accent-light);
}

.ref-btn-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Historique liste */
.ref-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-history-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
}

.ref-history-date {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.ref-history-date .history-date-main {
  color: var(--text);
  font-weight: 500;
}

.ref-history-date .history-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.ref-history-info {
  flex: 1;
  min-width: 0;
}

.ref-history-author {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.ref-history-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-history-version {
  font-size: 0.8rem;
  color: var(--accent-light);
  background: rgba(58, 157, 147, 0.15);
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
}

.ref-history-more {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 14px;
  cursor: pointer;
  margin-top: 4px;
}

.ref-history-more:hover {
  color: var(--accent-light);
}

.ref-no-data {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
  margin: 0;
}

/* Responsive: tablette */
@media (max-width: 1200px) {
  .references-page {
    padding: 28px 32px;
  }

  .ref-main-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  .ref-main-grid .ref-card:nth-child(3) {
    grid-column: span 2;
  }

  .ref-secondary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

/* Responsive: mobile */
@media (max-width: 768px) {
  .references-page {
    padding: 20px;
  }

  .ref-main-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .ref-main-grid .ref-card:nth-child(3) {
    grid-column: span 1;
  }

  .ref-secondary-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .ref-notification-grid {
    grid-template-columns: 1fr;
  }

  .ref-item-wide {
    grid-column: span 1;
  }

  .ref-history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .ref-history-version {
    align-self: flex-end;
  }

  .ref-card-header {
    padding: 16px 18px;
  }

  .ref-card-body {
    padding: 18px;
  }
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(58, 157, 147, 0.2);
  color: var(--accent-light);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Contacts */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.contact-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.contact-role {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.contact-email,
.contact-phone {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.contact-email i,
.contact-phone i {
  font-size: 0.7rem;
  color: var(--accent);
}

.no-data {
  color: var(--muted);
  font-style: italic;
  padding: 20px;
  text-align: center;
}

.ref-description {
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
}

/* Cartographie Tab */
.carto-container {
  padding: 24px;
}

.carto-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--muted);
}

.carto-empty i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.carto-section {
  margin-bottom: 24px;
}

.carto-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.carto-section h3 i {
  color: var(--accent);
}

.carto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.asset-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.asset-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.asset-type {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.asset-criticite {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.asset-criticite.crit-haute,
.asset-criticite.crit-high {
  background: rgba(220, 53, 69, 0.2);
  color: #f87171;
}

.asset-criticite.crit-moyenne,
.asset-criticite.crit-medium {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.asset-criticite.crit-basse,
.asset-criticite.crit-low {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

/* Discussions Tab */
.discussions-container {
  padding: 24px;
}

.discussions-header {
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #2563eb;
}

.discussions-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.disc-category {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.disc-category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--panel-darker);
  cursor: pointer;
}

.disc-cat-icon {
  font-size: 1rem;
}

.disc-cat-label {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.disc-cat-count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  color: white;
}

.disc-category-content {
  padding: 8px;
}

.no-topics {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px;
  margin: 0;
}

.disc-topic {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.disc-topic:hover {
  background: rgba(255, 255, 255, 0.05);
}

.disc-topic-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.disc-topic-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .si-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  .si-sidebar.open {
    transform: translateX(0);
  }

  .si-sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .header-nav {
    display: none;
  }

  .nav-section span:not(.nav-badge) {
    display: none;
  }
}


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

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

.modal-content {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 i {
  color: var(--accent);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-description {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.save-note-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.save-note-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 157, 147, 0.15);
}

.save-note-textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel-darker);
  border-radius: 0 0 12px 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

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

/* Modale de confirmation (warning) */
.modal-confirm {
  max-width: 480px;
}

.modal-header-warning {
  background: linear-gradient(135deg, #3d2a14 0%, #1e293b 100%);
  border-bottom: 1px solid rgba(251, 191, 36, 0.3);
}

.modal-header-warning h3 {
  color: #fbbf24;
}

.modal-header-warning h3 i {
  color: #f59e0b;
}

/* Liste des brouillons non envoyés */
.drafts-warning-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 8px;
  max-height: 150px;
  overflow-y: auto;
}

.drafts-warning-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
}

.drafts-warning-list li i {
  color: #fbbf24;
  font-size: 0.8rem;
}

.drafts-warning-list li + li {
  border-top: 1px solid rgba(251, 191, 36, 0.15);
}

/* Liste des modifications en attente */
.pending-changes-list {
  margin-top: 16px;
  max-height: 200px;
  overflow-y: auto;
}

.pending-changes-section {
  margin-bottom: 12px;
}

.pending-changes-section:last-child {
  margin-bottom: 0;
}

.pending-changes-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.pending-changes-title i {
  font-size: 0.9rem;
}

.pending-change-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.pending-change-item:last-child {
  margin-bottom: 0;
}

.pending-change-label {
  color: var(--muted);
  min-width: 100px;
  flex-shrink: 0;
}

.pending-change-value {
  color: var(--text);
  font-weight: 500;
}

.pending-change-arrow {
  color: var(--muted);
  margin: 0 6px;
}

.pending-change-old {
  color: #f87171;
  text-decoration: line-through;
  opacity: 0.7;
}

.pending-change-new {
  color: #4ade80;
  font-weight: 500;
}

/* Tableau des modifications avant/après */
.modal-changes-list {
  margin-top: 16px;
}

.changes-detail {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.changes-detail h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.changes-detail h4 i {
  font-size: 0.85rem;
}

.changes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.changes-table th,
.changes-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.changes-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.changes-table tbody tr:last-child td {
  border-bottom: none;
}

.changes-table .change-field {
  color: var(--text);
  font-weight: 500;
  min-width: 140px;
}

.changes-table .change-before {
  color: #f87171;
  max-width: 150px;
  word-break: break-word;
}

.changes-table .change-after {
  color: #4ade80;
  font-weight: 500;
  max-width: 150px;
  word-break: break-word;
}
