{# static/css/components/form.css #}
.form-field {
    position: relative;
    margin-bottom: 1rem;
    width: 100%;
}

.form-field-hidden {
    display: none;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: var(--white);
    font-size: 0.875rem;
    transition: all 0.2s;
    color: var(--text-color);
}

.form-field label {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    font-size: 0.875rem;
    color: #64748b;
    transition: all 0.2s;
    background-color: var(--white);
    padding: 0 0.25rem;
    pointer-events: none;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-field input:focus ~ label,
.form-field select:focus ~ label,
.form-field textarea:focus ~ label,
.form-field input:not(:placeholder-shown) ~ label,
.form-field select:not(:placeholder-shown) ~ label,
.form-field textarea:not(:placeholder-shown) ~ label {
    top: -0.5rem;
    font-size: 0.75rem;
    color: var(--text-color);
}

/* Styles spécifiques pour les champs de recherche liée */
.link-search-field {
    position: relative;
}

.link-search-field .autocomplete-suggestions {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.25rem 0;
    display: none;
}

.link-search-field .autocomplete-suggestions.is-visible {
    display: block;
}

.link-search-field .autocomplete-suggestion {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.link-search-field .autocomplete-suggestion.is-highlighted,
.link-search-field .autocomplete-suggestion:hover {
    background-color: rgba(59, 130, 246, 0.08);
}

.autocomplete-suggestion__content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.autocomplete-suggestion__image {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--border-radius--normal);
    object-fit: cover;
}

.autocomplete-suggestion__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
}

.autocomplete-suggestion__title {
    font-weight: 600;
    color: var(--text-color);
}

.autocomplete-suggestion__subtitle {
    font-size: 0.75rem;
    color: #64748b;
}

/* Présentation de la carte affichée lorsqu'une entrée est sélectionnée */
.link-search-field .autocomplete-selection {
    display: none;
    margin-bottom: 0.5rem;
}

.link-search-field .autocomplete-selection:not([hidden]) {
    display: block;
}

.link-search-field .autocomplete-selection__card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.link-search-field .autocomplete-selection__image {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--border-radius--normal);
    object-fit: cover;
}

.link-search-field .autocomplete-selection__content {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    color: var(--text-color);
}

.link-search-field .autocomplete-selection__title {
    font-weight: 600;
}

.link-search-field .autocomplete-selection__reference {
    font-size: 0.75rem;
    color: #64748b;
}

.link-search-field .autocomplete-selection__remove {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s ease;
}

.link-search-field .autocomplete-selection__remove:hover,
.link-search-field .autocomplete-selection__remove:focus {
    color: var(--primary-color);
}

.link-search-field .is-hidden {
    display: none !important;
}

.form-field.file-field input {
    padding-top: 1.5rem;
}

.form-field.file-field label {
    top: 0.25rem;
}

.media-field {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.media-field__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.media-dropzone {
    position: relative;
    border: 2px dashed rgba(148, 163, 184, 0.6);
    border-radius: 0.75rem;
    padding: 1.5rem;
    background: rgba(148, 163, 184, 0.08);
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.media-dropzone:hover,
.media-dropzone:focus-visible {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.06);
}

.media-dropzone.drag-over {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.12);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.media-dropzone.has-error {
    border-color: var(--danger-color, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

.media-dropzone__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    color: #475569;
}

.media-dropzone__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.media-dropzone__subtitle {
    font-size: 0.8125rem;
    color: #64748b;
}

.media-dropzone__action {
    margin-top: 0.5rem;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.media-dropzone__action:hover,
.media-dropzone__action:focus-visible {
    background: #4f46e5;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.25);
}

.media-field__error {
    font-size: 0.8125rem;
    color: var(--danger-color, #ef4444);
}

.media-preview-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--white);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.media-preview-card__visual {
    width: 4rem;
    height: 4rem;
    border-radius: 0.75rem;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-preview-card__placeholder {
    font-size: 0.75rem;
    color: #64748b;
    padding: 0 0.5rem;
    text-align: center;
}

.media-preview-card__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.media-preview-card__name {
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
}

.media-preview-card__size {
    font-size: 0.75rem;
    color: #64748b;
}

.media-preview-card__remove {
    border: none;
    background: transparent;
    color: #ef4444;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.media-preview-card__remove:hover,
.media-preview-card__remove:focus-visible {
    color: #b91c1c;
    transform: translateY(-1px);
}

.age-display {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.25rem;
    font-style: italic;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Styles pour la zone de drop */
.file-drop-zone {
    width: 100%;
}

.drop-zone-container {
    margin-bottom: 1rem;
}

.drop-zone {
    border: 2px dashed #e2e8f0;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.05);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-icon {
    color: #64748b;
    margin-bottom: 0.5rem;
}

.drop-text {
    font-size: 1rem;
    color: #1e293b;
}

.drop-hint {
    font-size: 0.875rem;
    color: #64748b;
}

/* Liste des fichiers */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: var(--bg-color);
    border-radius: 0.375rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.file-preview {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: cover;
    border-radius: 0.25rem;
}

.file-name {
    font-size: 0.875rem;
    color: #1e293b;
}

.file-size {
    font-size: 0.75rem;
    color: #64748b;
}

.remove-file {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.remove-file:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.file-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Reset des styles par défaut pour le champ checkbox */
.form-field.checkbox-field {
    margin-bottom: 1rem;
    width: 100%;
}

.form-field.checkbox-field input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    margin: 0;
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: all 0.2s ease;
}

.form-field.checkbox-field input[type="checkbox"]::before {
    content: "";
    width: 12px;
    height: 12px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--primary-color);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.form-field.checkbox-field input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.form-field.checkbox-field input[type="checkbox"]:checked {
    background-color: white;
    border-color: var(--primary-color);
}

/* Animation de pulsation */
@keyframes checkbox-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.form-field.checkbox-field input[type="checkbox"]:hover {
    border-color: var(--primary-color);
    animation: checkbox-pulse 1.5s infinite;
}

.form-field.checkbox-field input[type="checkbox"]:checked {
    animation: checkbox-pulse 1.5s infinite;
}

.form-field.checkbox-field input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Style spécifique pour le label de checkbox qui annule les effets de positionnement */
.form-field.checkbox-field {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
}

.form-field.checkbox-field label {
    position: static !important; /* Override le positionnement absolu */
    transform: none !important; /* Empêche toute transformation */
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0.875rem !important;
    color: #1e293b !important;
    background: none !important;
    cursor: pointer;
    user-select: none;
    pointer-events: auto !important;
    font-weight: 500;
    display: inline-block !important;
    transition: none !important; /* Désactive les transitions */
    top: auto !important; /* Annule le positionnement top */
  left: auto !important; /* Annule le positionnement left */
}

.form-message {
    margin-top: 1rem;
    font-size: 0.875rem;
}

.form-message.success {
    color: var(--success-color);
    border: 1px solid var(--success-color);
    border-radius: var(--border-radius--normal);
    padding: 0.9rem;
    margin-bottom: 30px;
    background: rgba(0, 128, 0, 0.225);
}

.form-message.error {
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: var(--border-radius--normal);
    padding: 0.9rem;
    margin-bottom: 30px;
    background: #dc262612;
}

/* --- Styles pour les champs de type "tags" --- */
/* Conteneur principal du composant tags */
[data-type="tags"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: var(--white);
    width: 100%;
}

/* Zone affichant les balises courantes */
.tag-input-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Style d'une balise individuelle */
.tag-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: #f1f5f9;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    color: #334155;
    cursor: pointer;
}

/* Champ texte pour la saisie des balises */
.tag-input-field {
    flex: 1;
    border: none;
    min-width: 6rem;
    font-size: 0.875rem;
    padding: 0.25rem;
}

.tag-input-field:focus {
    outline: none;
}

/* Bouton d'ajout de balise */
.tag-input-add {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.tag-input-add:hover {
    opacity: 0.9;
}

/* Positionnement du label pour le champ tags */
.form-field [data-type="tags"]:focus-within ~ label,
.form-field [data-type="tags"]:has(.tag-label) ~ label {
    top: -0.5rem;
    font-size: 0.75rem;
    color: var(--text-color);
}

/* Effet de focus cohérent avec les autres champs */
.form-field [data-type="tags"]:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
