{# Expert in Residence Card - Simplified Version #}
{% set expertData = expert.expertMetadata %}
{# Set language for all fields #}
{% if language is defined %}
{% set lang = language %}
{% else %}
{% set lang = app.request.locale|default('de') %}
{% endif %}
{% if lang not in ['de', 'en'] %}{% set lang = 'de' %}{% endif %}
<div class="expert-card premium">
{# Edit Icon for Admins/Masters #}
{% if is_granted('ROLE_ADMIN') or is_granted('ROLE_MASTER') %}
<a href="{{ path('admin_mentors_edit', {'category': 'experts', 'id': expert.id}) }}"
class="edit-corner-link"
title="Bearbeiten"
aria-label="Expert bearbeiten">
<i class="fas fa-edit"></i>
</a>
{% endif %}
{# SP-Connect Rocket Icon (replaces LinkedIn icon for conversion strategy) #}
<a href="{{ path('connect_mentor_show', {'id': expert.id}) }}"
target="_blank"
rel="noopener noreferrer"
class="sp-connect-corner-link"
aria-label="{{ lang == 'de' ? 'SP-Connect Profil von' : 'SP-Connect Profile of' }} {{ expert.firstName }} {{ expert.lastName }}"
title="{{ lang == 'de' ? 'SP-Connect Profil ansehen' : 'View SP-Connect Profile' }}">
<i class="fas fa-rocket sp-connect-corner-icon"></i>
</a>
<div class="expert-header">
<div class="expert-image-container">
<img src="{{ expert.profileImage|default('https://res.cloudinary.com/startplatz/image/upload/v1637360496/Wordpress/Sprechstunden/Sprechstunden_Platzhalter.jpg') }}"
alt="{{ expert.firstName }} {{ expert.lastName }}"
class="expert-image">
<div class="expert-badge">Expert in Residence</div>
</div>
</div>
<div class="expert-content">
<h2 class="expert-name">{{ expert.firstName }} {{ expert.lastName }}</h2>
{# Main Focus - NEW SIMPLIFIED FIELD with fallback to old title #}
{% set mainFocusField = 'mainFocus_' ~ lang %}
{% set mainFocus = attribute(expertData, mainFocusField) is defined ? attribute(expertData, mainFocusField) : null %}
{% if not mainFocus %}
{# Fallback to old title fields #}
{% set titleField = 'title_' ~ lang %}
{% set mainFocus = attribute(expertData, titleField) is defined ? attribute(expertData, titleField) : expertData.title|default('') %}
{% endif %}
{% if mainFocus %}
<p class="expert-title text-primary font-weight-bold mb-2">{{ mainFocus }}</p>
{% endif %}
{# Expert Bio - NEW SIMPLIFIED FIELD with fallback #}
{% set bioField = 'expertBio_' ~ lang %}
{% set expertBio = attribute(expertData, bioField) is defined ? attribute(expertData, bioField) : null %}
{% if not expertBio %}
{# Fallback to description #}
{% set expertBio = expert.description|default('') %}
{% endif %}
<div class="expert-bio text-muted small mb-3">
{% if expertBio %}
{{ expertBio|striptags|slice(0, 160) }}{% if expertBio|striptags|length > 160 %}...{% endif %}
{% else %}
<em class="text-muted">{{ lang == 'de' ? 'Profil in Bearbeitung' : 'Profile under construction' }}</em>
{% endif %}
</div>
{# Ask me about - NEW SIMPLIFIED FIELD with fallback #}
{% set askMeField = 'askMeAbout_' ~ lang %}
{% set askMeAbout = attribute(expertData, askMeField) is defined ? attribute(expertData, askMeField) : null %}
{% if not askMeAbout and expertData.expertFeatures is defined and expertData.expertFeatures.askMeAbout is defined %}
{# Fallback to old expertFeatures #}
{% set askMeAbout = expertData.expertFeatures.askMeAbout[lang]|default('') %}
{% endif %}
{% if not askMeAbout %}
{# Fallback to first 3 expertise areas #}
{% set expertiseField = 'expertiseAreas_' ~ lang %}
{% if attribute(expertData, expertiseField) is defined %}
{% set areas = attribute(expertData, expertiseField) %}
{% if areas is iterable %}
{% set askMeAbout = areas|slice(0,3)|join(', ') %}
{% endif %}
{% elseif expertData.expertiseAreas is defined %}
{% set areas = expertData.expertiseAreas is iterable ? expertData.expertiseAreas : expertData.expertiseAreas|split(',') %}
{% set askMeAbout = areas|slice(0,3)|join(', ') %}
{% endif %}
{% endif %}
{% if askMeAbout %}
<div class="expert-feature mb-2">
<strong class="text-muted small">{{ lang == 'de' ? 'Frag mich zu:' : 'Ask me about:' }}</strong><br>
<span class="text-dark">{{ askMeAbout }}</span>
</div>
{% endif %}
{# Connect Modes with Icons #}
{% set connectModes = expertData.connectModes ?? ['community'] %}
{% set modeIcons = {
'residency': '☕',
'meetup': '🎯',
'ama-session': '💬',
'accelerator-events': '🎪',
'community': '💻'
} %}
{% set modeLabels = {
'residency': {'de': 'Kaffeemaschine / Coworking', 'en': 'Coffee Machine / Coworking'},
'meetup': {'de': 'Meetups & Events', 'en': 'Meetups & Events'},
'ama-session': {'de': 'AMA-Sessions', 'en': 'AMA Sessions'},
'accelerator-events': {'de': 'Accelerator-Events', 'en': 'Accelerator Events'},
'community': {'de': 'Digitale Community', 'en': 'Digital Community'}
} %}
{% if connectModes is not empty %}
<div class="expert-feature mb-3">
<strong class="text-muted small">{{ lang == 'de' ? 'Triff mich bei:' : 'Meet me at:' }}</strong>
<div style="margin-top: 6px;">
{% for mode in connectModes %}
{% if modeLabels[mode] is defined %}
<div class="d-flex align-items-center mb-1" style="gap: 8px;">
<span style="font-size: 16px;">{{ modeIcons[mode] }}</span>
<span class="text-dark" style="font-size: 13px;">{{ modeLabels[mode][lang] }}</span>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>