/**
 * Styles pour la création de série v2
 * Avec sélection depuis la banque de mots
 */

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

/* Source tabs */
.source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.source-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    transition: all 0.2s;
}

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

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

/* Filtres */
.word-picker-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.picker-search {
    flex: 2;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 1rem;
}

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

.picker-filter {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
}

/* Container de sélection */
.word-picker-container {
    display: flex;
    gap: 1rem;
    height: 450px;
    max-height: 60vh;
}

.word-picker-available,
.word-picker-selected {
    flex: 1;
    background: white;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.word-picker-available h4,
.word-picker-selected h4 {
    padding: 0.75rem 1rem;
    margin: 0;
    background-color: var(--card-bg, #f9f9f9);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    font-size: 0.9rem;
    font-weight: 600;
}

.word-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 0; /* Important pour flex + overflow */
}

/* Barre de défilement stylisée */
.word-picker-list::-webkit-scrollbar {
    width: 8px;
}

.word-picker-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.word-picker-list::-webkit-scrollbar-thumb {
    background: var(--primary-color, #4a7c59);
    border-radius: 4px;
}

.word-picker-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover, #3d6a4a);
}

/* Flèches de transfert */
.word-picker-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}

.btn-arrow {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color, #4a7c59);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.btn-arrow:hover {
    background-color: var(--primary-dark, #3d6649);
    transform: scale(1.1);
}

.btn-arrow:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Items de mot dans le picker */
.picker-word-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.35rem;
    background-color: var(--card-bg, #f9f9f9);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.picker-word-item:hover {
    background-color: var(--hover-bg, #f0f0f0);
    border-color: var(--primary-color, #4a7c59);
}

.picker-word-item.selected {
    background-color: rgba(74, 124, 89, 0.1);
    border-color: var(--primary-color, #4a7c59);
}

.picker-word-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.picker-word-placeholder {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg, #e0e0e0);
    border-radius: 4px;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.picker-word-info {
    flex: 1;
    min-width: 0;
}

.picker-word-text {
    font-weight: 600;
    color: var(--text-color, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-word-def {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-word-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
    background-color: #e3f2fd;
    color: #1565c0;
    margin-top: 0.25rem;
}

/* États vides et chargement */
.picker-loading,
.picker-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #999);
    font-style: italic;
}

/* Selected count badge */
#selected-count {
    font-weight: normal;
    color: var(--text-secondary, #666);
}

/* Modal */
.modal-large {
    max-width: 600px;
    width: 90%;
}

.modal-image-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background-color: var(--card-bg, #f9f9f9);
    border-radius: 6px;
}

.modal-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

/* Small button */
.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .word-picker-container {
        flex-direction: column;
        min-height: auto;
    }

    .word-picker-arrows {
        flex-direction: row;
        justify-content: center;
        padding: 0.5rem 0;
    }

    .btn-arrow {
        transform: rotate(90deg);
    }

    .word-picker-available,
    .word-picker-selected {
        min-height: 200px;
    }

    .word-picker-filters {
        flex-direction: column;
    }
}

/* ==========================================
   Modal enrichi - Nouveau mot
   ========================================== */

.modal-xlarge {
    max-width: 750px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.form-group-small {
    flex: 0 0 120px;
}

.form-group-large {
    flex: 1;
}

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

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

/* Boutons AI */
.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.6rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    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-icon {
    font-size: 0.9rem;
}

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

/* Section image améliorée */
.modal-image-section {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.image-preview-box {
    width: 100px;
    height: 100px;
    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-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

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

.input-small {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* Section audio modal */
.audio-section-modal {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-group-inline {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

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

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

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

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

.recording-controls-modal {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-record-small {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background-color: var(--primary-color, #4a7c59);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

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

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

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

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

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

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

.recording-preview-modal audio {
    flex: 1;
    height: 36px;
}

.audio-file-info-modal {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    background-color: var(--card-bg, #e8e8e8);
    border-radius: 4px;
    font-size: 0.85rem;
}

#modal-audio-filename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Boutons small */
.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* ==========================================
   Modal recherche d'images
   ========================================== */

.image-source-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

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

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

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

.image-search-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); }
}

.image-search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    padding: 0.5rem;
}

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

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

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

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

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

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

.image-search-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary, #666);
}

/* Checkboxes niveaux */
.niveaux-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.checkbox-tag {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    user-select: none;
}

.checkbox-tag:hover {
    border-color: var(--primary-color, #4a7c59);
    background-color: var(--hover-bg, #f5f5f5);
}

.checkbox-tag input[type="checkbox"] {
    display: none;
}

.checkbox-tag:has(input:checked) {
    background-color: var(--primary-color, #4a7c59);
    color: white;
    border-color: var(--primary-color, #4a7c59);
}

/* Sélecteur image de couverture */
.cover-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.cover-option {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
}

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

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

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

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

.cover-option.selected .cover-check {
    display: flex;
}

.cover-option-none {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: 3px dashed var(--border-color, #ccc);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-secondary, #999);
    text-align: center;
    transition: all 0.2s;
}

.cover-option-none:hover {
    border-color: var(--primary-light, #5a9c6a);
}

.cover-option-none.selected {
    border-color: var(--primary-color, #4a7c59);
    border-style: solid;
    color: var(--primary-color, #4a7c59);
    font-weight: 500;
}

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

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

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

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

    .image-search-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}
