/**
 * 🎨 CRM ASLANE - RESPONSIVE REDESIGN 2026
 * Design System unifié - PC et Mobile
 * 
 * Version: 1.0.0
 * Date: 05/02/2026
 * Compatibilité: Chrome, Firefox, Safari, Mobile
 */

/* =============================================
   VARIABLES CSS - DESIGN TOKENS
   ============================================= */
:root {
  /* Spacing System - 8px base */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Typography Scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  
  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  
  /* Touch Targets - WCAG AAA */
  --touch-target-min: 44px;
  
  /* Breakpoints (pour référence) */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

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

/* =============================================
   CONTRASTE TEXTE AMÉLIORÉ (WCAG AA)
   ============================================= */

/* Force texte noir lisible sur fond clair */
body:not([data-role]) .card,
body:not([data-theme]) .card {
  color: #1a1a1a !important;
}

body:not([data-role]) .text-muted,
body:not([data-theme]) .text-muted {
  color: #4a4a4a !important; /* Plus foncé que #94a3b8 */
}

/* Labels de formulaire - TOUJOURS NOIR */
label,
.form-label {
  color: #000000 !important;
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
  display: block;
}

/* Inputs - Texte noir, placeholder gris foncé */
input,
select,
textarea {
  color: #000000 !important;
  font-size: var(--text-base) !important;
}

input::placeholder,
textarea::placeholder {
  color: #6b6b6b !important;
  opacity: 1 !important;
}

/* Titres - Force contraste */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
}

body[data-role="ADMIN"] h1,
body[data-role="ADMIN"] h2,
body[data-role="ADMIN"] h3,
body[data-role="TECH"] h1,
body[data-role="TECH"] h2,
body[data-role="TECH"] h3 {
  color: #111827 !important;
}

/* =============================================
   RESPONSIVE HEADER
   ============================================= */
.header {
  padding: var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.header h1 {
  font-size: var(--text-2xl);
  margin: 0;
  flex: 1 1 auto;
  min-width: 200px;
}

.header .header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Mobile Header */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header h1 {
    font-size: var(--text-xl);
    text-align: center;
  }
  
  .header .header-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .header .header-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* =============================================
   CONTAINER & GRID RESPONSIVE
   ============================================= */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-md);
}

@media (max-width: 640px) {
  .container {
    padding: var(--space-sm);
  }
}

/* Grid System Responsive */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   CARDS RESPONSIVE
   ============================================= */
.card {
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card h2 {
  margin-top: 0;
  margin-bottom: var(--space-md);
  font-size: var(--text-xl);
}

.card h3 {
  margin-top: 0;
  margin-bottom: var(--space-sm);
  font-size: var(--text-lg);
}

@media (max-width: 640px) {
  .card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }
  
  .card h2 {
    font-size: var(--text-lg);
  }
  
  .card h3 {
    font-size: var(--text-base);
  }
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

@media (max-width: 640px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
}

/* =============================================
   BOUTONS RESPONSIVE (Touch-Friendly)
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  min-height: var(--touch-target-min);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: #6B7280;
  color: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.btn-secondary:hover {
  background: #4B5563;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Boutons mobiles - pleine largeur */
@media (max-width: 640px) {
  .btn {
    width: 100%;
    padding: var(--space-md);
  }
  
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
  }
  
  .btn-group .btn {
    width: 100%;
  }
}

/* =============================================
   FORMULAIRES RESPONSIVE
   ============================================= */
.form-group {
  margin-bottom: var(--space-md);
}

.form-control {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  min-height: var(--touch-target-min);
  font-size: var(--text-base);
  border: 2px solid rgba(148, 163, 184, 0.3);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-sm) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: var(--space-xl);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* Checkbox & Radio - Touch-Friendly */
input[type="checkbox"],
input[type="radio"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  cursor: pointer;
}

@media (max-width: 640px) {
  input[type="checkbox"],
  input[type="radio"] {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
  }
}

/* =============================================
   TABLEAUX RESPONSIVE
   ============================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
}

th {
  padding: var(--space-md);
  text-align: left;
  font-weight: var(--font-semibold);
  white-space: nowrap;
  font-size: var(--text-sm);
}

td {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

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

/* Mobile: Table → Cards */
@media (max-width: 768px) {
  .table-responsive table {
    display: block;
  }
  
  .table-responsive thead {
    display: none;
  }
  
  .table-responsive tbody {
    display: block;
  }
  
  .table-responsive tr {
    display: block;
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }
  
  .table-responsive td {
    display: block;
    text-align: right;
    padding: var(--space-xs) var(--space-sm);
    border: none;
  }
  
  .table-responsive td::before {
    content: attr(data-label);
    float: left;
    font-weight: var(--font-semibold);
    color: #4a4a4a;
  }
}

/* =============================================
   BADGES RESPONSIVE
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .badge {
    font-size: var(--text-sm);
    padding: var(--space-xs) var(--space-md);
  }
}

/* =============================================
   MODALS RESPONSIVE
   ============================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: var(--z-modal);
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .modal-backdrop {
    padding: 0;
  }
  
  .modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .modal-footer {
    flex-direction: column-reverse;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

/* =============================================
   NAVIGATION MOBILE (Hamburger)
   ============================================= */
.mobile-nav-toggle {
  display: none;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  padding: var(--space-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.mobile-nav-toggle span {
  display: block;
  width: 24px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-nav-toggle.active span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.mobile-nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-nav-toggle.active span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: flex;
  }
}

/* =============================================
   UTILITIES SPACING
   ============================================= */
.p-0 { padding: 0 !important; }
.p-xs { padding: var(--space-xs) !important; }
.p-sm { padding: var(--space-sm) !important; }
.p-md { padding: var(--space-md) !important; }
.p-lg { padding: var(--space-lg) !important; }
.p-xl { padding: var(--space-xl) !important; }

.m-0 { margin: 0 !important; }
.m-xs { margin: var(--space-xs) !important; }
.m-sm { margin: var(--space-sm) !important; }
.m-md { margin: var(--space-md) !important; }
.m-lg { margin: var(--space-lg) !important; }
.m-xl { margin: var(--space-xl) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }

/* =============================================
   UTILITIES DISPLAY
   ============================================= */
.hidden { display: none !important; }
.block { display: block !important; }
.inline-block { display: inline-block !important; }
.flex { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.grid { display: grid !important; }

.flex-row { flex-direction: row !important; }
.flex-col { flex-direction: column !important; }
.items-center { align-items: center !important; }
.items-start { align-items: flex-start !important; }
.items-end { align-items: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }

.gap-xs { gap: var(--space-xs) !important; }
.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }
.gap-lg { gap: var(--space-lg) !important; }

/* =============================================
   UTILITIES TEXT
   ============================================= */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.text-xs { font-size: var(--text-xs) !important; }
.text-sm { font-size: var(--text-sm) !important; }
.text-base { font-size: var(--text-base) !important; }
.text-lg { font-size: var(--text-lg) !important; }
.text-xl { font-size: var(--text-xl) !important; }

.font-normal { font-weight: var(--font-normal) !important; }
.font-medium { font-weight: var(--font-medium) !important; }
.font-semibold { font-weight: var(--font-semibold) !important; }
.font-bold { font-weight: var(--font-bold) !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

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

/* Focus visible pour navigation clavier */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* =============================================
   PRINT STYLES
   ============================================= */
@media print {
  .header,
  .btn,
  .mobile-nav-toggle {
    display: none !important;
  }
  
  .card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #000;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
}

/* =============================================
   FIN RESPONSIVE REDESIGN
   ============================================= */
