<?= $this->extend('layouts/app') ?>

<?= $this->section('content') ?>

<style>
    /* ===== MODERN SAAS DESIGN SYSTEM TOKENS ===== */
    :root {
        --bg-body: #f8fafc;
        --bg-card: #ffffff;
        --bg-accent: #f1f5f9;
        --bg-input: #ffffff;
        --border-color: #e2e8f0;
        --border-hover: #cbd5e1;
        --text-main: #0f172a;
        --text-sub: #64748b;
        --primary: #4f46e5;
        --primary-hover: #4338ca;
        --primary-light: rgba(79, 70, 229, 0.08);
        --success: #10b981;
        --warning: #f59e0b;
        --danger: #ef4444;
        --info: #06b6d4;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
        --radius-lg: 16px;
        --radius-md: 12px;
        --radius-sm: 8px;
        --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --bg-body: #0b0f19;
            --bg-card: #151e2e;
            --bg-accent: #1e293b;
            --bg-input: #0f172a;
            --border-color: #243044;
            --border-hover: #334155;
            --text-main: #f8fafc;
            --text-sub: #94a3b8;
            --primary-light: rgba(79, 70, 229, 0.18);
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        }
    }

    [data-bs-theme="dark"] {
        --bg-body: #0b0f19;
        --bg-card: #151e2e;
        --bg-accent: #1e293b;
        --bg-input: #0f172a;
        --border-color: #243044;
        --border-hover: #334155;
        --text-main: #f8fafc;
        --text-sub: #94a3b8;
        --primary-light: rgba(79, 70, 229, 0.18);
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    }

    body, .content-wrapper, .main-content, .content, .page-content, main, .detail-log-workspace {
        background-color: var(--bg-body) !important;
        color: var(--text-main) !important;
        transition: var(--transition);
    }

    .detail-card-container {
        max-width: 840px;
        margin: 0 auto;
    }

    /* Card Premium Styling */
    .card-modern {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 2rem;
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }

    /* Hero Log Header */
    .log-hero-header {
        background: var(--bg-accent);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1.5rem;
    }

    .avatar-circle-hero {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 800;
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        box-shadow: inset 0 0 0 2px var(--primary);
    }

    /* Code Pill for Identifiers */
    .code-pill {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-main);
        font-family: var(--bs-font-monospace);
        font-size: 0.85rem;
        font-weight: 600;
        padding: 0.25rem 0.6rem;
        border-radius: var(--radius-sm);
    }

    /* Soft Badges */
    .badge-soft-primary { background: rgba(79, 70, 229, 0.12); color: #4f46e5; border: 1px solid rgba(79, 70, 229, 0.2); }
    .badge-soft-info    { background: rgba(6, 182, 212, 0.12); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.2); }
    .badge-soft-warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }

    /* Property Items Grid */
    .property-card {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1rem 1.25rem;
        transition: var(--transition);
        height: 100%;
    }

    .property-card:hover {
        border-color: var(--border-hover);
        background: var(--bg-accent);
    }

    .property-label {
        font-size: 0.72rem;
        color: var(--text-sub);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin-bottom: 0.35rem;
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

    .property-value {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-main);
        word-break: break-word;
    }

    /* Highlight Activity Box */
    .activity-highlight-box {
        background: var(--bg-accent);
        border: 1px solid var(--border-color);
        border-left: 4px solid var(--primary);
        border-radius: var(--radius-md);
        padding: 1.25rem;
    }
</style>

<div class="container-fluid py-4 detail-log-workspace">
    
    <div class="detail-card-container">
        
        <!-- PAGE HEADER -->
        <div class="d-flex flex-column flex-sm-row justify-content-between align-items-sm-center mb-4 gap-3">
            <div>
                <h3 class="fw-bold mb-0 text-main">Detail Aktivitas Log</h3>
                <p class="text-sub small mb-0 mt-0.5">Rincian rekam jejak aksi dan atribut eksekusi sistem.</p>
            </div>
            <div>
                <a href="<?= base_url('superadmin/activitylog') ?>" class="btn btn-outline-secondary rounded-3 px-3 py-2 fw-semibold d-inline-flex align-items-center gap-2 fs-7">
                    <i class="bi bi-arrow-left"></i> Kembali
                </a>
            </div>
        </div>

        <?php 
            $namaLengkap = $log['nama_lengkap'] ?? 'System';
            $initial = strtoupper(substr(trim($namaLengkap), 0, 1));
            $roleName = strtolower($log['nama_role'] ?? 'system');
            
            // Dynamic Role Badge Color
            $roleBadgeClass = 'badge-soft-info';
            if (str_contains($roleName, 'admin') || str_contains($roleName, 'super')) {
                $roleBadgeClass = 'badge-soft-primary';
            } elseif (str_contains($roleName, 'staff') || str_contains($roleName, 'operator')) {
                $roleBadgeClass = 'badge-soft-warning';
            }
        ?>

        <!-- MAIN CARD CONTAINER -->
        <div class="card-modern">
            
            <!-- HERO LOG HEADER -->
            <div class="log-hero-header mb-4">
                <div class="d-flex flex-column flex-sm-row align-items-sm-center justify-content-between gap-3">
                    <div class="d-flex align-items-center gap-3">
                        <div class="avatar-circle-hero"><?= $initial ?></div>
                        <div>
                            <h5 class="fw-bold text-main mb-1"><?= esc($namaLengkap) ?></h5>
                            <div class="d-flex flex-wrap align-items-center gap-2">
                                <span class="code-pill text-primary">
                                    <i class="bi bi-at"></i><?= esc($log['username'] ?? 'system') ?>
                                </span>
                                <span class="badge <?= $roleBadgeClass ?> rounded-pill px-2.5 py-1">
                                    <i class="bi bi-shield-check me-1"></i><?= esc($log['nama_role'] ?? 'System') ?>
                                </span>
                            </div>
                        </div>
                    </div>

                    <!-- ID LOG PILL -->
                    <div class="align-self-start align-self-sm-center">
                        <span class="code-pill fs-7 text-sub">
                            <i class="bi bi-hash text-primary me-0.5"></i>ID LOG: <?= esc($log['id_log']) ?>
                        </span>
                    </div>
                </div>
            </div>

            <!-- DETAILED PROPERTY GRID -->
            <div class="row g-3 mb-4">
                
                <!-- ID Log -->
                <div class="col-12 col-sm-6">
                    <div class="property-card">
                        <div class="property-label">
                            <i class="bi bi-hash text-primary"></i> ID Log Aktivitas
                        </div>
                        <div class="property-value font-monospace">
                            #<?= esc($log['id_log']) ?>
                        </div>
                    </div>
                </div>

                <!-- Waktu Eksekusi -->
                <div class="col-12 col-sm-6">
                    <div class="property-card">
                        <div class="property-label">
                            <i class="bi bi-clock-history text-primary"></i> Stempel Waktu (Timestamp)
                        </div>
                        <div class="property-value font-monospace">
                            <?= esc($log['timestamp'] ?? '-') ?>
                        </div>
                    </div>
                </div>

                <!-- Username -->
                <div class="col-12 col-sm-6">
                    <div class="property-card">
                        <div class="property-label">
                            <i class="bi bi-at text-primary"></i> Username
                        </div>
                        <div class="property-value font-monospace text-primary">
                            <?= esc($log['username'] ?? '-') ?>
                        </div>
                    </div>
                </div>

                <!-- Role / Hak Akses -->
                <div class="col-12 col-sm-6">
                    <div class="property-card">
                        <div class="property-label">
                            <i class="bi bi-shield-lock text-primary"></i> Role / Peran
                        </div>
                        <div class="property-value">
                            <?= esc($log['nama_role'] ?? '-') ?>
                        </div>
                    </div>
                </div>

            </div>

            <!-- FULL ACTIVITY DESCRIPTION HIGHLIGHT -->
            <div class="activity-highlight-box mb-4">
                <div class="property-label mb-2">
                    <i class="bi bi-terminal text-primary"></i> Deskripsi Rincian Aktivitas
                </div>
                <div class="property-value fs-6 fw-semibold text-main">
                    <?= esc($log['aktivitas'] ?? '-') ?>
                </div>
            </div>

            <!-- ACTION TOOLBAR -->
            <div class="d-flex justify-content-between align-items-center pt-3 border-top border-color">
                <a href="<?= base_url('superadmin/activitylog') ?>" class="btn btn-outline-secondary rounded-3 py-2 px-4 fw-semibold">
                    <i class="bi bi-arrow-left me-1"></i> Kembali ke Daftar Log
                </a>
            </div>

        </div>

    </div>

</div>

<?= $this->endSection() ?>