{% extends "layouts/base.html" %}
{% block title %}Call Transcript{% endblock %}
{% block extra_css %}
<style>
    body {
        background: #f5f7fb;
    }

    .transcript-container {
        max-width: 900px;
        margin: 0 auto;
        padding: 32px 24px 80px;
    }

    .transcript-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 24px;
    }

    .transcript-header h1 {
        margin: 0 0 6px;
        font-size: 28px;
        font-weight: 700;
        color: #0f172a;
    }

    .transcript-header p {
        margin: 0;
        color: #475569;
        font-size: 15px;
    }

    .status-chip {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 6px 14px;
        border-radius: 999px;
        font-size: 13px;
        font-weight: 600;
        background: rgba(37, 99, 235, 0.12);
        color: #1d4ed8;
    }

    .status-chip.success {
        background: rgba(34, 197, 94, 0.16);
        color: #15803d;
    }

    .status-chip.pending {
        background: rgba(245, 158, 11, 0.16);
        color: #b45309;
    }

    .status-chip.failed {
        background: rgba(248, 113, 113, 0.18);
        color: #b91c1c;
    }

    .info-card {
        background: #ffffff;
        border-radius: 18px;
        padding: 20px 24px;
        box-shadow: 0 30px 60px rgba(15, 23, 42, 0.06);
        border: 1px solid rgba(148, 163, 184, 0.12);
        margin-bottom: 24px;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        flex-wrap: wrap;
    }

    .info-item {
        display: flex;
        flex-direction: column;
        gap: 6px;
        min-width: 160px;
    }

    .info-label {
        font-size: 12px;
        text-transform: uppercase;
        color: #94a3b8;
        letter-spacing: 0.08em;
        font-weight: 600;
    }

    .info-value {
        font-size: 16px;
        font-weight: 600;
        color: #0f172a;
    }

    .chat-card {
        background: #ffffff;
        border-radius: 18px;
        box-shadow: 0 35px 65px rgba(15, 23, 42, 0.06);
        border: 1px solid rgba(148, 163, 184, 0.12);
        padding: 28px 24px;
    }

    .chat-transcript {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .chat-message {
        display: flex;
        gap: 14px;
    }

    .chat-bubble {
        max-width: 75%;
        padding: 14px 18px;
        border-radius: 18px;
        position: relative;
        font-size: 15px;
        line-height: 1.6;
        background: #e0e7ff;
        color: #1f2937;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
    }

    .user-message {
        justify-content: flex-end;
    }

    .user-message .chat-bubble {
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        color: #fff;
        border-bottom-right-radius: 6px;
        border-bottom-left-radius: 16px;
    }

    .ai-message {
        justify-content: flex-start;
    }

    .ai-message .chat-bubble {
        background: #eef2ff;
        color: #1f2937;
        border-bottom-left-radius: 6px;
        border-bottom-right-radius: 16px;
    }

    .chat-bubble strong {
        display: block;
        margin-bottom: 6px;
        font-size: 13px;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .user-message .chat-bubble strong {
        color: rgba(255, 255, 255, 0.85);
    }

    .chat-timestamp {
        display: block;
        font-size: 12px;
        color: #94a3b8;
        margin-top: 10px;
        text-align: right;
    }

    .user-message .chat-timestamp {
        color: rgba(255, 255, 255, 0.7);
    }

    .transcript-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 20px;
    }

    .action-button {
        text-decoration: none;
        padding: 12px 18px;
        border-radius: 12px;
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
    }

    .action-button.primary {
        background: linear-gradient(135deg, #1d4ed8, #2563eb);
        color: #fff;
        box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
    }

    .action-button.primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 16px 30px rgba(37, 99, 235, 0.3);
    }

    @media (max-width: 768px) {
        .chat-bubble {
            max-width: 100%;
        }

        .info-card {
            flex-direction: column;
            align-items: flex-start;
        }
    }
</style>
{% endblock %}
{% block content %}
<div class="transcript-container">
    <div class="transcript-header">
        <div>
            <h1>Call Transcript</h1>
            <p>Full conversation log for {{ call[1] }} ({{ call[2] }}).</p>
        </div>
        <div class="status-chip {{ call[3]|lower }}">
            <i class="fa-solid fa-circle"></i>
            {{ call[3] }}
        </div>
    </div>

    <div class="info-card">
        <div class="info-item">
            <span class="info-label">Contact</span>
            <span class="info-value">{{ call[1] }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">Phone Number</span>
            <span class="info-value">{{ call[2] }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">Status</span>
            <span class="info-value">{{ call[3] }}</span>
        </div>
    </div>

    <div class="transcript-actions" style="margin-bottom: 20px;"> 
        <a class="action-button primary" href="{{ url_for('company.view_call_campaign', campaign_id=campaign_id) }}">
            <i class="fa-light fa-arrow-left"></i> Back to Campaign
        </a>
    </div>

    <div class="chat-card">
        <div class="chat-transcript">
            {% for entry in transcript %}
            {% if entry[0] %}
            <div class="chat-message user-message">
                <div class="chat-bubble">
                    <strong>User</strong>
                    {{ entry[0] }}
                    <span class="chat-timestamp">{{ entry[2] }}</span>
                </div>
            </div>
            {% endif %}
            {% if entry[1] %}
            <div class="chat-message ai-message">
                <div class="chat-bubble">
                    <strong>AI</strong>
                    {{ entry[1] }}
                    <span class="chat-timestamp">{{ entry[2] }}</span>
                </div>
            </div>
            {% endif %}
            {% endfor %}
        </div>
    </div>
</div>
{% endblock %}