/**
 * Styles pour le formulaire d'ajout de mot
 * Vocabulaire - Module /mots/
 */

/* Bouton retour */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--bg-color, #f5f5f5);
    color: var(--text-color, #333);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--primary-color, #4a7c59);
    color: white;
    border-color: var(--primary-color, #4a7c59);
}

/* Container */
.form-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
}

/* Form */
.mot-form {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Form group */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color, #333);
}

/* Label with button */
.label-with-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.label-with-button .form-label {
    margin-bottom: 0;
}

/* AI buttons */
.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.btn-ai:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-ai.loading {
    pointer-events: none;
}

.btn-ai-icon {
    font-size: 1rem;
}

/* Language select */
.select-lang {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
}

/* URL input inline */
.url-input {
    flex: 1;
    min-width: 150px;
    padding: 0.5rem;
    font-size: 0.9rem;
}

/* Inputs */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #4a7c59);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Champ exemple plus grand */
.exemple-input {
    min-height: 70px;
    line-height: 1.5;
}

/* Radio group */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    transition: all 0.2s;
}

.radio-label:hover {
    background-color: var(--hover-bg, #f5f5f5);
}

.radio-label:has(input:checked) {
    border-color: var(--primary-color, #4a7c59);
    background-color: rgba(74, 124, 89, 0.05);
}

.radio-label input[type="radio"] {
    accent-color: var(--primary-color, #4a7c59);
}

/* Theme input group */
.theme-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.theme-input-group .form-select {
    flex: 1;
    min-width: 200px;
}

.theme-separator {
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
}

.theme-new-input {
    flex: 1;
    min-width: 150px;
}

/* Form feedback */
.form-feedback {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.form-feedback.warning {
    background-color: #fff3e0;
    color: #e65100;
}

.form-feedback.success {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.form-feedback.error {
    background-color: #ffebee;
    color: #c62828;
}

/* Champ en erreur */
.input-error,
textarea.input-error,
input.input-error {
    border-color: #c62828 !important;
    background-color: #fff5f5 !important;
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.2) !important;
}

.form-feedback .feedback-link {
    display: block;
    margin-top: 0.5rem;
    color: var(--primary-color, #4a7c59);
    font-weight: 600;
    text-decoration: none;
}

.form-feedback .feedback-link:hover {
    text-decoration: underline;
}

/* Effet de surbrillance pour nouvelle carte de sens */
.sens-card.highlight {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 4px rgba(74, 124, 89, 0.6);
        border-color: var(--primary-color, #4a7c59);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 124, 89, 0);
        border-color: var(--border-color, #e0e0e0);
    }
}

/* Image section */
.image-section {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.image-preview {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--border-color, #ddd);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--card-bg, #f9f9f9);
    flex-shrink: 0;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-placeholder {
    color: var(--text-secondary, #999);
    font-size: 0.875rem;
    text-align: center;
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

/* Audio section */
.audio-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.audio-option {
    padding: 1rem;
    background-color: var(--card-bg, #f9f9f9);
    border-radius: 8px;
}

/* Recording controls */
.recording-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-record {
    background-color: var(--primary-color, #4a7c59);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-record:hover {
    background-color: var(--primary-dark, #3d6649);
}

.btn-record.recording {
    background-color: #c62828;
    animation: pulse 1s infinite;
}

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

.recording-status {
    color: var(--text-secondary, #666);
    font-size: 0.875rem;
}

.recording-status.recording {
    color: #c62828;
    font-weight: 500;
}

.recording-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.recording-preview audio {
    flex: 1;
}

/* Audio file info */
.audio-file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--card-bg, #f0f0f0);
    border-radius: 4px;
}

#audio-filename {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-color, #333);
}

/* Label hint */
.label-hint {
    display: block;
    font-weight: normal;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    margin-top: 0.25rem;
}

/* Form row */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-group-small {
    flex: 1;
    min-width: 100px;
    margin-bottom: 1rem;
}

.form-group-small .form-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* Form separator */
/* ==========================================
   Accordéons (Grammaire, Morphologie)
   ========================================== */

.accordeon-section {
    margin: 0.75rem 0;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: white;
}

.accordeon-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color, #333);
    list-style: none;
}

.accordeon-header::-webkit-details-marker {
    display: none;
}

.accordeon-header::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--text-secondary, #666);
    transition: transform 0.2s;
}

.accordeon-section[open] .accordeon-header::before {
    transform: rotate(90deg);
}

.accordeon-content {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

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

.accordeon-content .form-label {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.accordeon-content .form-input,
.accordeon-content .form-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* Grammaire spécifique */
.grammaire-sens .form-row {
    margin-top: 0.5rem;
}

/* Morphologie spécifique */
.morphologie-sens .form-row {
    margin-top: 0.5rem;
}

/* ==========================================
   Réseau sémantique
   ========================================== */

.reseau-semantique-sens .section-help {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(74, 124, 89, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color, #4a7c59);
}

.reseau-semantique-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.reseau-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reseau-field .form-label {
    margin-bottom: 0;
}

.reseau-field .field-help {
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    margin-top: 0.25rem;
}

/* Intégration TagsInput dans accordeon */
.reseau-semantique-sens .tags-input-wrapper {
    min-height: 40px;
    padding: 6px 10px;
    font-size: 0.9rem;
}

.reseau-semantique-sens .tag-item {
    font-size: 0.85rem;
    padding: 3px 6px;
}

.reseau-semantique-sens .tags-input-field {
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .reseau-semantique-grid {
        grid-template-columns: 1fr;
    }
}

.form-group-half {
    flex: 1;
    min-width: 200px;
}

.form-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0 1.5rem;
    color: var(--primary-color, #4a7c59);
    font-weight: 600;
    font-size: 1.1rem;
}

.form-separator::before,
.form-separator::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color, #4a7c59), transparent);
}

.form-separator::after {
    background: linear-gradient(90deg, transparent, var(--primary-color, #4a7c59));
}

/* Sens card */
.sens-card {
    background: var(--card-bg, #f9f9f9);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
}

.sens-card:hover {
    border-color: var(--primary-light, #6a9c7a);
}

.sens-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #ddd);
}

.sens-number {
    font-weight: 600;
    color: var(--primary-color, #4a7c59);
    font-size: 1rem;
}

.btn-remove-sens {
    width: 28px;
    height: 28px;
    border: none;
    background: #ffebee;
    color: #c62828;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-remove-sens:hover {
    background: #c62828;
    color: white;
}

/* Add sens button */
.btn-add-sens {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 2rem;
    border: 2px dashed var(--border-color, #ccc);
    background: transparent;
    color: var(--text-secondary, #666);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-sens:hover {
    border-color: var(--primary-color, #4a7c59);
    color: var(--primary-color, #4a7c59);
    background: rgba(74, 124, 89, 0.05);
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color, #eee);
}

/* Buttons */
.btn-outline {
    background: none;
    border: 1px solid var(--border-color, #ddd);
    color: var(--text-color, #333);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary-color, #4a7c59);
    color: var(--primary-color, #4a7c59);
}

/* Loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .mot-form {
        padding: 1.5rem;
    }

    .image-section {
        flex-direction: column;
        align-items: center;
    }

    .image-actions {
        flex-direction: row;
        justify-content: center;
    }

    .theme-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-separator {
        text-align: center;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-label {
        justify-content: flex-start;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Sens cards responsive */
    .sens-card {
        padding: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group-small {
        min-width: 100%;
    }
}

/* ==========================================
   Modal sélection d'image
   ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #eee);
}

.modal-header h3 {
    color: var(--primary-color, #4a7c59);
    font-size: 1.1rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color, #333);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, #eee);
}

/* Onglets sources */
.image-source-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.image-search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.image-search-bar .form-input {
    flex: 1;
}

.source-tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color, #ddd);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.source-tab:hover {
    border-color: var(--primary-color, #4a7c59);
}

.source-tab.active {
    background: var(--primary-color, #4a7c59);
    color: white;
    border-color: var(--primary-color, #4a7c59);
}

/* Zone de chargement */
.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary, #666);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, #ddd);
    border-top-color: var(--primary-color, #4a7c59);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Grille d'images */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.image-option {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.image-option:hover {
    border-color: var(--primary-light, #5a9c6a);
    transform: scale(1.02);
}

.image-option.selected {
    border-color: var(--primary-color, #4a7c59);
    box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.3);
}

.image-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-option .check-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--primary-color, #4a7c59);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.image-option.selected .check-icon {
    display: flex;
}

/* Message vide */
.image-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary, #666);
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal {
        max-height: 95vh;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .source-tab {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ==========================================
   Modal génération de définition
   ========================================== */

.definition-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary, #666);
}

.definition-result {
    margin-bottom: 1.5rem;
}

.definition-preview {
    background: var(--card-bg, #f5f5f5);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-color, #333);
    margin-top: 0.5rem;
}

.definition-preview.loading {
    color: var(--text-secondary, #888);
    font-style: italic;
}

.definition-refine {
    border-top: 1px solid var(--border-color, #eee);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.definition-refine .form-textarea {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

/* Modal footer pour définition */
#btn-regenerate-definition {
    margin-right: auto;
}

#btn-regenerate-definition:hover {
    background: rgba(74, 124, 89, 0.1);
}

/* Animation du bouton régénérer */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#btn-regenerate-definition.loading {
    pointer-events: none;
    opacity: 0.7;
}

#btn-regenerate-definition.loading::before {
    content: '⏳';
    margin-right: 0.25rem;
    display: inline-block;
    animation: rotate 1s linear infinite;
}

/* ==========================================
   Modal génération d'image IA
   ========================================== */

.ia-tries-counter {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.95rem;
}

.ia-tries-counter.unlimited {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.ia-tries-counter.warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.ia-tries-counter.exhausted {
    background: #e53935;
}

.ia-tries-counter strong {
    font-size: 1.2rem;
}

.ia-image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary, #666);
}

.ia-image-result {
    margin-top: 1rem;
}

.ia-image-preview {
    width: 100%;
    max-width: 400px;
    margin: 0.5rem auto 0;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color, #ddd);
    background: var(--card-bg, #f5f5f5);
}

.ia-image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.ia-image-error {
    background-color: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin-top: 1rem;
}

.ia-image-error.warning {
    background-color: #fff3e0;
    color: #e65100;
}

/* Bouton générer IA dans le modal */
#btn-generate-ia-image {
    margin-right: auto;
}

#btn-generate-ia-image:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .ia-image-preview {
        max-width: 100%;
    }

    .ia-tries-counter {
        font-size: 0.85rem;
    }
}

/* ==============================
   Éditeur d'annotations (flèches)
   ============================== */

.annotate-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.annotate-colors {
    display: flex;
    gap: 0.5rem;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.selected {
    border-color: #333;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

.annotate-actions {
    display: flex;
    gap: 0.5rem;
}

.annotate-canvas-container {
    display: flex;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 8px;
    overflow: auto;
    max-height: 60vh;
}

#annotate-canvas {
    cursor: crosshair;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.annotate-hint {
    text-align: center;
    color: var(--text-secondary, #888);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.btn-annotate-image {
    font-size: 0.85rem;
}
