/* NetExpress v2 Custom Styles - CDN Compatible */

:root {
  /* Palette principale vert NetExpress (#0e6a4c) */
  --ne-blue-50: #f0fdf7;
  --ne-blue-100: #d9f3e7;
  --ne-blue-200: #b3e7cf;
  --ne-blue-300: #8bdab6;
  --ne-blue-400: #63ce9e;
  --ne-blue-500: #3bc287;
  --ne-blue-600: #0e6a4c;
  --ne-blue-700: #0b563d;
  --ne-blue-800: #09422f;
  --ne-blue-900: #062d21;
  --ne-blue-950: #041b15;

  --ne-success: #22c55e;
  --ne-warning: #f59e0b;
  --ne-error: #ef4444;

  --ne-gray-50: #f9fafb;
  --ne-gray-100: #f3f4f6;
  --ne-gray-500: #6b7280;
  --ne-gray-800: #1f2937;

  --ne-primary: var(--ne-blue-600);
  --ne-primary-hover: var(--ne-blue-700);
  --ne-primary-strong: var(--ne-blue-800);
}

/* ==========================================================================
   ACCESSIBILITÉ
   ========================================================================== */

/* Screen Reader Only - visible uniquement aux lecteurs d'écran */
.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;
}

/* Visible au focus (pour skip links) */
.sr-only:focus,
.focus\:not-sr-only:focus {
  position: absolute;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Portal Navigation */
.portal-nav {
  background-color: #0e6a4c !important;
  color: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.portal-nav-item {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease-in-out;
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.portal-nav-item:hover {
  background-color: var(--ne-primary-hover);
  color: white;
  text-decoration: none;
}

.portal-nav-item.active {
  background-color: var(--ne-primary-strong);
  color: white;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.breadcrumb-nav a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

.breadcrumb-nav a:hover {
  color: #1e293b;
}

/* Cards */
.card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease-in-out;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.card-header {
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--ne-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
  background-color: #475569;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #334155;
  transform: translateY(-1px);
}

.btn-success {
  background-color: #059669;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #047857;
  transform: translateY(-1px);
}

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

.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
  transform: translateY(-1px);
}

.btn-outline {
  border: 2px solid var(--ne-primary);
  color: var(--ne-primary);
  background-color: transparent;
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--ne-primary);
  color: white;
  transform: translateY(-1px);
}

/* Forms */
.form-input {
  display: block;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease-in-out;
  font-size: 0.875rem;
}

.form-input:focus {
  border-color: var(--ne-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

.form-input:invalid {
  border-color: #dc2626;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}

.form-error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

/* Mobile menu */
.mobile-menu-button {
  padding: 0.5rem;
  border-radius: 0.375rem;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.mobile-menu-button:hover {
  background-color: var(--ne-primary-hover);
}

.mobile-menu {
  position: absolute;
  top: 4rem;
  left: 0;
  right: 0;
  background-color: var(--ne-primary);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 40;
}

/* Task cards */
.task-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  margin-bottom: 1rem;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
}

.task-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.task-card.urgent {
  border-left: 4px solid #dc2626;
}

.task-card.completed {
  background-color: #f0fdf4;
  border-left: 4px solid #059669;
}

.task-card.in-progress {
  border-left: 4px solid #f59e0b;
}

/* Document cards */
.document-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  margin-bottom: 1rem;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
}

.document-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.document-status {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.document-status.pending {
  background-color: #fef3c7;
  color: #92400e;
}

.document-status.validated {
  background-color: #dcfce7;
  color: #166534;
}

.document-status.paid {
  background-color: var(--ne-primary-100);
  color: var(--ne-primary-900);
}

.document-status.draft {
  background-color: var(--ne-gray-100);
  color: var(--ne-gray-800);
}

/* KPI cards */
.kpi-card {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  text-align: center;
  padding: 1.5rem;
  transition: all 0.2s ease-in-out;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.kpi-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--ne-primary);
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.5rem;
}

.kpi-trend {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.kpi-trend.up {
  color: var(--ne-success);
}

.kpi-trend.down {
  color: var(--ne-error);
}

/* Notifications */
/* Notifications inline (messages Django) */
.notification {
  position: relative;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  animation: slideInDown 0.3s ease-out;
}

/* Notifications fixed (créées par JavaScript) */
#notification-container .notification {
  position: relative;
  max-width: 24rem;
  animation: slideInRight 0.3s ease-out;
}

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

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

.notification.success {
  border-color: #bbf7d0;
  background-color: #f0fdf4;
}

.notification.error {
  border-color: #fecaca;
  background-color: #fef2f2;
}

.notification.info {
  border-color: #bfdbfe;
  background-color: #eff6ff;
}

.notification.warning {
  border-color: #fed7aa;
  background-color: #fffbeb;
}

/* HTMX loading states */
.htmx-indicator {
  display: none !important;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block !important;
}

.htmx-loading {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--ne-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: white;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.table th {
  background-color: #f9fafb;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
}

.table tbody tr:hover {
  background-color: #f9fafb;
}

/* Calendar styles */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
}

.calendar-day {
  background-color: white;
  padding: 0.75rem;
  min-height: 6rem;
  position: relative;
}

.calendar-day.other-month {
  background-color: #f9fafb;
  color: #9ca3af;
}

.calendar-day.today {
  background-color: #fef3c7;
}

.calendar-event {
  background-color: var(--ne-primary);
  color: white;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  cursor: pointer;
}

/* Responsive utilities */
@media (max-width: 640px) {
  .card-body {
    padding: 1rem;
  }
  
  .kpi-card {
    padding: 1rem;
  }
  
  .kpi-value {
    font-size: 1.5rem;
  }
  
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
  
  .table {
    font-size: 0.875rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem;
  }
  
  .notification {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

@media (max-width: 768px) {
  .mobile-menu-button {
    display: block;
  }
  
  .desktop-nav {
    display: none;
  }
  
  .calendar-grid {
    grid-template-columns: repeat(7, 1fr);
    font-size: 0.875rem;
  }
  
  .calendar-day {
    padding: 0.5rem;
    min-height: 4rem;
  }
  
  .task-card,
  .document-card {
    margin-bottom: 0.75rem;
  }
}

@media (min-width: 769px) {
  .mobile-menu-button {
    display: none;
  }
  
  .mobile-menu {
    display: none !important;
  }
  
  .desktop-nav {
    display: flex;
  }
}

@media (max-width: 1024px) {
  .kpi-card {
    text-align: center;
  }
  
  .calendar-day {
    min-height: 5rem;
  }
}

/* Touch-friendly styles for mobile */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .portal-nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .task-card,
  .document-card {
    padding: 1rem;
  }
  
  .form-input {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Print styles */
@media print {
  .portal-nav,
  .mobile-menu,
  .notification,
  .btn {
    display: none !important;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  body {
    background: white !important;
  }
}

/* Utility classes */
.text-shadow {
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.bg-gradient-ne {
  background: linear-gradient(135deg, var(--ne-primary), var(--ne-primary-strong));
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Focus styles for accessibility */
.btn:focus-visible,
.form-input:focus-visible,
.portal-nav-item:focus-visible {
  outline: 2px solid var(--ne-primary);
  outline-offset: 2px;
}

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

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

/* ==========================================================================
   DARK MODE
   ========================================================================== */

/* Variables mode sombre */
.dark {
  --ne-bg-primary: #0f172a;
  --ne-bg-secondary: #1e293b;
  --ne-bg-tertiary: #334155;
  --ne-text-primary: #f8fafc;
  --ne-text-secondary: #94a3b8;
  --ne-text-muted: #64748b;
  --ne-border: #334155;
}

/* Application du dark mode */
.dark body,
.dark {
  background-color: var(--ne-bg-primary);
  color: var(--ne-text-primary);
}

.dark .bg-white {
  background-color: var(--ne-bg-secondary) !important;
}

.dark .bg-gray-50,
.dark .bg-gray-100 {
  background-color: var(--ne-bg-tertiary) !important;
}

.dark .text-gray-900,
.dark .text-gray-800 {
  color: var(--ne-text-primary) !important;
}

.dark .text-gray-700,
.dark .text-gray-600 {
  color: var(--ne-text-secondary) !important;
}

.dark .text-gray-500,
.dark .text-gray-400 {
  color: var(--ne-text-muted) !important;
}

.dark .border-gray-200,
.dark .border-gray-300 {
  border-color: var(--ne-border) !important;
}

.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
.dark .divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--ne-border) !important;
}

.dark .shadow,
.dark .shadow-md,
.dark .shadow-lg,
.dark .shadow-xl {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}

.dark .hover\:bg-gray-50:hover,
.dark .hover\:bg-gray-100:hover {
  background-color: var(--ne-bg-tertiary) !important;
}

/* Cards en dark mode */
.dark .card,
.dark .rounded-xl.shadow-md,
.dark .rounded-lg.shadow {
  background-color: var(--ne-bg-secondary);
  border-color: var(--ne-border);
}

/* Tableaux en dark mode */
.dark thead {
  background-color: var(--ne-bg-tertiary) !important;
}

.dark tbody tr:hover {
  background-color: var(--ne-bg-tertiary) !important;
}

/* Inputs en dark mode */
.dark input,
.dark select,
.dark textarea {
  background-color: var(--ne-bg-tertiary) !important;
  border-color: var(--ne-border) !important;
  color: var(--ne-text-primary) !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: var(--ne-text-muted) !important;
}

/* Boutons en dark mode */
.dark .btn-secondary {
  background-color: var(--ne-bg-tertiary) !important;
  border-color: var(--ne-border) !important;
  color: var(--ne-text-primary) !important;
}

.dark .btn-secondary:hover {
  background-color: var(--ne-border) !important;
}

/* Badges conservent leurs couleurs */
.dark .bg-green-100 { background-color: rgba(34, 197, 94, 0.2) !important; }
.dark .bg-blue-100 { background-color: rgba(59, 130, 246, 0.2) !important; }
.dark .bg-yellow-100 { background-color: rgba(245, 158, 11, 0.2) !important; }
.dark .bg-red-100 { background-color: rgba(239, 68, 68, 0.2) !important; }
.dark .bg-purple-100 { background-color: rgba(168, 85, 247, 0.2) !important; }
.dark .bg-orange-100 { background-color: rgba(249, 115, 22, 0.2) !important; }

/* Portal nav reste inchangée (déjà sombre) */

/* Bouton toggle dark mode */
.dark-mode-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  background-color: transparent;
  color: currentColor;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dark-mode-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.dark .dark-mode-toggle .fa-moon { display: none; }
.dark .dark-mode-toggle .fa-sun { display: inline; }
:not(.dark) .dark-mode-toggle .fa-moon { display: inline; }
:not(.dark) .dark-mode-toggle .fa-sun { display: none; }

/* Transition fluide pour le changement de thème */
body,
.bg-white,
.bg-gray-50,
.bg-gray-100,
input,
select,
textarea {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}