/**
 * Styles pour l'infobulle de correction orthographique
 * Design discret et accessible
 */

/* Marquage visuel des mots incorrects - Dans l'éditeur Quill */
.ql-editor span.spell-error-mark,
.ql-editor span[data-spell-error="true"] {
    border: 2px solid #f39c12 !important;
    border-radius: 4px !important;
    padding: 0 2px !important;
    background: rgba(243, 156, 18, 0.1) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    -webkit-tap-highlight-color: transparent !important;
    /* touch-action: manipulation retiré pour permettre l'édition sur écrans tactiles */
    user-select: text !important;
    display: inline !important;
}

.ql-editor span.spell-error-mark:hover,
.ql-editor span[data-spell-error="true"]:hover {
    background: rgba(243, 156, 18, 0.2) !important;
    border-color: #e67e22 !important;
}

.ql-editor span.spell-error-mark:active,
.ql-editor span[data-spell-error="true"]:active {
    background: rgba(243, 156, 18, 0.3) !important;
    transform: scale(0.98) !important;
}

/* Adaptation pour mobile/tablette */
@media (max-width: 1024px) {
    .ql-editor span.spell-error-mark,
    .ql-editor span[data-spell-error="true"] {
        border-width: 2.5px !important;
        padding: 2px 4px !important;
        min-height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
}

/* Conteneur principal de l'infobulle */
.spell-tooltip {
    position: fixed;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.spell-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Contenu de l'infobulle */
.spell-tooltip-content {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 280px;
    max-width: 400px;
    padding: 0;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Header de l'infobulle */
.spell-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px 12px 0 0;
}

.spell-tooltip-question {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
}

.spell-tooltip-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.spell-tooltip-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #334155;
}

.spell-tooltip-close:active {
    transform: scale(0.95);
}

/* Corps de l'infobulle - Suggestions */
.spell-tooltip-body {
    padding: 16px;
}

.spell-tooltip-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spell-suggestion-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.spell-suggestion-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spell-suggestion-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.spell-suggestion-btn:hover::before {
    opacity: 1;
}

.spell-suggestion-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.spell-suggestion-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Raccourci clavier affiché */
.spell-suggestion-shortcut {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    margin-left: 12px;
}

/* Footer de l'infobulle */
.spell-tooltip-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px 16px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.spell-tooltip-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: white;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.spell-tooltip-btn:hover {
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.2);
    color: #1e293b;
}

.spell-tooltip-btn:active {
    transform: scale(0.98);
    background: #e2e8f0;
}

.spell-tooltip-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.spell-tooltip-always-ignore {
    border-color: #fbbf24;
    color: #92400e;
}

.spell-tooltip-always-ignore:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #78350f;
}

/* Flèche de l'infobulle */
.spell-tooltip-arrow {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transform: rotate(45deg);
    left: 50%;
    top: -9px;
    margin-left: -8px;
    border-bottom: none;
    border-right: none;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

/* Infobulle au-dessus du mot */
.spell-tooltip.above .spell-tooltip-arrow {
    top: auto;
    bottom: -9px;
    border-top: none;
    border-left: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

/* Animation d'apparition */
@keyframes spell-tooltip-appear {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive - Mobile et tablette */
@media (max-width: 768px) {
    .spell-tooltip-content {
        min-width: 280px;
        max-width: calc(100vw - 40px);
    }
    
    .spell-tooltip-header {
        padding: 16px 16px 12px 16px;
    }
    
    .spell-tooltip-question {
        font-size: 15px;
    }
    
    .spell-tooltip-body {
        padding: 16px;
    }
    
    .spell-suggestion-btn {
        padding: 16px;
        font-size: 15px;
        min-height: 52px; /* Taille tactile augmentée */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .spell-tooltip-footer {
        padding: 12px 16px 16px 16px;
        flex-direction: column;
        gap: 10px;
    }
    
    .spell-tooltip-btn {
        min-height: 48px; /* Taille tactile recommandée */
        font-size: 15px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Responsive - Tablette */
@media (min-width: 769px) and (max-width: 1024px) {
    .spell-tooltip-content {
        min-width: 320px;
    }
    
    .spell-suggestion-btn {
        min-height: 48px;
        font-size: 15px;
    }
    
    .spell-tooltip-btn {
        min-height: 44px;
    }
}

/* Mode sombre (si Imagilire Studio l'implémente) */
@media (prefers-color-scheme: dark) {
    .spell-tooltip-content {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                    0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .spell-tooltip-header {
        background: linear-gradient(to bottom, #334155 0%, #1e293b 100%);
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }
    
    .spell-tooltip-question {
        color: #f1f5f9;
    }
    
    .spell-tooltip-close {
        color: #cbd5e1;
    }
    
    .spell-tooltip-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #f1f5f9;
    }
    
    .spell-tooltip-btn {
        background: #334155;
        color: #cbd5e1;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .spell-tooltip-btn:hover {
        background: #475569;
        border-color: rgba(255, 255, 255, 0.2);
        color: #f1f5f9;
    }
    
    .spell-tooltip-btn:active {
        background: #3f4f66;
    }
    
    .spell-tooltip-always-ignore {
        border-color: #f59e0b;
        color: #fbbf24;
    }
    
    .spell-tooltip-always-ignore:hover {
        background: rgba(251, 191, 36, 0.1);
        border-color: #fbbf24;
        color: #fcd34d;
    }
    
    .spell-tooltip-arrow {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .spell-tooltip-footer {
        border-top-color: rgba(255, 255, 255, 0.08);
    }
}

/* Classe pour le thème sombre explicite d'Imagilire Studio */
[data-theme="dark"] .spell-tooltip-content,
.theme-dark .spell-tooltip-content {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .spell-tooltip-header,
.theme-dark .spell-tooltip-header {
    background: linear-gradient(to bottom, #334155 0%, #1e293b 100%);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .spell-tooltip-question,
.theme-dark .spell-tooltip-question {
    color: #f1f5f9;
}

[data-theme="dark"] .spell-tooltip-close,
.theme-dark .spell-tooltip-close {
    color: #cbd5e1;
}

[data-theme="dark"] .spell-tooltip-close:hover,
.theme-dark .spell-tooltip-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

[data-theme="dark"] .spell-tooltip-btn,
.theme-dark .spell-tooltip-btn {
    background: #334155;
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .spell-tooltip-btn:hover,
.theme-dark .spell-tooltip-btn:hover {
    background: #475569;
    border-color: rgba(255, 255, 255, 0.2);
    color: #f1f5f9;
}

[data-theme="dark"] .spell-tooltip-btn:active,
.theme-dark .spell-tooltip-btn:active {
    background: #3f4f66;
}

[data-theme="dark"] .spell-tooltip-always-ignore,
.theme-dark .spell-tooltip-always-ignore {
    border-color: #f59e0b;
    color: #fbbf24;
}

[data-theme="dark"] .spell-tooltip-always-ignore:hover,
.theme-dark .spell-tooltip-always-ignore:hover {
    background: rgba(251, 191, 36, 0.1);
    border-color: #fbbf24;
    color: #fcd34d;
}

[data-theme="dark"] .spell-tooltip-arrow,
.theme-dark .spell-tooltip-arrow {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .spell-tooltip-footer,
.theme-dark .spell-tooltip-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

/* Accessibilité - réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .spell-tooltip,
    .spell-tooltip-btn,
    .spell-suggestion-btn,
    .spell-tooltip-close {
        transition: none;
    }
    
    .spell-tooltip.visible {
        animation: none;
    }
}

/* Focus visible pour l'accessibilité clavier */
.spell-tooltip-btn:focus-visible,
.spell-suggestion-btn:focus-visible,
.spell-tooltip-close:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Amélioration du contraste pour l'accessibilité */
@media (prefers-contrast: high) {
    .spell-tooltip-content {
        border: 2px solid #000;
    }
    
    .spell-tooltip-btn,
    .spell-suggestion-btn {
        border: 2px solid currentColor;
    }
}
