/**
 * LocotoManager CSS - Styles pour le gestionnaire JavaScript global
 * ================================================================
 * 
 * Styles pour les composants du gestionnaire LocotoManager :
 * - Notifications toast
 * - Modals améliorées
 * - États de boutons
 * - Indicateurs de chargement
 * 
 * @version 1.0.0
 * @author SEMCODE
 */

/* ========================================
   VARIABLES CSS PERSONNALISÉES
   ======================================== */
:root {
  --locoto-primary: #2563eb;
  --locoto-success: #16a34a;
  --locoto-warning: #d97706;
  --locoto-danger: #dc2626;
  --locoto-info: #0891b2;
  
  --locoto-border-radius: 0.375rem;
  --locoto-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --locoto-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  --locoto-transition: all 0.15s ease-in-out;
  --locoto-z-toast: 9999;
  --locoto-z-modal: 1050;
  --locoto-z-overlay: 1040;
}

/* ========================================
   SYSTÈME DE NOTIFICATIONS TOAST
   ======================================== */

.toast-container {
  position: fixed !important;
  top: 1rem !important;
  right: 1rem !important;
  z-index: var(--locoto-z-toast) !important;
  max-width: 300px;
}

.toast {
  margin-bottom: 0.5rem;
  opacity: 0;
  transform: translateX(100%);
  transition: var(--locoto-transition);
  box-shadow: var(--locoto-shadow);
  border-radius: var(--locoto-border-radius);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.hide {
  opacity: 0;
  transform: translateX(100%);
}

/* Types de toasts */
.toast.toast-success {
  background-color: var(--locoto-success) !important;
  border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.toast.toast-error {
  background-color: var(--locoto-danger) !important;
  border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.toast.toast-warning {
  background-color: var(--locoto-warning) !important;
  border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.toast.toast-info {
  background-color: var(--locoto-info) !important;
  border-left: 4px solid rgba(255, 255, 255, 0.3);
}

/* ========================================
   MODALS AMÉLIORÉES
   ======================================== */

.modal {
  z-index: var(--locoto-z-modal);
}

.modal.fade {
  opacity: 0;
  transition: opacity 0.15s linear;
}

.modal.show {
  opacity: 1;
}

.modal-backdrop {
  z-index: var(--locoto-z-overlay);
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-dialog {
  transition: transform 0.3s ease-out;
}

.modal.fade .modal-dialog {
  transform: translate(0, -50px);
}

.modal.show .modal-dialog {
  transform: none;
}

/* Modal responsive améliorée */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
}

/* Headers de modals */
.modal-header {
  border-bottom: 1px solid #e5e7eb;
  background-color: #f8fafc;
}

.modal-header .modal-title {
  color: #1f2937;
  font-weight: 600;
}

/* Bouton de fermeture amélioré */
.modal-header .btn-close,
.modal-header .modal-close {
  padding: 0.5rem;
  margin: -0.5rem -0.5rem -0.5rem auto;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: #6b7280;
  cursor: pointer;
  transition: var(--locoto-transition);
}

.modal-header .btn-close:hover,
.modal-header .modal-close:hover {
  color: #374151;
  transform: scale(1.1);
}

/* ========================================
   ÉTATS DES BOUTONS
   ======================================== */

/* États de chargement */
.btn.loading {
  position: relative;
  color: transparent !important;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  margin-left: -0.5rem;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: locoto-spin 0.8s linear infinite;
}

/* Animation de rotation */
@keyframes locoto-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Boutons avec icônes */
.btn .fas,
.btn .far,
.btn .fab {
  margin-right: 0.375rem;
}

.btn .fas:last-child,
.btn .far:last-child,
.btn .fab:last-child {
  margin-right: 0;
  margin-left: 0.375rem;
}

/* États désactivés améliorés */
.btn:disabled,
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
}

/* ========================================
   FORMULAIRES AMÉLIORÉS
   ======================================== */

/* Messages d'erreur */
.error-message {
  animation: locoto-slide-down 0.3s ease-out;
  border-left: 4px solid var(--locoto-danger);
}

@keyframes locoto-slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Champs invalides */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--locoto-danger);
  box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.25);
}

/* Indicateurs de validation */
.form-control.is-valid,
.form-select.is-valid {
  border-color: var(--locoto-success);
  box-shadow: 0 0 0 0.2rem rgba(22, 163, 74, 0.25);
}

/* ========================================
   COMPOSANTS HTMX
   ======================================== */

/* Indicateurs de chargement HTMX */
.htmx-request {
  opacity: 0.6;
  pointer-events: none;
}

.htmx-request::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* Effet de swap HTMX */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.htmx-added {
  opacity: 0;
  animation: locoto-fade-in 0.3s ease-out forwards;
}

@keyframes locoto-fade-in {
  to {
    opacity: 1;
  }
}

/* ========================================
   UTILITAIRES DE MISE EN FORME
   ======================================== */

/* Transitions fluides */
.locoto-transition {
  transition: var(--locoto-transition);
}

.locoto-transition-slow {
  transition: all 0.3s ease-in-out;
}

/* Ombres */
.locoto-shadow {
  box-shadow: var(--locoto-shadow);
}

.locoto-shadow-lg {
  box-shadow: var(--locoto-shadow-lg);
}

/* États de focus améliorés */
.locoto-focus:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  border-color: var(--locoto-primary);
}

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

/* Focus visible pour navigation clavier */
.locoto-focus-visible:focus-visible {
  outline: 2px solid var(--locoto-primary);
  outline-offset: 2px;
}

/* Réduction des mouvements pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Amélioration du contraste en mode sombre */
@media (prefers-color-scheme: dark) {
  .modal-header {
    background-color: #374151;
    border-bottom-color: #4b5563;
  }
  
  .modal-header .modal-title {
    color: #f9fafb;
  }
  
  .toast {
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

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

/* Tablettes */
@media (max-width: 768px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
  
  .toast {
    margin-bottom: 0.75rem;
  }
}

/* Mobiles */
@media (max-width: 576px) {
  .toast-container {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
  }
  
  .modal-dialog {
    margin: 0.25rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

/* ========================================
   DEBUGGING ET DÉVELOPPEMENT
   ======================================== */

/* Bordures de debug (désactivées par défaut) */
.locoto-debug * {
  outline: 1px solid red !important;
}

.locoto-debug-grid {
  background-image: 
    linear-gradient(to right, rgba(255, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 0, 0, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Performance - GPU acceleration pour les animations */
.toast,
.modal-dialog,
.btn.loading::after {
  will-change: transform;
  transform: translateZ(0);
} 