/* ===== DASHBOARD MODERNE UNIFIÉ - ARCHITECTURE COMPLÈTE ===== */
/* Système CSS responsive de A à Z pour tous les appareils */

/* ===== VARIABLES CSS GLOBALES ===== */
:root {
  /* Palette de couleurs */
  --primary: #7289da;
  --primary-dark: #5b6eae;
  --primary-light: #8fa4e3;
  --primary-alpha: rgba(114, 137, 218, 0.1);
  
  --success: #43b581;
  --warning: #f6ad55;
  --danger: #f04747;
  --info: #3498db;
  
  /* Couleurs de fond */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-sidebar: #1a202c;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  
  /* Couleurs de texte */
  --text-primary: #1a202c;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Bordures */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-dark: #cbd5e1;
  
  /* Ombres */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  
  /* Espacements */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  
  /* Rayons */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Typographie */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;
  
  /* Transitions */
  --transition: all 0.2s ease-in-out;
  --transition-fast: all 0.15s ease-in-out;
  --transition-slow: all 0.3s ease-in-out;
  
  /* Layout */
  --sidebar-width: 280px;
  --header-height: 80px;
  --container-max: 1200px;
}

/* ===== RESET ET BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ===== LAYOUT PRINCIPAL ===== */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-body);
}

/* ===== SIDEBAR ===== */
.dashboard-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-inverse);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transform: translateX(0);
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-inverse);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  flex-shrink: 0;
}

.brand-name {
  font-size: var(--font-xl);
  font-weight: 700;
  white-space: nowrap;
}

.sidebar-nav {
  padding: var(--space-4) 0;
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-title {
  padding: 0 var(--space-6) var(--space-2);
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
}

.nav-item {
  margin: 0 var(--space-4) var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  transition: var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-inverse);
  transform: translateX(4px);
}

.nav-link.active {
  background-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ===== CONTENU PRINCIPAL ===== */
.dashboard-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

.dashboard-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  position: relative;
}

.mobile-menu-btn:hover {
  background-color: var(--bg-elevated);
}

.hamburger {
  width: 24px;
  height: 18px;
  position: relative;
  transform: rotate(0deg);
  transition: var(--transition-fast);
}

.hamburger span {
  display: block;
  position: absolute;
  height: 3px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: var(--transition-fast);
}

.hamburger span:nth-child(1) {
  top: 0px;
}

.hamburger span:nth-child(2) {
  top: 7px;
}

.hamburger span:nth-child(3) {
  top: 14px;
}

.mobile-menu-btn.active .hamburger span:nth-child(1) {
  top: 7px;
  transform: rotate(135deg);
}

.mobile-menu-btn.active .hamburger span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

.mobile-menu-btn.active .hamburger span:nth-child(3) {
  top: 7px;
  transform: rotate(-135deg);
}

.page-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-fast);
}

.user-menu:hover {
  background-color: var(--bg-body);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--primary-alpha);
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-role {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  line-height: 1.2;
}

/* ===== CONTENU DE LA PAGE ===== */
.dashboard-content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

/* ===== GRILLE DE STATISTIQUES ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  transition: var(--transition);
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--info));
  opacity: 0;
  transition: var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-alpha);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.stat-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
  opacity: 0.8;
}

.stat-value {
  font-size: var(--font-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: 1.1;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-sm);
  font-weight: 500;
}

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

.stat-change.negative {
  color: var(--danger);
}

/* ===== CARTES ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-6);
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition);
}

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

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

.card-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-content {
  padding: var(--space-6);
}

/* ===== BOUTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-sm);
  font-weight: 500;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: 44px;
  min-width: 44px;
  position: relative;
  overflow: hidden;
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

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

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

.btn-secondary:hover {
  background-color: var(--bg-body);
  border-color: var(--primary);
}

/* ===== OVERLAY MOBILE ===== */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-overlay);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== NOTIFICATIONS ===== */
.notification {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  max-width: 400px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  transform: translateX(100%);
  transition: var(--transition);
}

.notification.show {
  transform: translateX(0);
}

.notification-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.notification-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.notification-text {
  flex: 1;
}

.notification-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.notification-message {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

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

/* Tablettes */
@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .dashboard-sidebar {
    transform: translateX(-100%);
    z-index: 1001;
  }
  
  .dashboard-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  
  .dashboard-main {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobiles */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --header-height: 70px;
    --space-8: var(--space-6);
  }
  
  .dashboard-header {
    padding: 0 var(--space-4);
  }
  
  .dashboard-content {
    padding: var(--space-6) var(--space-4);
  }
  
  .page-title {
    font-size: var(--font-xl);
  }
  
  .user-info {
    display: none;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .stat-card {
    padding: var(--space-4);
  }
  
  .stat-value {
    font-size: var(--font-2xl);
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .card-header,
  .card-content {
    padding: var(--space-4);
  }
  
  .notification {
    top: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

/* Petits mobiles */
@media (max-width: 480px) {
  :root {
    --header-height: 60px;
    --space-6: var(--space-4);
  }
  
  .dashboard-header {
    padding: 0 var(--space-3);
  }
  
  .dashboard-content {
    padding: var(--space-4) var(--space-3);
  }
  
  .page-title {
    font-size: var(--font-lg);
  }
  
  .stat-card {
    padding: var(--space-3);
  }
  
  .stat-value {
    font-size: var(--font-xl);
  }
  
  .card-header,
  .card-content {
    padding: var(--space-3);
  }
  
  .btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-xs);
  }
}

/* Très petits écrans */
@media (max-width: 360px) {
  .dashboard-sidebar {
    width: 100vw;
  }
  
  .stat-card,
  .card-header,
  .card-content {
    padding: var(--space-2);
  }
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.stat-card,
.card {
  animation: slideIn 0.6s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* ===== OPTIMISATIONS ===== */
.dashboard-sidebar,
.dashboard-main,
.stat-card,
.card {
  will-change: transform;
}

/* ===== ACCESSIBILITÉ ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== MODE SOMBRE ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-elevated: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --border-dark: #1e293b;
  }
}

/* ===== CLASSES UTILITAIRES ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* Responsive utilities */
@media (max-width: 768px) {
  .hidden-mobile { display: none !important; }
  .visible-mobile { display: block !important; }
}

@media (min-width: 769px) {
  .hidden-desktop { display: none !important; }
  .visible-desktop { display: block !important; }
}