def replace_desc():
    with open('app/modules/sag/templates/detail.html', 'r', encoding='utf-8') as f:
        html = f.read()
    
    start_str = "<!-- ROW 1: Main Info -->"
    end_str = "<!-- ROW 1B: Pipeline -->"
    
    start_idx = html.find(start_str)
    end_idx = html.find(end_str)
    
    if start_idx == -1 or end_idx == -1:
        print("COULD NOT FIND ROWS")
        return
        
    new_desc = """<!-- ROW 1: Main Info -->
    <div class="row mb-3">
        <!-- MAIN HERO CARD: Titel & Beskrivelse -->
        <div class="col-12 mb-4 mt-2">
            <div class="card shadow-sm border-0 border-start border-4 border-primary" style="background-color: var(--bg-card); border-radius: 8px;">
                <div class="card-body p-4 pt-4 pb-5 position-relative">
                    <div class="d-flex justify-content-between align-items-start mb-4">
                        <div class="w-100 pe-3">
                            <h2 class="mb-2 fw-bolder" style="color: var(--accent); font-size: 1.8rem; letter-spacing: -0.5px;">
                                {{ case.titel }}
                            </h2>
                            <div class="d-flex align-items-center gap-2 mb-1 mt-2">
                                <span class="badge {{ 'bg-success' if case.status == 'åben' else 'bg-secondary' }} px-2 py-1 shadow-sm">{{ case.status }}</span>
                                <span class="badge bg-light text-dark border px-2 py-1">{{ case.template_key or case.type or 'ticket' }}</span>
                            </div>
                        </div>
                        
                        <div class="d-flex gap-2 flex-shrink-0 mt-1">
                            <a href="/sag/{{ case.id }}/edit" class="btn btn-outline-primary shadow-sm" style="border-radius: 6px;">
                                <i class="bi bi-pencil me-1"></i>Rediger sag
                            </a>
                            <button onclick="confirmDeleteCase()" class="btn btn-outline-danger shadow-sm" style="border-radius: 6px;" title="Slet sag">
                                <i class="bi bi-trash"></i>
                            </button>
                        </div>
                    </div>

                    <div class="mt-4 pt-3 border-top border-light">
                        <div class="d-flex align-items-center mb-3">
                            <i class="bi bi-card-text fs-5 text-muted me-2"></i>
                            <h6 class="text-muted text-uppercase small mb-0 fw-bold" style="letter-spacing: 0.05em;">Opgavebeskrivelse</h6>
                        </div>
                        
                        <div class="description-section rounded bg-white p-4 shadow-sm border" style="min-height: 120px;">
                            <div class="prose text-dark" style="font-size: 1.05rem; line-height: 1.7; white-space: pre-wrap;">{{ case.beskrivelse or '<div class="text-center p-3"><p class="text-muted fst-italic mb-2">Ingen opgavebeskrivelse tilføjet endnu.</p></div>' | safe }}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    """
    
    html = html[:start_idx] + new_desc + "\n    " + html[end_idx:]
    with open('app/modules/sag/templates/detail.html', 'w', encoding='utf-8') as f:
        f.write(html)
        print("Done description")

replace_desc()