{% macro render_user_welcome(user_email, greeting="Welcome back", show_time=true) %}
{#
  User Welcome Card Macro
  Renders a personalized welcome message with user info

  Args:
    user_email: The user's email (from user://current/email.email)
    greeting: Custom greeting text
    show_time: Whether to show current time
#}

{% set username = user_email.split('@')[0] if user_email else 'User' %}
{% set domain = user_email.split('@')[1] if user_email and '@' in user_email else '' %}

<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 500px; margin: 0 auto;">

  <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 24px; border-radius: 16px; color: white; box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);">

    <div style="font-size: 14px; opacity: 0.9; margin-bottom: 8px;">
      {{ greeting }}
    </div>

    <div style="font-size: 28px; font-weight: 700; margin-bottom: 16px;">
      {{ username | title }}
    </div>

    <div style="display: flex; gap: 20px; font-size: 13px;">
      <div>
        <div style="opacity: 0.7;">Email</div>
        <div style="font-weight: 600;">{{ user_email }}</div>
      </div>
      {% if domain %}
      <div>
        <div style="opacity: 0.7;">Organization</div>
        <div style="font-weight: 600;">{{ domain | replace('.com', '') | title }}</div>
      </div>
      {% endif %}
    </div>

    {% if show_time %}
    <div style="margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.2); font-size: 12px; opacity: 0.8;">
      Session active
    </div>
    {% endif %}

  </div>

</div>
{% endmacro %}

{#
MACRO USAGE EXAMPLE:
{{ render_user_welcome(user://current/email.email, 'Good morning', true) }}
#}
