# -*- coding: utf-8 -*-
"""
Script d'intégration du scénario 'Suppositions' de Raphaël dans blocnotes.html.
"""

with open(r'C:\ASSISTANT_IA\JARVIS_LIVE_VOICE\public_jarvis\blocnotes.html', 'r', encoding='utf-8') as f:
    html = f.read()

# 1. Ajouter le bouton d'onglet Suppositions dans la barre d'onglets
old_nav = '<button class="tab-btn" onclick="switchTab(\'handball\', this)">🌍 Handball Afrique</button>'
new_nav = '<button class="tab-btn" onclick="switchTab(\'handball\', this)">🌍 Handball Afrique</button>\n        <button class="tab-btn" onclick="switchTab(\'suppositions\', this)" style="border-color: rgba(239, 68, 68, 0.4); color: #fca5a5;">💔 Suppositions</button>'

if old_nav in html:
    html = html.replace(old_nav, new_nav)
    print("1. Bouton d'onglet Suppositions ajouté.")

# 2. Ajouter le conteneur tab-suppositions
target_dock = '    <!-- Master Audio Dock Flottant pour écoute mains-libres -->'
tab_suppositions_html = '''    <!-- ONGLET 8 : SUPPOSITIONS (SCÉNARIO RAPHAËL) -->
    <div id="tab-suppositions" class="tab-content">
      <div style="background: rgba(239, 68, 68, 0.08); border-left: 4px solid #ef4444; padding: 14px 18px; border-radius: 0 10px 10px 0; margin-bottom: 20px;">
        <h2 style="margin: 0; font-size: 1.25rem; color: #fca5a5; display: flex; align-items: center; gap: 8px;">
          💔 Scénario Cinématographique : Suppositions
        </h2>
        <p style="margin: 6px 0 0 0; font-size: 0.88rem; color: #cbd5e1; line-height: 1.45;">
          Drame intimiste &amp; huis clos relationnel écrit par <strong>Raphaël</strong>. La spirale des non-dits et des projections anxieuses dans un couple à bout de souffle.
        </p>
        <div style="margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;">
          <audio controls style="width: 100%; max-width: 480px; height: 38px; border-radius: 8px;">
            <source src="/artifacts/SCENARIO_SUPPOSITIONS.mp3" type="audio/mpeg">
            <source src="/media/artifacts_audio/SCENARIO_SUPPOSITIONS.mp3" type="audio/mpeg">
          </audio>
          <a href="/artifacts/SCENARIO_SUPPOSITIONS.html" target="_blank" class="bn-btn" style="border-color: rgba(239, 68, 68, 0.4); color: #fca5a5;">
            ↗️ Ouvrir en Plein Écran
          </a>
        </div>
      </div>
      <div class="md-container" id="content-suppositions">Chargement du scénario Suppositions...</div>
    </div>\n\n'''

if target_dock in html:
    html = html.replace(target_dock, tab_suppositions_html + target_dock)
    print("2. Conteneur tab-suppositions inséré.")

# 3. Ajouter loadMarkdown pour suppositions
old_load = "loadMarkdown('/artifacts/SCENARIO_HANDBALL_AFRIQUE_LE_SAUT_DU_DESTIN.md', 'content-handball');"
new_load = "loadMarkdown('/artifacts/SCENARIO_HANDBALL_AFRIQUE_LE_SAUT_DU_DESTIN.md', 'content-handball');\n    loadMarkdown('/artifacts/SCENARIO_SUPPOSITIONS.md', 'content-suppositions');"

if old_load in html:
    html = html.replace(old_load, new_load)
    print("3. loadMarkdown Suppositions ajouté.")

# Sauvegarder dans public_jarvis et public
for p in [r'C:\ASSISTANT_IA\JARVIS_LIVE_VOICE\public_jarvis\blocnotes.html', r'C:\ASSISTANT_IA\JARVIS_LIVE_VOICE\public\blocnotes.html']:
    with open(p, 'w', encoding='utf-8') as f:
        f.write(html)
    print("Fichier synchronisé :", p)
