import sys

with open('frontend/admin.html', 'r', encoding='utf-8') as f:
    content = f.read()

# 1. Update Rastreamento spacing
content = content.replace(
    '        <div id="aba-rastreamento" class="tab-section">\n            <div style="margin:0; min-height:calc(100vh - 120px);">',
    '        <div id="aba-rastreamento" class="tab-section">\n            <div style="margin:0; min-height:calc(100vh - 120px); padding-bottom:120px;">'
)

# 2. Update Entregadores spacing
content = content.replace(
    '        <!-- ======== ABA GERENCIAR ENTREGADORES ======== -->\n        <div id="aba-entregadores" class="tab-section">',
    '        <!-- ======== ABA GERENCIAR ENTREGADORES ======== -->\n        <div id="aba-entregadores" class="tab-section" style="padding-bottom:120px;">'
)


# 3. Update Impressão y
content = content.replace(
    'bottom:396px; right:24px; width:52px; height:52px; border-radius:50%; background:#007bff;',
    'bottom:458px; right:24px; width:52px; height:52px; border-radius:50%; background:#007bff;'
)

# 4. Update Chat y
content = content.replace(
    'bottom:334px; right:24px; width:52px; height:52px; border-radius:50%; background:#075E54;',
    'bottom:396px; right:24px; width:52px; height:52px; border-radius:50%; background:#075E54;'
)

# 5. Update Pedidos y
content = content.replace(
    'bottom:272px; right:24px; width:52px; height:52px; border-radius:50%; background:#34495e;',
    'bottom:334px; right:24px; width:52px; height:52px; border-radius:50%; background:#34495e;'
)

# 6. Add Rastreamento button before Balcão
novo_btn = """    <!-- 🛵 BOTÃO FLUTUANTE RASTREAMENTO -->
    <button onclick="document.querySelector(`.nav-btn[onclick*='rastreamento']`).click()" title="Rastreamento em Tempo Real" style="position:fixed; bottom:272px; right:24px; width:52px; height:52px; border-radius:50%; background:#e84393; color:white; border:none; cursor:pointer; font-size:20px; box-shadow:0 4px 16px rgba(232,67,147,0.4); z-index:9990; display:flex; align-items:center; justify-content:center; transition:0.2s;" onmouseover="this.style.transform='scale(1.1)'" onmouseout="this.style.transform='scale(1)'">
        <i class="fas fa-motorcycle"></i>
    </button>

    <!-- 🏪 BOTÃO FLUTUANTE BALCÃO -->"""

content = content.replace('    <!-- 🏪 BOTÃO FLUTUANTE BALCÃO -->', novo_btn)

with open('frontend/admin.html', 'w', encoding='utf-8') as f:
    f.write(content)

print("Modificados:", 
    "Rastreamento OK" if 'padding-bottom:120px' in content else "Falhou",
)
