<!DOCTYPE html>
<html lang="{{ current_language }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ user.full_name }} - {{ _('user_details') }} - iAccess Terminal</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #667eea;
            --secondary-color: #764ba2;
            --success-color: #28a745;
            --warning-color: #ffc107;
            --danger-color: #dc3545;
            --info-color: #17a2b8;
            --dark-color: #343a40;
            --light-color: #f8f9fa;
        }

        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.95) !important;
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
        }

        .navbar-brand {
            font-weight: 700;
            color: var(--primary-color) !important;
        }

        .nav-link {
            color: var(--dark-color) !important;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .nav-link:hover {
            color: var(--primary-color) !important;
            transform: translateY(-1px);
        }

        .nav-link.active {
            color: var(--primary-color) !important;
            background: rgba(102, 126, 234, 0.1) !important;
            border-radius: 8px;
        }

        .main-container {
            margin-top: 80px;
            padding: 20px 0;
        }

        .detail-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            border: none;
            overflow: hidden;
            margin-bottom: 20px;
        }

        .card-header-modern {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 20px 25px;
            border: none;
        }

        .card-header-modern h2 {
            font-size: 1.5rem;
            font-weight: 700;
            margin: 0;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .card-body-modern {
            padding: 20px;
        }

        .btn-modern {
            border-radius: 10px;
            padding: 8px 16px;
            font-weight: 600;
            font-size: 0.85rem;
            transition: all 0.3s ease;
            border: none;
            text-transform: none;
            letter-spacing: 0.5px;
        }

        .btn-modern:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .btn-primary-modern {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
        }

        .btn-secondary-modern {
            background: linear-gradient(135deg, #6c757d, #495057);
            color: white;
        }

        .back-button {
            margin-bottom: 20px;
        }

        .detail-section {
            margin-bottom: 2rem;
        }

        .detail-section h4 {
            color: var(--primary-color);
            font-weight: 700;
            margin-bottom: 1rem;
            padding-bottom: 8px;
            border-bottom: 2px solid var(--primary-color);
            font-size: 1.1rem;
        }

        .info-row {
            margin-bottom: 0.8rem;
            padding: 12px;
            background: rgba(102, 126, 234, 0.05);
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .info-row:hover {
            background: rgba(102, 126, 234, 0.1);
            transform: translateX(5px);
        }

        .info-label {
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .info-value {
            color: #666;
            font-size: 1.1rem;
        }

        .badge-access-method {
            padding: 8px 12px;
            border-radius: 15px;
            font-weight: 600;
            margin-right: 5px;
            margin-bottom: 5px;
            display: inline-block;
        }

        .device-card {
            background: rgba(255, 255, 255, 0.8);
            border-radius: 12px;
            padding: 15px;
            margin-bottom: 10px;
            border-left: 3px solid var(--primary-color);
            transition: all 0.3s ease;
        }

        .device-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }

        .profile-section {
            text-align: center;
            margin-bottom: 2rem;
        }

        .profile-image {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            border: 4px solid white;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
            margin-bottom: 10px;
        }

        .user-name {
            font-size: 1.6rem;
            font-weight: 700;
            color: var(--dark-color);
            margin-bottom: 8px;
        }

        .user-type-badge {
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.9rem;
        }

        @media (max-width: 768px) {
            .main-container {
                margin-top: 60px;
                padding: 10px;
            }
            
            .card-body-modern {
                padding: 15px;
            }
            
            .user-name {
                font-size: 1.4rem;
            }
            
            .profile-image {
                width: 80px;
                height: 80px;
            }
        }
    </style>
</head>
<body>
    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg fixed-top">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('home') }}">
                <i class="fas fa-shield-alt me-2"></i>iAccess Terminal
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('home') }}">
                            <i class="fas fa-tachometer-alt me-1"></i>{{ _('dashboard') }}
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('devices') }}">
                            <i class="fas fa-microchip me-1"></i>{{ _('devices') }}
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="{{ url_for('users') }}">
                            <i class="fas fa-users me-1"></i>{{ _('users_title') }}
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('access_logs') }}">
                            <i class="fas fa-list-alt me-1"></i>{{ _('access_logs') }}
                        </a>
                    </li>
                </ul>
                
                <ul class="navbar-nav">
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown">
                            {% if current_user and current_user.profile_image %}
                                {% if current_user.profile_image[0] == '@' %}
                                    {% set imgfile = current_user.profile_image[1:] %}
                                    <img src="{{ url_for('static', filename='img/' + imgfile) }}?v={{ static_bust }}"
                                         alt="{{ _('profile_image') }}" class="rounded-circle me-2" width="32" height="32" style="object-fit: cover;">
                                {% else %}
                                    <img src="{{ url_for('static', filename='uploads/' + current_user.profile_image) }}?v={{ static_bust }}"
                                         alt="{{ _('profile_image') }}" class="rounded-circle me-2" width="32" height="32" style="object-fit: cover;">
                                {% endif %}
                            {% else %}
                                <img src="{{ url_for('static', filename='img/default-avatar.png') }}?v={{ static_bust }}"
                                     alt="{{ _('profile_image') }}" class="rounded-circle me-2" width="32" height="32" style="object-fit: cover;">
                            {% endif %}
                            <div class="d-flex flex-column align-items-start">
                                <span>{{ user_name }}</span>
                                {% if current_user and current_user.company %}
                                  <small class="text-muted">{{ current_user.company }}</small>
                                {% endif %}
                            </div>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{{ url_for('profile') }}"><i class="fas fa-user me-2"></i>{{ _('profile') }}</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{{ url_for('logout') }}"><i class="fas fa-sign-out-alt me-2"></i>{{ _('logout') }}</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <div class="main-container">
        <div class="container">
            <!-- Back Button -->
            <div class="back-button">
                <a href="{{ url_for('users') }}" class="btn btn-secondary-modern btn-modern">
                    <i class="fas fa-arrow-left me-2"></i>{{ _('back_to_users') }}
                </a>
            </div>

            <!-- User Profile Section -->
            <div class="detail-card">
                <div class="card-body-modern">
                    <div class="profile-section">
                        {% if user.profile_image %}
                            {% if user.profile_image[0] == '@' %}
                                {% set imgfile = user.profile_image[1:] %}
                                <img src="{{ url_for('static', filename='img/' + imgfile) }}?v={{ static_bust }}"
                                     alt="{{ _('profile_image') }}" class="profile-image">
                            {% else %}
                                <img src="{{ url_for('static', filename='uploads/' + user.profile_image) }}?v={{ static_bust }}"
                                     alt="{{ _('profile_image') }}" class="profile-image">
                            {% endif %}
                        {% else %}
                            <img src="{{ url_for('static', filename='img/default-avatar.png') }}?v={{ static_bust }}"
                                 alt="{{ _('profile_image') }}" class="profile-image">
                        {% endif %}
                        
                        <div class="user-name">{{ user.full_name }}</div>
                        <span class="badge user-type-badge {{ 'bg-danger' if user.is_admin else 'bg-primary' }}">
                            {{ user.access_type }}
                        </span>
                    </div>
                </div>
            </div>

            <!-- Personal Information -->
            <div class="detail-card">
                <div class="card-header-modern">
                    <h2><i class="fas fa-user me-2"></i>{{ _('personal_info') }}</h2>
                </div>
                <div class="card-body-modern">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-id-card me-2"></i>{{ _('full_name') }}</div>
                                <div class="info-value">{{ user.full_name or '-' }}</div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-envelope me-2"></i>{{ _('email') }}</div>
                                <div class="info-value">{{ user.email or '-' }}</div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-building me-2"></i>{{ _('company') }}</div>
                                <div class="info-value">{{ user.company or '-' }}</div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-phone me-2"></i>{{ _('phone') }}</div>
                                <div class="info-value">{{ user.phone or '-' }}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Access Information -->
            <div class="detail-card">
                <div class="card-header-modern">
                    <h2><i class="fas fa-key me-2"></i>{{ _('access_info') }}</h2>
                </div>
                <div class="card-body-modern">
                    <div class="detail-section">
                        <h4><i class="fas fa-unlock-alt me-2"></i>{{ _('access_methods') }}</h4>
                        <div>
                            {% if user.access_methods == 'Hiç bir erişim yöntemi yok' %}
                                <span class="badge-access-method bg-warning text-dark">
                                    <i class="fas fa-exclamation-triangle me-1"></i>{{ user.access_methods }}
                                </span>
                            {% else %}
                                {% for method in user.access_methods.split(', ') %}
                                    {% if method.strip() == 'NFC' %}
                                        <span class="badge-access-method bg-success">
                                            <i class="fas fa-credit-card me-1"></i>{{ method.strip() }}
                                        </span>
                                    {% elif method.strip() == 'Mobil' %}
                                        <span class="badge-access-method bg-info">
                                            <i class="fas fa-mobile-alt me-1"></i>{{ method.strip() }}
                                        </span>
                                    {% else %}
                                        <span class="badge-access-method bg-secondary">
                                            {{ method.strip() }}
                                        </span>
                                    {% endif %}
                                {% endfor %}
                            {% endif %}
                        </div>
                    </div>

                    <div class="detail-section">
                        <h4><i class="fas fa-microchip me-2"></i>{{ _('authorized_devices') }}</h4>
                        {% if user.devices %}
                            {% for device in user.devices %}
                                <div class="device-card">
                                    <div class="d-flex justify-content-between align-items-center">
                                        <div>
                                            <h5 class="mb-1">
                                                <i class="fas fa-microchip me-2"></i>{{ device.name or device.id }}
                                            </h5>
                                            <small class="text-muted">Serial: {{ device.serial_number or device.id }}</small>
                                        </div>
                                        <span class="badge bg-primary">{{ _('authorized') }}</span>
                                    </div>
                                </div>
                            {% endfor %}
                        {% else %}
                            <div class="text-center py-4">
                                <i class="fas fa-exclamation-circle fa-3x text-muted mb-3"></i>
                                <p class="text-muted">{{ _('no_authorized_devices') }}</p>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>

            <!-- System Information -->
            <div class="detail-card">
                <div class="card-header-modern">
                    <h2><i class="fas fa-info-circle me-2"></i>{{ _('system_info') }}</h2>
                </div>
                <div class="card-body-modern">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-hashtag me-2"></i>{{ _('user_id') }}</div>
                                <div class="info-value">{{ user.id }}</div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-calendar-alt me-2"></i>{{ _('created_at') }}</div>
                                <div class="info-value">
                                    {% if user.created_at %}
                                        {{ user.created_at.split(' ')[0] if ' ' in user.created_at else user.created_at }}
                                    {% else %}
                                        -
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-clock me-2"></i>{{ _('last_login') }}</div>
                                <div class="info-value">
                                    {% if user.last_login %}
                                        {{ user.last_login.split('.')[0] if '.' in user.last_login else user.last_login }}
                                    {% else %}
                                        {{ _('never_logged_in') }}
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="info-row">
                                <div class="info-label"><i class="fas fa-toggle-on me-2"></i>{{ _('status') }}</div>
                                <div class="info-value">
                                    <span class="badge {{ 'bg-success' if user.is_active else 'bg-danger' }}">
                                        {{ _('active') if user.is_active else _('inactive') }}
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

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