/* ============================================
   SIG SÉNÉGAL - DESIGN SYSTÈME MODERNE
   ============================================ */

:root {
  /* Palette Couleurs */
  --primary: #006633;           /* Vert Sénégal */
  --secondary: #ffcc00;         /* Jaune Sénégal */
  --accent: #10b981;            /* Émeraude lumineux */
  --dark: #0f172a;              /* Gris très foncé */
  --light: #f8fafc;             /* Blanc cassé */
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  
  /* Feedback */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* 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);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Sidebar */
  --sidebar-width: 360px;
  
  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-tooltip: 600;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --light: #1a1a2e;
    --gray-100: #2a2a3e;
    --gray-200: #3a3a4e;
    --gray-300: #4a4a5e;
    --gray-600: #b0b0c0;
    --gray-700: #c0c0d0;
    --gray-800: #e0e0f0;
  }
}

/* ============================================
   RESET & BASICS
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

body {
  display: flex;
  flex-direction: column;
}

/* Top Navbar */
#top-navbar {
  height: 65px;
  background: linear-gradient(135deg, var(--dark) 0%, var(--gray-800) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-fixed);
  gap: var(--spacing-xl);
}

#top-navbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

#top-navbar-title::before {
  content: '🗺️';
  font-size: 1.5rem;
}

/* Main Container */
.main-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-base);
  z-index: var(--z-sticky);
}

.sidebar.collapsed {
  margin-left: calc(var(--sidebar-width) * -1);
}

/* Map Container */
#map {
  flex: 1;
  position: relative;
  background: var(--gray-100);
}

/* ============================================
   NAVIGATION TABS
   ============================================ */

.nav-pills-custom {
  display: flex;
  background: linear-gradient(90deg, var(--gray-700) 0%, var(--gray-600) 100%);
  padding: var(--spacing-sm);
  gap: var(--spacing-xs);
  border-bottom: 1px solid var(--gray-200);
}

.nav-pills-custom .nav-link {
  flex: 1;
  padding: var(--spacing-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.nav-pills-custom .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-pills-custom .nav-link.active {
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Tab Content */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  scroll-behavior: smooth;
}

.tab-content::-webkit-scrollbar {
  width: 6px;
}

.tab-content::-webkit-scrollbar-track {
  background: var(--gray-100);
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ============================================
   CARDS & SECTIONS
   ============================================ */

.card, .stat-card, .control-panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover, .stat-card:hover, .control-panel:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}

.card-title, .stat-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.card-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--primary);
  border-radius: 2px;
}

/* Stat Cards */
.stat-card {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, var(--light) 0%, white 100%);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: var(--spacing-md) 0;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-600);
  font-weight: 500;
}

/* ============================================
   BUTTONS & CONTROLS
   ============================================ */

button, .btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  user-select: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

/* Primary Button */
.btn-primary, button:not([class]) {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 102, 51, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 102, 51, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-800);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

/* Danger Button */
.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Icon Buttons */
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--light);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-icon:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn-icon.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

input, select, textarea {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--gray-800);
  background: white;
  transition: all var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 51, 0.1);
  background: rgba(0, 102, 51, 0.02);
}

input::placeholder {
  color: var(--gray-400);
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: var(--spacing-sm);
  font-size: 0.875rem;
}

/* ============================================
   LEGENDS & LAYERS
   ============================================ */

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.legend-item:hover {
  background: var(--gray-100);
}

.legend-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.color-box {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--gray-300);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.legend-label {
  flex: 1;
  font-weight: 500;
  color: var(--gray-800);
}

/* ============================================
   MAP TOOLS
   ============================================ */

.map-tools {
  position: absolute;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: var(--z-fixed);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.map-tool-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all var(--transition-fast);
  font-weight: 600;
  color: var(--gray-700);
}

.map-tool-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

/* ============================================
   SEARCH CONTAINER
   ============================================ */

.search-container {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  position: relative;
}

.search-container input {
  flex: 1;
  padding: var(--spacing-md);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
}

.search-container input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 51, 0.1);
}

.search-container button {
  padding: var(--spacing-md) var(--spacing-lg);
}

/* ============================================
   NOTIFICATIONS & STATUS
   ============================================ */

.notification {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  background: white;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-md);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.success {
  border-left-color: var(--success);
}

.notification.warning {
  border-left-color: var(--warning);
}

.notification.error {
  border-left-color: var(--danger);
}

.notification-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.notification-content {
  flex: 1;
}

.notification-title {
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.notification-message {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: pulse 2s infinite;
}

.status-dot.online {
  background: var(--success);
}

.status-dot.offline {
  background: var(--danger);
  animation: none;
}

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

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

@media (max-width: 768px) {
  :root {
    --sidebar-width: 320px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
  }

  #top-navbar {
    height: 56px;
    padding: 0 var(--spacing-md);
  }

  #top-navbar-title {
    font-size: 1.1rem;
  }

  .main-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    flex-direction: row;
  }

  .nav-pills-custom {
    flex: 1;
    border-right: 1px solid var(--gray-200);
    border-bottom: none;
    flex-direction: column;
    width: auto;
    min-width: 150px;
  }

  .tab-content {
    flex: 1;
    padding: var(--spacing-md);
  }

  .map-tools {
    top: var(--spacing-md);
    right: var(--spacing-md);
    flex-direction: row;
  }

  .card, .stat-card {
    padding: var(--spacing-md);
  }

  input, select, textarea {
    font-size: 16px; /* Évite zoom iOS */
  }
}

@media (max-width: 480px) {
  :root {
    --sidebar-width: 280px;
    --spacing-lg: 12px;
    --spacing-md: 12px;
  }

  #top-navbar {
    height: 50px;
  }

  #top-navbar-title {
    font-size: 1rem;
  }

  .sidebar.collapsed {
    margin-left: calc(var(--sidebar-width) * -1);
  }

  .nav-pills-custom .nav-link {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
  }

  .map-tools {
    bottom: auto;
    top: auto;
    right: auto;
    left: var(--spacing-sm);
    bottom: var(--spacing-md);
    flex-direction: row;
  }

  .card, .stat-card {
    border-radius: var(--radius-md);
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus visible pour accessibilité */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.4);
  }

  .card, .stat-card {
    border: 2px solid var(--gray-800);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  #top-navbar,
  .sidebar,
  .map-tools,
  .search-container {
    display: none;
  }

  #map {
    width: 100%;
    height: 100%;
  }
}
