/* ========================================
   SOFATELCOM - DESIGN SYSTEM (V1.0)
   Consolidated stylesheet from 6 source files
   Includes: tokens + custom styles + forms + animations + mobile + tables
   ======================================== */

@import url('tokens-enhanced.css');
@import url('accessibility-wcag-aa.css');

/* ===== SOFATELCOM BRAND COLORS ===== */
:root {
  --sofatelcom-primary: #dc3545;
  --sofatelcom-secondary: #0d6efd;
  --sofatelcom-accent: #ffffff;
  --sofatelcom-dark: #212529;
  --sofatelcom-light: #f8f9fa;
  --sofatelcom-success: #198754;
  --sofatelcom-warning: #ffc107;
  --sofatelcom-info: #0dcaf0;
  --sofatelcom-danger: #dc3545;
}

/* ===== BRAND COLOR UTILITIES ===== */
.bg-sofatelcom-primary {
  background-color: var(--sofatelcom-primary) !important;
}

.bg-sofatelcom-secondary {
  background-color: var(--sofatelcom-secondary) !important;
}

.text-sofatelcom-primary {
  color: var(--sofatelcom-primary) !important;
}

.text-sofatelcom-secondary {
  color: var(--sofatelcom-secondary) !important;
}

/* ===== BUTTONS ===== */
.btn-sofatelcom-primary {
  background-color: var(--sofatelcom-primary);
  border-color: var(--sofatelcom-primary);
  color: white;
}

.btn-sofatelcom-primary:hover {
  background-color: #c02a37;
  border-color: #c02a37;
  color: white;
}

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

.btn-sofatelcom-secondary:hover {
  background-color: #0b5ed7;
  border-color: #0b5ed7;
  color: white;
}

/* ===== NAVBAR ===== */
.navbar-dark .navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
}

.navbar-dark .navbar-nav .nav-link {
  font-weight: 500;
  transition: all var(--duration-200) var(--ease-out);
}

.navbar-dark .navbar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
}

/* ===== CARDS ===== */
.card {
  border: none;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-300) var(--ease-out);
}

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

.card-header {
  border-bottom: 2px solid rgba(0, 0, 0, 0.125);
  font-weight: 600;
}

/* Clickable cards (statistics) */
.clickable-card {
  cursor: pointer;
  transition: transform var(--duration-200) var(--ease-in-out), box-shadow var(--duration-200) var(--ease-in-out);
}

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

/* Stat cards */
.stat-card {
  border-radius: 1rem;
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  border: 1px solid #e9ecef;
  transition: all var(--duration-300) var(--ease-out);
  padding: var(--space-lg);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

/* Stat card color variants */
.stat-card-primary .stat-icon { background-color: rgba(220, 53, 69, 0.1); }
.stat-card-secondary .stat-icon { background-color: rgba(13, 110, 253, 0.1); }
.stat-card-success .stat-icon { background-color: rgba(25, 135, 84, 0.1); }
.stat-card-warning .stat-icon { background-color: rgba(240, 173, 78, 0.1); }
.stat-card-danger .stat-icon { background-color: rgba(220, 53, 69, 0.1); }
.stat-card-info .stat-icon { background-color: rgba(13, 202, 240, 0.1); }

/* ===== BADGES ===== */
.badge-status-nouveau {
  background-color: var(--sofatelcom-danger) !important;
}

.badge-status-affecte {
  background-color: var(--sofatelcom-warning) !important;
  color: #000 !important;
}

.badge-status-en-cours {
  background-color: var(--sofatelcom-info) !important;
}

.badge-status-termine {
  background-color: var(--sofatelcom-secondary) !important;
}

.badge-status-valide {
  background-color: var(--sofatelcom-success) !important;
}

.badge-status-rejete {
  background-color: #6c757d !important;
}

/* ===== FORMS ===== */
.form-control,
.form-select {
  border-color: #dee2e6;
  transition: border-color var(--duration-200) var(--ease-out), box-shadow var(--duration-200) var(--ease-out);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-focus-ring);
  box-shadow: var(--shadow-focus);
}

.form-check-input:checked {
  background-color: var(--sofatelcom-primary);
  border-color: var(--sofatelcom-primary);
}

.form-control.is-invalid {
  border-color: var(--color-danger);
}

.form-control.is-invalid:focus {
  box-shadow: var(--shadow-focus-danger);
}

.form-control.is-valid {
  border-color: var(--color-success);
}

.form-control.is-valid:focus {
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* Form floating labels */
.form-floating > label {
  padding: var(--space-md) var(--space-md);
}

/* ===== ALERTS ===== */
.alert {
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 500;
}

.alert-dismissible .btn-close {
  padding: 0.875rem 1rem;
}

/* ===== TABLES ===== */
.table {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table thead th {
  background-color: var(--sofatelcom-light);
  border-bottom: 2px solid var(--sofatelcom-primary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.table tbody tr {
  transition: all var(--duration-200) var(--ease-out);
}

.table tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

/* Sortable columns */
.table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}

.table th[data-sortable]:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.table th.sort-asc::after {
  content: ' ↑';
}

.table th.sort-desc::after {
  content: ' ↓';
}

/* ===== MODALS ===== */
.modal-header {
  border-bottom: 2px solid #e9ecef;
}

.modal-title {
  font-weight: 600;
}

/* ===== PROGRESS ===== */
.progress {
  height: 0.75rem;
  border-radius: var(--radius-md);
}

.progress-bar {
  border-radius: var(--radius-md);
  transition: width var(--duration-600) var(--ease-out);
}

/* ===== SIGNATURE PAD ===== */
.signature-pad {
  background-color: #ffffff;
  border: 2px dashed #dee2e6;
  border-radius: var(--radius-lg);
  cursor: crosshair;
  touch-action: none;
}

.signature-pad:hover {
  border-color: var(--sofatelcom-primary);
}

.signature-container {
  position: relative;
  background: linear-gradient(145deg, #f8f9fa, #e9ecef);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.signature-clear {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 10;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== INTERVENTION SECTIONS ===== */
.intervention-section {
  border-left: 4px solid var(--sofatelcom-primary);
  background: linear-gradient(135deg, #f8f9fa, #ffffff);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-200) var(--ease-out);
}

.intervention-section:hover {
  box-shadow: var(--shadow-md);
}

.intervention-section h5 {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid rgba(220, 53, 69, 0.2);
}

.field-group {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-xs);
}

/* Survey section */
.survey-section {
  background: linear-gradient(135deg, #e7f3ff, #cce7ff);
  border: 2px solid var(--sofatelcom-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.survey-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--sofatelcom-primary), var(--sofatelcom-secondary));
}

/* ===== DISPATCHING ===== */
.demande-row {
  transition: all var(--duration-200) var(--ease-out);
}

.demande-row.selected {
  background-color: rgba(13, 110, 253, 0.1);
  border-left: 4px solid var(--sofatelcom-secondary);
}

.demande-checkbox:checked {
  transform: scale(1.1);
}

.urgent-row {
  border-left: 4px solid #dc3545;
  background-color: #fff8f8;
}

.urgent-row.animate-urgent {
  animation: blink var(--duration-700) var(--ease-in-out) infinite;
}

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

.fade-in {
  animation: fadeIn var(--duration-500) var(--ease-out);
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-left {
  animation: slideInLeft var(--duration-300) var(--ease-out);
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Button hover ripple effect */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width var(--duration-500) var(--ease-out), height var(--duration-500) var(--ease-out);
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Card hover lift */
.card {
  position: relative;
  overflow: hidden;
}

/* ===== MOBILE NAVIGATION ===== */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  background: white;
  box-shadow: var(--shadow-lg);
  transition: left var(--duration-300) var(--ease-out);
  z-index: var(--z-fixed);
  overflow-y: auto;
}

.mobile-nav-drawer.active {
  left: 0;
}

.mobile-nav-drawer .nav-link {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  color: #333;
  text-decoration: none;
  transition: all var(--duration-200) var(--ease-out);
}

.mobile-nav-drawer .nav-link:hover {
  background-color: var(--sofatelcom-light);
  padding-left: var(--space-xl);
}

.mobile-nav-drawer .nav-link.active {
  background-color: var(--sofatelcom-light);
  border-left: 4px solid var(--sofatelcom-primary);
  color: var(--sofatelcom-primary);
  font-weight: 600;
}

/* Touch target sizing (44px minimum) */
.mobile-nav-drawer .nav-link {
  min-height: 44px;
}

button,
.btn,
a[role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* ===== LOADING STATES ===== */
.loading {
  position: relative;
  color: transparent !important;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--sofatelcom-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Skeleton loading */
.placeholder-glow {
  animation: placeholder-glow var(--duration-2000) var(--ease-linear) infinite;
}

@keyframes placeholder-glow {
  50% { opacity: 0.5; }
}

/* ===== NOTIFICATIONS ===== */
.notification-dropdown .dropdown-item {
  padding: var(--space-md) var(--space-md);
  border-bottom: 1px solid #f0f0f0;
  transition: background-color var(--duration-200) var(--ease-out);
}

.notification-dropdown .dropdown-item:last-child {
  border-bottom: none;
}

.notification-dropdown .dropdown-item:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

.notification-item.unread {
  background-color: rgba(220, 53, 69, 0.05);
  border-left: 3px solid var(--sofatelcom-primary);
}

.notification-item.unread:hover {
  background-color: rgba(220, 53, 69, 0.1);
}

.notification-message {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  margin-bottom: var(--space-xs);
  color: #333;
}

.notification-count {
  font-size: var(--font-size-xs);
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  background-color: var(--sofatelcom-danger);
  color: white;
  position: relative;
  top: -8px;
  right: 8px;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--sofatelcom-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #c02a37;
}

/* ===== UTILITY CLASSES ===== */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.font-weight-medium { font-weight: var(--font-weight-medium); }
.font-weight-semibold { font-weight: var(--font-weight-semibold); }
.border-radius-lg { border-radius: var(--radius-xl); }
.shadow-soft { box-shadow: var(--shadow-lift-sm); }

.gradient-primary {
  background: linear-gradient(135deg, var(--sofatelcom-primary), #ff6b7a);
}

.gradient-secondary {
  background: linear-gradient(135deg, var(--sofatelcom-secondary), #4dabf7);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .intervention-section {
    padding: var(--space-md);
    border-left-width: 3px;
    margin-bottom: var(--space-md);
  }
  
  .field-group {
    padding: var(--space-md);
  }
  
  .signature-pad {
    height: 150px;
  }
  
  .navbar-brand {
    font-size: 1.25rem !important;
  }
  
  .card {
    margin-bottom: var(--space-md);
  }
  
  .table-responsive {
    border-radius: var(--radius-lg);
  }
  
  .notification-dropdown {
    min-width: 280px !important;
    max-width: 320px !important;
  }
  
  .notification-message {
    font-size: var(--font-size-xs);
  }
}

@media (max-width: 576px) {
  .intervention-section {
    padding: 0.75rem;
    border-left-width: 2px;
  }
  
  .field-group {
    padding: 0.75rem;
  }
  
  .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  
  .signature-pad {
    height: 120px;
  }
  
  .stat-card {
    padding: var(--space-md);
  }
  
  .table {
    font-size: 0.875rem;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .no-print {
    display: none !important;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }
  
  .intervention-section {
    break-inside: avoid;
    box-shadow: none;
  }
  
  .btn,
  .navbar {
    display: none;
  }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid #000;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* Dark mode support (for future implementation) */
@media (prefers-color-scheme: dark) {
  :root {
    --sofatelcom-light: #343a40;
    --sofatelcom-dark: #f8f9fa;
  }
}
