/**
 * ====================================
 * STYLES POUR LES FORMULAIRES
 * ====================================
 */

/* Modal de base */
.form-modal {
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(5px);
    }
}

/* Contenu de la modal */
.modal-content {
    background: white;
    border-radius: var(--border-radius-lg);
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
    position: relative;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* En-tête de la modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--light-gray);
    background: var(--card-bg);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-title {
    margin: 0;
    color: var(--secondary-color);
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-normal);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--error-color);
    background: rgba(231, 76, 60, 0.1);
}

.modal-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Corps de la modal */
.modal-body {
    padding: var(--spacing-lg);
}

/* Grille de formulaire */
.form-grid {
    display: grid;
    gap: var(--spacing-lg);
}

/* Groupes de champs */
.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--secondary-color);
    font-size: 14px;
}

.required-asterisk {
    color: var(--error-color);
    margin-left: var(--spacing-xs);
    font-weight: bold;
}

/* Contrôles de formulaire */
.form-control {
    padding: var(--spacing-md);
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-normal);
    background: white;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-control:hover {
    border-color: var(--primary-color);
}

.form-control::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* États d'erreur */
.form-control-error {
    border-color: var(--error-color);
    background: rgba(231, 76, 60, 0.05);
}

.form-control-error:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* Messages d'aide et d'erreur */
.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
    line-height: 1.4;
}

.form-error {
    font-size: 12px;
    color: var(--error-color);
    margin-top: var(--spacing-xs);
    display: none;
    font-weight: 500;
}

/* Zones de texte */
.form-control[type="textarea"],
textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

/* Champs numériques */
.form-control[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.form-control[type="number"]::-webkit-outer-spin-button,
.form-control[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Actions du formulaire */
.form-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--light-gray);
}

/* Boutons */
.btn {
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    min-width: 120px;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-cancel {
    background: var(--light-gray);
    color: var(--text-secondary);
}

.btn-cancel:hover {
   background: var(--dark-gray);
   color: white;
}

.btn-primary {
   background: var(--primary-color);
   color: white;
}

.btn-primary:hover {
   background: #2980b9;
   transform: translateY(-1px);
   box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
   opacity: 0.6;
   cursor: not-allowed;
   transform: none;
   box-shadow: none;
}

/* Spinner de chargement */
.btn-spinner {
   display: none;
   align-items: center;
   gap: var(--spacing-sm);
}

.spinner {
   width: 16px;
   height: 16px;
   border: 2px solid transparent;
   border-top: 2px solid currentColor;
   border-radius: 50%;
   animation: spin 1s linear infinite;
}

@keyframes spin {
   0% { transform: rotate(0deg); }
   100% { transform: rotate(360deg); }
}

/* ====================================
  BOUTONS D'ACTION SUR LES CARTES
  ==================================== */

.prompt-meta {
   display: flex;
   align-items: center;
   gap: var(--spacing-sm);
   flex-wrap: wrap;
}

.prompt-actions {
   display: flex;
   gap: var(--spacing-xs);
}

.btn-edit,
.btn-delete {
   background: none;
   border: none;
   padding: var(--spacing-xs);
   cursor: pointer;
   border-radius: var(--border-radius-sm);
   transition: all var(--transition-normal);
   font-size: 16px;
   width: 32px;
   height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
}

.btn-edit:hover {
   background: rgba(52, 152, 219, 0.1);
   transform: scale(1.1);
}

.btn-delete:hover {
   background: rgba(231, 76, 60, 0.1);
   transform: scale(1.1);
}

.btn-edit:focus,
.btn-delete:focus {
   outline: 2px solid var(--primary-color);
   outline-offset: 2px;
}

/* Bouton d'ajout flottant */
.fab-add {
   position: fixed;
   bottom: 30px;
   right: 30px;
   width: 60px;
   height: 60px;
   background: var(--primary-color);
   color: white;
   border: none;
   border-radius: 50%;
   font-size: 28px;
   font-weight: 300;
   cursor: pointer;
   box-shadow: var(--shadow-lg);
   transition: all var(--transition-normal);
   z-index: 100;
   display: flex;
   align-items: center;
   justify-content: center;
}

.fab-add:hover {
   background: #2980b9;
   transform: scale(1.1);
   box-shadow: var(--shadow-xl);
}

.fab-add:focus {
   outline: 3px solid rgba(52, 152, 219, 0.3);
   outline-offset: 3px;
}

.fab-add:active {
   transform: scale(0.95);
}

/* Animation d'apparition du FAB */
.fab-add {
   opacity: 0;
   transform: scale(0.8) translateY(20px);
   animation: fabSlideIn 0.3s ease 0.5s forwards;
}

@keyframes fabSlideIn {
   to {
       opacity: 1;
       transform: scale(1) translateY(0);
   }
}

/* ====================================
  RESPONSIVE DESIGN
  ==================================== */

/* Tablette */
@media (min-width: 768px) and (max-width: 1023px) {
   .modal-content {
       max-width: 600px;
       width: 90%;
   }
   
   .form-grid {
       grid-template-columns: 1fr;
   }
}

/* Mobile */
@media (max-width: 767px) {
   .modal-content {
       width: 100%;
       height: 100vh;
       max-height: 100vh;
       border-radius: 0;
       max-width: none;
   }
   
   .modal-header {
       padding: var(--spacing-md);
       border-radius: 0;
   }
   
   .modal-title {
       font-size: 18px;
   }
   
   .modal-body {
       padding: var(--spacing-md);
   }
   
   .form-actions {
       flex-direction: column;
       gap: var(--spacing-sm);
   }
   
   .btn {
       width: 100%;
       justify-content: center;
   }
   
   .form-control {
       font-size: 16px; /* Évite le zoom sur iOS */
       padding: var(--spacing-md);
   }
   
   .fab-add {
       bottom: 20px;
       right: 20px;
       width: 50px;
       height: 50px;
       font-size: 24px;
   }
   
   .prompt-actions {
       margin-top: var(--spacing-xs);
   }
   
   .prompt-meta {
       flex-direction: column;
       align-items: flex-start;
       gap: var(--spacing-xs);
   }
}

/* Très petit mobile */
@media (max-width: 479px) {
   .modal-header {
       padding: var(--spacing-sm) var(--spacing-md);
   }
   
   .modal-body {
       padding: var(--spacing-sm) var(--spacing-md);
   }
   
   .modal-title {
       font-size: 16px;
   }
   
   .form-grid {
       gap: var(--spacing-md);
   }
   
   .fab-add {
       bottom: 15px;
       right: 15px;
       width: 45px;
       height: 45px;
       font-size: 20px;
   }
}

/* ====================================
  AMÉLIORATIONS D'ACCESSIBILITÉ
  ==================================== */

/* Focus visible amélioré */
.form-control:focus-visible {
   outline: 2px solid var(--primary-color);
   outline-offset: 2px;
}

/* Réduction des animations pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
   .modal-content,
   .form-modal,
   .fab-add,
   .btn,
   .form-control {
       animation: none !important;
       transition: none !important;
   }
   
   .fab-add {
       opacity: 1;
       transform: scale(1) translateY(0);
   }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
   .modal-content {
       background: #2c2c2c;
       color: #ffffff;
   }
   
   .modal-header {
       background: #3a3a3a;
       border-bottom-color: #4a4a4a;
   }
   
   .modal-title {
       color: #ffffff;
   }
   
   .modal-close {
       color: #cccccc;
   }
   
   .modal-close:hover {
       color: #e74c3c;
       background: rgba(231, 76, 60, 0.2);
   }
   
   .form-control {
       background: #3a3a3a;
       border-color: #4a4a4a;
       color: #ffffff;
   }
   
   .form-control:focus {
       border-color: var(--primary-color);
       background: #2c2c2c;
   }
   
   .form-control::placeholder {
       color: #888888;
   }
   
   .form-control-error {
       background: rgba(231, 76, 60, 0.1);
   }
   
   .form-actions {
       border-top-color: #4a4a4a;
   }
   
   .btn-cancel {
       background: #4a4a4a;
       color: #cccccc;
   }
   
   .btn-cancel:hover {
       background: #6c757d;
       color: #ffffff;
   }
}

/* ====================================
  ÉTATS DE VALIDATION VISUELS
  ==================================== */

/* Champ valide */
.form-control:valid:not(:placeholder-shown) {
   border-color: var(--success-color);
}

.form-control:valid:not(:placeholder-shown):focus {
   box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

/* Indicateur de caractères restants */
.form-group {
   position: relative;
}

.character-count {
   position: absolute;
   bottom: -18px;
   right: 0;
   font-size: 11px;
   color: var(--text-muted);
}

.character-count.warning {
   color: var(--warning-color);
}

.character-count.error {
   color: var(--error-color);
}

/* ====================================
  ANIMATIONS ET MICRO-INTERACTIONS
  ==================================== */

/* Effet de focus sur les boutons */
.btn:focus-visible {
   outline: 2px solid var(--primary-color);
   outline-offset: 2px;
}

/* Effet de hover sur les champs */
.form-control:hover:not(:disabled):not(:focus) {
   border-color: rgba(52, 152, 219, 0.5);
}

/* Animation de succès après soumission */
@keyframes successPulse {
   0%, 100% { transform: scale(1); }
   50% { transform: scale(1.05); }
}

.form-success {
   animation: successPulse 0.3s ease;
}

/* Transition douce pour les erreurs */
.form-error {
   opacity: 0;
   transform: translateY(-10px);
   transition: all 0.3s ease;
}

.form-error:not(:empty) {
   opacity: 1;
   transform: translateY(0);
   display: block;
}