/* ============================================================================
   IMAGILIRE MINI - MODALE DICTIONNAIRE PERSONNALISÉ
   ============================================================================ */

/* Backdrop de la modale */
.dict-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.dict-modal-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Conteneur principal de la modale */
.dict-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background-color: var(--page-color, #fff);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 2001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dict-modal.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Header de la modale */
.dict-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color, #3ba99c) 0%, #2a8e90 100%);
    color: white;
    border-bottom: 3px solid rgba(255, 255, 255, 0.2);
}

.dict-modal-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.dict-modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.dict-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Onglets */
.dict-tabs {
    display: flex;
    background-color: #f5f5f5;
    border-bottom: 2px solid #ddd;
    overflow-x: auto;
}

.dict-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
}

.dict-tab:hover {
    background-color: rgba(59, 169, 156, 0.1);
    color: var(--primary-color, #3ba99c);
}

.dict-tab.active {
    color: var(--primary-color, #3ba99c);
    border-bottom-color: var(--primary-color, #3ba99c);
    background-color: white;
    font-weight: 600;
}

/* Contenu des onglets */
.dict-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.dict-tab-panel {
    display: none;
}

.dict-tab-panel.active {
    display: block;
}

/* Formulaires d'ajout */
.dict-form {
    margin-bottom: 20px;
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.dict-form-group {
    margin-bottom: 12px;
}

.dict-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.dict-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.dict-form-group input:focus {
    outline: none;
    border-color: var(--primary-color, #3ba99c);
}

.dict-form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 0.85em;
}

.dict-add-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--primary-color, #3ba99c);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.dict-add-btn:hover {
    background-color: #2a8e90;
}

.dict-add-btn:active {
    transform: scale(0.98);
}

/* Feedback messages */
.dict-feedback {
    display: none;
    padding: 10px 12px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 0.9em;
    animation: slideIn 0.3s ease;
}

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

.dict-feedback-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.dict-feedback-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.dict-feedback-warn {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.dict-feedback-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Liste des mots */
.dict-list {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
}

.dict-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s;
}

.dict-list-item:hover {
    background-color: #f5f5f5;
    border-color: var(--primary-color, #3ba99c);
    box-shadow: 0 2px 8px rgba(59, 169, 156, 0.1);
}

.dict-list-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.dict-item-mot {
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.dict-item-detail {
    color: #666;
    font-size: 0.9em;
    flex: 1;
}

.dict-item-delete {
    background-color: #dc3545;
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, transform 0.1s;
}

.dict-item-delete:hover {
    background-color: #c82333;
}

.dict-item-delete:active {
    transform: scale(0.95);
}

/* Footer de la modale */
.dict-modal-footer {
    padding: 16px 20px;
    background-color: #f5f5f5;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.dict-export-btn,
.dict-import-btn {
    flex: 1;
    padding: 10px 16px;
    background-color: white;
    border: 2px solid var(--primary-color, #3ba99c);
    color: var(--primary-color, #3ba99c);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dict-export-btn:hover,
.dict-import-btn:hover {
    background-color: var(--primary-color, #3ba99c);
    color: white;
}

.dict-global-feedback {
    display: none;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: center;
}

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

    .dict-modal-header h2 {
        font-size: 1.1em;
    }

    .dict-tab {
        padding: 10px 12px;
        font-size: 0.85em;
    }

    .dict-modal-body {
        padding: 16px;
    }

    .dict-modal-footer {
        flex-direction: column;
    }

    .dict-export-btn,
    .dict-import-btn {
        width: 100%;
    }

    .dict-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dict-item-delete {
        align-self: flex-end;
    }
}

/* ── Barre de recherche dans les listes ──────────────────────────────── */
.dict-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
}

.dict-search-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.dict-search-icon {
    position: absolute;
    left: 10px;
    color: #bbb;
    font-size: 0.85em;
    pointer-events: none;
    transition: color 0.2s;
}

.dict-search-input-wrap:focus-within .dict-search-icon {
    color: var(--primary-color, #3ba99c);
}

.dict-search-input {
    width: 100%;
    padding: 8px 34px 8px 30px;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    font-size: 0.9em;
    background-color: #fafafa;
    color: var(--text-color, #333);
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}

.dict-search-input:focus {
    outline: none;
    border-color: var(--primary-color, #3ba99c);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(59, 169, 156, 0.12);
}

/* Masquer le bouton natif de suppression des navigateurs */
.dict-search-input::-webkit-search-cancel-button,
.dict-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.dict-search-clear {
    position: absolute;
    right: 6px;
    background: #e8e8e8;
    border: none;
    color: #666;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    padding: 0;
    font-size: 0.75em;
    flex-shrink: 0;
}

.dict-search-clear:hover {
    background-color: #d0d0d0;
    color: #333;
}

.dict-search-count {
    font-size: 0.8em;
    color: #888;
    white-space: nowrap;
    min-width: 52px;
    text-align: right;
    flex-shrink: 0;
}

/* Message "aucun résultat" de recherche */
.dict-search-no-results {
    text-align: center;
    color: #aaa;
    font-style: italic;
    padding: 20px 16px;
    margin: 4px 0 0 0;
    font-size: 0.9em;
    border: 1.5px dashed #e0e0e0;
    border-radius: 8px;
}

/* ── Responsive barre de recherche ───────────────────────────────────── */
@media (max-width: 768px) {
    .dict-search-bar {
        margin: 12px 0 6px;
        gap: 8px;
    }

    .dict-search-count {
        min-width: 44px;
        font-size: 0.75em;
    }
}

@media (max-width: 480px) {
    .dict-search-input {
        font-size: 0.85em;
        padding: 7px 32px 7px 28px;
    }

    .dict-search-count {
        min-width: 36px;
        font-size: 0.72em;
    }
}

@media (max-width: 360px) {
    .dict-search-count {
        display: none;
    }
}

/* Scrollbar personnalisée */
.dict-modal-body::-webkit-scrollbar {
    width: 8px;
}

.dict-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.dict-modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color, #3ba99c);
    border-radius: 4px;
}

.dict-modal-body::-webkit-scrollbar-thumb:hover {
    background: #2a8e90;
}
