@php
    $record = $getRecord();

    $badgeClass = match ($record->action) {
        'created' => 'badge-created',
        'updated' => 'badge-updated',
        'deleted' => 'badge-deleted',
        default   => 'badge-default',
    };

    $dotClass = match ($record->action) {
        'created' => 'dot-created',
        'updated' => 'dot-updated',
        'deleted' => 'dot-deleted',
        default   => 'dot-default',
    };

    $actionLabel = match ($record->action) {
        'created' => class_basename($record->loggable_type ?? '') . ' Created',
        'updated' => class_basename($record->loggable_type ?? '') . ' Updated',
        'deleted' => class_basename($record->loggable_type ?? '') . ' Deleted',
        default   => ucfirst($record->action),
    };
@endphp

<style>
    .log-modal-container {
        font-family: inherit;
    }
    .log-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }
    @media (max-width: 768px) {
        .log-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }
    }
    @media (max-width: 480px) {
        .log-grid {
            grid-template-columns: 1fr;
            gap: 10px;
        }
    }
    .log-card {
        background-color: #f8fafc;
        border: 1px solid #f1f5f9;
        border-radius: 12px;
        padding: 14px 16px;
        transition: all 0.2s ease;
    }
    .dark .log-card {
        background-color: rgba(31, 41, 55, 0.3);
        border-color: rgba(75, 85, 99, 0.3);
    }
    @media (max-width: 768px) {
        .log-card {
            padding: 10px 12px;
            border-radius: 10px;
        }
    }
    .log-agent-card {
        grid-column: span 2;
    }
    @media (max-width: 480px) {
        .log-agent-card {
            grid-column: span 1 !important;
        }
    }
    .log-label {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #94a3b8;
        margin-bottom: 8px;
    }
    @media (max-width: 768px) {
        .log-label {
            margin-bottom: 4px;
        }
    }
    .log-user-info {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    @media (max-width: 768px) {
        .log-user-info {
            gap: 6px;
        }
    }
    .log-avatar {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background-color: #e0e7ff;
        color: #6366f1;
        flex-shrink: 0;
    }
    .dark .log-avatar {
        background-color: rgba(99, 102, 241, 0.15);
        color: #818cf8;
    }
    .log-avatar svg {
        width: 16px;
        height: 16px;
    }
    @media (max-width: 768px) {
        .log-avatar {
            width: 22px;
            height: 22px;
        }
        .log-avatar svg {
            width: 12px;
            height: 12px;
        }
    }
    .log-username {
        font-size: 13px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .dark .log-username {
        color: #f3f4f6;
    }
    @media (max-width: 768px) {
        .log-username {
            font-size: 11.5px;
        }
    }
    .log-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 12px;
        border-radius: 9999px;
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
    }
    .badge-created {
        background-color: #f0fdf4;
        color: #16a34a;
        border: 1px solid #bbf7d0;
    }
    .dark .badge-created {
        background-color: rgba(22, 163, 74, 0.15);
        color: #4ade80;
        border-color: rgba(22, 163, 74, 0.25);
    }
    .badge-updated {
        background-color: #fffbeb;
        color: #d97706;
        border: 1px solid #fde68a;
    }
    .dark .badge-updated {
        background-color: rgba(217, 119, 6, 0.15);
        color: #fbbf24;
        border-color: rgba(217, 119, 6, 0.25);
    }
    .badge-deleted {
        background-color: #fff1f2;
        color: #e11d48;
        border: 1px solid #fecdd3;
    }
    .dark .badge-deleted {
        background-color: rgba(225, 29, 72, 0.15);
        color: #f43f5e;
        border-color: rgba(225, 29, 72, 0.25);
    }
    .badge-default {
        background-color: #f8fafc;
        color: #475569;
        border: 1px solid #e2e8f0;
    }
    .dark .badge-default {
        background-color: rgba(71, 85, 105, 0.15);
        color: #cbd5e1;
        border-color: rgba(71, 85, 105, 0.25);
    }
    @media (max-width: 768px) {
        .log-badge {
            padding: 3px 8px;
            font-size: 10.5px;
            gap: 4px;
        }
    }
    .log-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        display: inline-block;
        flex-shrink: 0;
    }
    .dot-created { background-color: #16a34a; }
    .dark .dot-created { background-color: #4ade80; }
    .dot-updated { background-color: #d97706; }
    .dark .dot-updated { background-color: #fbbf24; }
    .dot-deleted { background-color: #e11d48; }
    .dark .dot-deleted { background-color: #f43f5e; }
    .dot-default { background-color: #475569; }
    .dark .dot-default { background-color: #cbd5e1; }
    @media (max-width: 768px) {
        .log-dot {
            width: 5px;
            height: 5px;
        }
    }

    .log-time {
        font-size: 13px;
        color: #334155;
        font-weight: 650;
        line-height: 1.4;
    }
    .dark .log-time {
        color: #cbd5e1;
    }
    @media (max-width: 768px) {
        .log-time {
            font-size: 11.5px;
        }
    }
    .log-time-sec {
        font-size: 11px;
        color: #64748b;
        font-family: monospace;
        margin-top: 2px;
    }
    .dark .log-time-sec {
        color: #9ca3af;
    }
    @media (max-width: 768px) {
        .log-time-sec {
            font-size: 9.5px;
            margin-top: 1px;
        }
    }
    .log-mono-box {
        font-family: monospace;
        font-size: 12px;
        font-weight: 600;
        color: #334155;
        background-color: #ffffff;
        border: 1px solid #e2e8f0;
        padding: 4px 8px;
        border-radius: 6px;
        display: inline-block;
    }
    .dark .log-mono-box {
        color: #e5e7eb;
        background-color: rgba(17, 24, 39, 0.5);
        border-color: rgba(75, 85, 99, 0.4);
    }
    @media (max-width: 768px) {
        .log-mono-box {
            font-size: 10.5px;
            padding: 3px 6px;
        }
    }
    .log-agent-text {
        font-size: 11px;
        color: #475569;
        line-height: 1.5;
        overflow-wrap: break-word;
        word-break: normal;
        font-family: monospace;
    }
    .dark .log-agent-text {
        color: #cbd5e1;
    }
    @media (max-width: 768px) {
        .log-agent-text {
            font-size: 10px;
            line-height: 1.4;
        }
    }
    .log-desc-card {
        background-color: rgba(99, 102, 241, 0.03);
        border-left: 4px solid #6366f1;
        border-radius: 0 12px 12px 0;
        padding: 16px;
        margin-top: 16px;
    }
    .dark .log-desc-card {
        background-color: rgba(99, 102, 241, 0.02);
        border-left-color: #818cf8;
    }
    @media (max-width: 768px) {
        .log-desc-card {
            padding: 12px;
            margin-top: 12px;
        }
    }
    .log-desc-label {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6366f1;
        margin-bottom: 6px;
    }
    .dark .log-desc-label {
        color: #818cf8;
    }
    .log-desc-content {
        font-size: 13px;
        color: #1e293b;
        font-weight: 500;
        line-height: 1.5;
        overflow-wrap: break-word;
        word-break: normal;
    }
    .dark .log-desc-content {
        color: #cbd5e1;
    }
    @media (max-width: 768px) {
        .log-desc-content {
            font-size: 12px;
            line-height: 1.4;
        }
    }
</style>

<div class="log-modal-container">
    {{-- Combined Meta Grid --}}
    <div class="log-grid">
        {{-- User --}}
        <div class="log-card">
            <div class="log-label">User</div>
            <div class="log-user-info">
                <span class="log-avatar">
                    <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
                    </svg>
                </span>
                <span class="log-username">{{ $record->user?->name ?? 'System' }}</span>
            </div>
        </div>

        {{-- Event Type --}}
        <div class="log-card">
            <div class="log-label">Event Type</div>
            <div style="display: flex;">
                <span class="log-badge {{ $badgeClass }}">
                    <span class="log-dot {{ $dotClass }}"></span>
                    {{ $actionLabel }}
                </span>
            </div>
        </div>

        {{-- Logged At --}}
        <div class="log-card">
            <div class="log-label">Logged At</div>
            <div class="log-time">
                <div>{{ $record->created_at->format('M j, Y') }}</div>
                <div class="log-time-sec">{{ $record->created_at->format('H:i:s') }}</div>
            </div>
        </div>

        {{-- IP Address --}}
        <div class="log-card">
            <div class="log-label">IP Address</div>
            <span class="log-mono-box">
                {{ $record->ip_address ?? '—' }}
            </span>
        </div>

        {{-- User Agent --}}
        <div class="log-card log-agent-card">
            <div class="log-label">User Agent</div>
            <div class="log-agent-text">
                {{ $record->user_agent ?? '—' }}
            </div>
        </div>
    </div>

    {{-- Description --}}
    <div class="log-desc-card">
        <div class="log-desc-label">Description</div>
        <div class="log-desc-content">
            {{ $record->description ?? '—' }}
        </div>
    </div>
</div>
