<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ _('json_logs') }} - iAccess Terminal</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .navbar {
            background: rgba(255, 255, 255, 0.1) !important;
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .navbar-brand {
            color: white !important;
            font-weight: bold;
        }
        
        .nav-link {
            color: rgba(255, 255, 255, 0.9) !important;
            transition: color 0.3s ease;
        }
        
        .nav-link:hover {
            color: white !important;
        }
        
        .main-container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            margin: 20px;
            padding: 30px;
        }
        
        .page-title {
            color: #2c3e50;
            font-weight: 700;
            margin-bottom: 30px;
            text-align: center;
        }
        
        .json-card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .json-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }
        
        .json-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .json-type {
            background: rgba(255, 255, 255, 0.2);
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 0.9em;
            font-weight: 600;
        }
        
        .json-time {
            font-size: 0.85em;
            opacity: 0.9;
        }
        
        .json-content {
            padding: 20px;
            background: #f8f9fa;
            border-left: 4px solid #667eea;
        }
        
        .json-data {
            background: #2d3748;
            color: #e2e8f0;
            padding: 15px;
            border-radius: 8px;
            font-family: 'Courier New', monospace;
            font-size: 0.9em;
            line-height: 1.5;
            overflow-x: auto;
            white-space: pre-wrap;
            word-break: break-word;
        }
        
        .json-source {
            margin-top: 10px;
            font-size: 0.85em;
            color: #6c757d;
        }
        
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #6c757d;
        }
        
        .empty-state i {
            font-size: 4em;
            margin-bottom: 20px;
            opacity: 0.5;
        }
        
        .btn-modern {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            color: white;
            padding: 10px 20px;
            border-radius: 25px;
            font-weight: 600;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
        }
        
        .btn-modern:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
            color: white;
        }
        
        .stats-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 15px;
            margin-bottom: 30px;
            text-align: center;
        }
        
        .stats-number {
            font-size: 2.5em;
            font-weight: bold;
            margin-bottom: 10px;
        }
        
        .stats-label {
            font-size: 1.1em;
            opacity: 0.9;
        }
    </style>
</head>
<body>
    <!-- Navbar -->
    <nav class="navbar navbar-expand-lg">
        <div class="container-fluid">
            <a class="navbar-brand" href="{{ url_for('home') }}">
                <img src="{{ url_for('static', filename='img/monicont_logo.png') }}" alt="Monicont" height="40" style="margin-right: 10px;">
                iAccess Terminal
            </a>
            <div class="navbar-nav ms-auto">
                <a class="nav-link" href="{{ url_for('home') }}">
                    <i class="fas fa-home me-1"></i>{{ _('access_logs') }}
                </a>
                <a class="nav-link" href="{{ url_for('devices') }}">
                    <i class="fas fa-microchip me-1"></i>{{ _('devices') }}
                </a>
                <a class="nav-link active" href="{{ url_for('json_logs') }}">
                    <i class="fas fa-code me-1"></i>{{ _('json_logs') }}
                </a>
                <a class="nav-link" href="{{ url_for('device_info') }}">
                    <i class="fas fa-info-circle me-1"></i>{{ _('device_info') }}
                </a>
                {% if is_admin %}
                <a class="nav-link" href="{{ url_for('users') }}">
                    <i class="fas fa-users me-1"></i>{{ _('users') }}
                </a>
                {% endif %}
                <a class="nav-link" href="{{ url_for('logout') }}">
                    <i class="fas fa-sign-out-alt me-1"></i>{{ _('logout') }}
                </a>
            </div>
        </div>
    </nav>

    <div class="main-container">
        <h1 class="page-title">
            <i class="fas fa-code me-2"></i>{{ _('json_logs') }}
        </h1>
        
        <!-- İstatistikler -->
        <div class="row">
            <div class="col-md-4">
                <div class="stats-card">
                    <div class="stats-number">{{ json_logs|length }}</div>
                    <div class="stats-label">{{ _('total_logs') }}</div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="stats-card">
                    <div class="stats-number">{{ json_logs|selectattr('data_type', 'equalto', 'device_data')|list|length }}</div>
                    <div class="stats-label">{{ _('device_data') }}</div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="stats-card">
                    <div class="stats-number">{{ json_logs|selectattr('data_type', 'equalto', 'sensor_data')|list|length }}</div>
                    <div class="stats-label">{{ _('sensor_data') }}</div>
                </div>
            </div>
        </div>

        {% if json_logs %}
            {% for log in json_logs %}
            <div class="json-card">
                <div class="json-header">
                    <div>
                        <span class="json-type">{{ log['data_type'] }}</span>
                        <span class="json-time ms-3">
                            <i class="fas fa-clock me-1"></i>{{ log['received_at'] }}
                        </span>
                    </div>
                    <div class="json-source">
                        <i class="fas fa-network-wired me-1"></i>{{ log['source_ip'] }}
                    </div>
                </div>
                <div class="json-content">
                    <div class="json-data">{{ log['json_data'] }}</div>
                </div>
            </div>
            {% endfor %}
        {% else %}
            <div class="empty-state">
                <i class="fas fa-inbox"></i>
                <h3>{{ _('no_json_logs') }}</h3>
                <p>{{ _('no_json_logs_description') }}</p>
                <a href="{{ url_for('devices') }}" class="btn-modern">
                    <i class="fas fa-microchip me-1"></i>{{ _('go_to_devices') }}
                </a>
            </div>
        {% endif %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 