/* Système d'aide contextuelle - Styles CSS */

/* Icône d'aide - Style amélioré et moderne */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    cursor: pointer;
    font-size: 14px;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    vertical-align: middle;
    user-select: none;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    position: relative;
    font-weight: 600;
}

.help-icon::before {
    content: 'i';
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-weight: bold;
    font-size: 12px;
    line-height: 1;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.help-icon:hover {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.help-icon:active {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* Animation pulse subtile */
@keyframes helpIconPulse {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    }
}

.help-icon:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 50%;
    animation: helpIconPulse 2s ease-in-out infinite;
}

/* Conteneur du popup */
#help-popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

/* Popup d'aide */
.help-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    pointer-events: auto;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
    transition: all 0.2s ease;
}

.help-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.help-popup.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
    pointer-events: none;
}

/* Contenu du popup */
.help-popup-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 80vh;
    overflow: hidden;
}

/* En-tête du popup */
.help-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.help-popup-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
}

.help-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-popup-close:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Corps du popup */
.help-popup-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    line-height: 1.6;
    color: #374151;
    /* Scrollbar personnalisée pour meilleure visibilité */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Scrollbar personnalisée pour WebKit */
.help-popup-body::-webkit-scrollbar {
    width: 8px;
}

.help-popup-body::-webkit-scrollbar-track {
    background: transparent;
}

.help-popup-body::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

.help-popup-body::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Sections d'aide */
.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section p {
    margin: 0 0 12px 0;
    color: #4b5563;
}

.help-section ul,
.help-section ol {
    margin: 0 0 12px 0;
    padding-left: 20px;
    color: #4b5563;
}

.help-section li {
    margin-bottom: 6px;
}

.help-section li:last-child {
    margin-bottom: 0;
}

.help-section strong {
    color: #111827;
    font-weight: 600;
}

/* Code dans les sections d'aide */
.help-section pre {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.4;
}

.help-section code {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #dc2626;
}

/* Overlay sombre */
.help-popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.help-popup.show::before {
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .help-popup {
        width: 95%;
        max-height: 85vh;
        margin: 20px;
    }
    
    .help-popup-content {
        max-height: 85vh;
    }
    
    .help-popup-header {
        padding: 16px 20px 12px;
        flex-shrink: 0;
    }
    
    .help-popup-title {
        font-size: 18px;
    }
    
    .help-popup-body {
        padding: 20px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    
    .help-section {
        margin-bottom: 20px;
    }
}

/* Animation d'apparition */
@keyframes helpPopupAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.help-popup.show {
    animation: helpPopupAppear 0.2s ease-out;
}

/* Styles pour les icônes d'aide dans les titres */
h1 .help-icon,
h2 .help-icon,
h3 .help-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    margin-left: 12px;
}

h1 .help-icon::before,
h2 .help-icon::before,
h3 .help-icon::before {
    font-size: 14px;
}

/* Styles pour les icônes d'aide dans les boutons */
.btn .help-icon {
    margin-left: 6px;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
}

.btn .help-icon::before {
    font-size: 11px;
}

/* Styles pour les icônes d'aide dans les cartes */
.card .help-icon,
.relative .help-icon[style*="position: absolute"] {
    position: absolute;
    top: 12px;
    right: 12px;
    margin: 0;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
}

.card .help-icon::before,
.relative .help-icon[style*="position: absolute"]::before {
    font-size: 11px;
}

.help-popup:focus {
    outline: none;
}

/* Mode sombre */
.dark .help-popup,
[class*="dark"] .help-popup {
    background: #1f2937;
    color: #f9fafb;
}

.dark .help-popup-header,
[class*="dark"] .help-popup-header {
    background: #111827;
    border-bottom-color: #374151;
}

.dark .help-popup-title,
[class*="dark"] .help-popup-title {
    color: #f9fafb;
}

.dark .help-popup-close,
[class*="dark"] .help-popup-close {
    color: #9ca3af;
}

.dark .help-popup-close:hover,
[class*="dark"] .help-popup-close:hover {
    background: #374151;
    color: #f9fafb;
}

.dark .help-popup-body,
[class*="dark"] .help-popup-body {
    color: #d1d5db;
    scrollbar-color: #4b5563 transparent;
}

.dark .help-popup-body::-webkit-scrollbar-thumb,
[class*="dark"] .help-popup-body::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

.dark .help-popup-body::-webkit-scrollbar-thumb:hover,
[class*="dark"] .help-popup-body::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
}

.dark .help-section h4,
[class*="dark"] .help-section h4 {
    color: #f9fafb;
}

.dark .help-section p,
.dark .help-section li,
[class*="dark"] .help-section p,
[class*="dark"] .help-section li {
    color: #d1d5db;
}

.dark .help-section strong,
[class*="dark"] .help-section strong {
    color: #f9fafb;
}

.dark .help-section pre,
[class*="dark"] .help-section pre {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
}

.dark .help-section code,
[class*="dark"] .help-section code {
    background: #111827;
    border-color: #374151;
    color: #f87171;
}

/* Styles spécifiques pour le popup score-info en mode sombre */
.dark .score-info-card,
[class*="dark"] .score-info-card {
    background: #1f2937 !important;
    border-color: #374151 !important;
}

.dark .score-info-title,
[class*="dark"] .score-info-title {
    color: #f9fafb !important;
}

.dark .score-info-text,
[class*="dark"] .score-info-text {
    color: #d1d5db !important;
}

.dark .score-info-text strong,
[class*="dark"] .score-info-text strong {
    color: #f9fafb !important;
}

.dark .score-info-list,
[class*="dark"] .score-info-list {
    color: #d1d5db !important;
}

.dark .score-info-list li,
[class*="dark"] .score-info-list li {
    color: #d1d5db !important;
}

/* Mode clair : texte en noir pour meilleure lisibilité */
.score-info-text {
    color: #111827 !important;
}

.score-info-list {
    color: #111827 !important;
}

.score-info-list li {
    color: #111827 !important;
}

.dark .score-formula-box,
[class*="dark"] .score-formula-box {
    background: #111827 !important;
    border: 1px solid #374151 !important;
}

.dark .score-formula-text,
[class*="dark"] .score-formula-text {
    color: #d1d5db !important;
}

.dark .score-bonus-box,
.dark .score-malus-box,
[class*="dark"] .score-bonus-box,
[class*="dark"] .score-malus-box {
    background: #1f2937 !important;
    border: 1px solid #374151 !important;
}

.dark .score-bonus-title,
.dark .score-malus-title,
[class*="dark"] .score-bonus-title,
[class*="dark"] .score-malus-title {
    color: #f9fafb !important;
}

.dark .score-bonus-list,
.dark .score-malus-list,
[class*="dark"] .score-bonus-list,
[class*="dark"] .score-malus-list {
    color: #d1d5db !important;
}

.dark .score-bonus-list li,
.dark .score-malus-list li,
[class*="dark"] .score-bonus-list li,
[class*="dark"] .score-malus-list li {
    color: #d1d5db !important;
}

/* Mode sombre pour l'icône */
.dark .help-icon,
[class*="dark"] .help-icon {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.dark .help-icon:hover,
[class*="dark"] .help-icon:hover {
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

/* Mode sombre (si supporté via media query) */
@media (prefers-color-scheme: dark) {
    .help-popup:not(.light) {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .help-popup-header:not(.light) {
        background: #111827;
        border-bottom-color: #374151;
    }
    
    .help-popup-title:not(.light) {
        color: #f9fafb;
    }
    
    .help-popup-close:not(.light) {
        color: #9ca3af;
    }
    
    .help-popup-close:not(.light):hover {
        background: #374151;
        color: #f9fafb;
    }
    
    .help-popup-body:not(.light) {
        color: #d1d5db;
    }
    
    .help-section:not(.light) h4 {
        color: #f9fafb;
    }
    
    .help-section:not(.light) p,
    .help-section:not(.light) li {
        color: #d1d5db;
    }
    
    .help-section:not(.light) strong {
        color: #f9fafb;
    }
    
    .help-section:not(.light) pre {
        background: #111827;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .help-section:not(.light) code {
        background: #111827;
        border-color: #374151;
        color: #f87171;
    }
}
