doctype html
html(lang="it")
  head
    meta(charset="UTF-8")
    meta(name="viewport" content="width=device-width, initial-scale=1.0")
    style(type="text/css").
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      
      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        background-color: #f5f5f5;
        padding: 20px;
        line-height: 1.6;
      }
      
      .header-logo {
        width: 120px;
        height: auto;
        margin-bottom: 16px;
        display: block;
        margin-left: auto;
        margin-right: auto;
      }
      
      .email-container {
        max-width: 600px;
        margin: 0 auto;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
        overflow: hidden;
      }
      
      .email-header {
        background: linear-gradient(135deg, #7cb342 0%, #558b2f 100%);
        color: white;
        padding: 40px 24px;
        text-align: center;
      }
      
      .email-header h1 {
        margin: 0 0 8px 0;
        font-size: 26px;
        font-weight: 600;
        line-height: 1.3;
      }
      
      .email-header .subtitle {
        margin: 8px 0 0 0;
        font-size: 17px;
        opacity: 0.95;
        font-style: italic;
      }
      
      .alert-icon {
        font-size: 56px;
        margin-bottom: 12px;
      }
      
      .email-body {
        padding: 32px 24px;
      }
      
      .intro-text {
        font-size: 16px;
        color: #333;
        margin-bottom: 20px;
        text-align: center;
        line-height: 1.7;
      }
      
      .request-card {
        background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
        border: 2px solid #2196f3;
        border-radius: 8px;
        padding: 24px;
        margin: 20px 0;
        text-align: center;
      }
      
      .request-card h3 {
        font-size: 14px;
        text-transform: uppercase;
        color: #2196f3;
        margin-bottom: 12px;
        letter-spacing: 0.5px;
        font-weight: 600;
      }
      
      .request-card .member-name {
        font-size: 28px;
        color: #1a1a1a;
        font-weight: 700;
        margin-bottom: 8px;
      }
      
      .request-card .member-detail {
        font-size: 15px;
        color: #555;
        margin: 6px 0;
      }
      
      .request-card .member-detail strong {
        color: #2196f3;
      }
      
      .territory-badge {
        background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
        color: white;
        display: inline-block;
        padding: 8px 20px;
        border-radius: 20px;
        font-size: 16px;
        font-weight: 600;
        margin-top: 12px;
      }
      
      .question-box {
        background: #e1f5fe;
        border-left: 4px solid #2196f3;
        border-radius: 8px;
        padding: 20px;
        margin: 24px 0;
        text-align: center;
      }
      
      .question-box p {
        font-size: 20px;
        color: #1a1a1a;
        font-weight: 600;
        margin: 0;
        line-height: 1.4;
      }
      
      .cta-section {
        text-align: center;
        margin: 32px 0;
        padding: 24px 0;
        border-top: 2px solid #e0e0e0;
        border-bottom: 2px solid #e0e0e0;
      }
      
      .cta-title {
        font-size: 18px;
        font-weight: 600;
        color: #1a1a1a;
        margin-bottom: 20px;
      }
      
      .cta-button {
        display: inline-block;
        padding: 18px 56px;
        font-size: 20px;
        font-weight: 700;
        color: white;
        background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
        border-radius: 50px;
        text-decoration: none;
        box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
        transition: all 0.3s ease;
      }
      
      .button-icon {
        font-size: 20px;
        margin-right: 10px;
        vertical-align: middle;
      }
      
      .info-box {
        background: #e8f5e9;
        border-radius: 8px;
        padding: 16px;
        margin: 20px 0;
      }
      
      .info-box p {
        margin: 0 0 8px 0;
        color: #2e7d32;
        font-size: 15px;
        line-height: 1.6;
      }
      
      .info-box p:last-child {
        margin-bottom: 0;
      }
      
      .responsibility-box {
        background: #f8f9fa;
        border-radius: 8px;
        padding: 20px;
        margin: 20px 0;
      }
      
      .responsibility-box h3 {
        font-size: 17px;
        color: #1a1a1a;
        margin-bottom: 12px;
        text-align: center;
        font-weight: 600;
      }
      
      .responsibility-item {
        display: flex;
        align-items: flex-start;
        margin-bottom: 10px;
        padding: 6px 0;
      }
      
      .responsibility-icon {
        font-size: 20px;
        margin-right: 10px;
        min-width: 24px;
        flex-shrink: 0;
      }
      
      .responsibility-text {
        font-size: 15px;
        color: #555;
        line-height: 1.5;
      }
      
      .email-footer {
        padding: 20px;
        text-align: center;
        background: #f8f9fa;
        color: #777;
        font-size: 13px;
      }
      
      .email-footer p {
        margin: 4px 0;
      }
      
      .divider {
        height: 1px;
        background: linear-gradient(to right, transparent, #e0e0e0, transparent);
        margin: 20px 0;
      }
      
      @media only screen and (max-width: 600px) {
        body {
          padding: 10px;
        }
        
        .email-header {
          padding: 24px 16px;
        }
        
        .email-header h1 {
          font-size: 22px;
        }
        
        .alert-icon {
          font-size: 48px;
        }
        
        .email-body {
          padding: 20px 16px;
        }
        
        .request-card .member-name {
          font-size: 24px;
        }
        
        .territory-badge {
          font-size: 14px;
          padding: 6px 16px;
        }
        
        .question-box p {
          font-size: 18px;
        }
        
        .cta-button {
          padding: 16px 40px;
          font-size: 18px;
          width: 100%;
          max-width: 300px;
        }
        
        .responsibility-item {
          font-size: 14px;
        }
      }

  body
    .email-container
      //- Header
      .email-header
        img.header-logo(src=baseurl+'/images/logo.png' alt=nomeapp)
        h1 🎯 Richiesta Abilitazione #{nomeTerritorio}
        p.subtitle Nuovo membro in attesa di attivazione

      //- Body
      .email-body
        //- Intro
        .intro-text
          | Ciao <strong>#{nomeFacilitatore}</strong>,<br>
          | un nuovo membro richiede l'abilitazione alla fiducia al Circuito del tuo territorio!

        //- Card richiesta
        .request-card
          h3 👤 Richiesta Ingresso Circuito
          .member-name #{usernameMembro}
          if nomeMembro
            if cognomeMembro
              .member-detail
                strong Nome: 
                | #{nomeMembro} #{cognomeMembro}
            else
              .member-detail
                strong Nome: 
                | #{nomeMembro}
          if emailMembro
            .member-detail
              strong Email: 
              | #{emailMembro}
          if telegramMembro
            .member-detail
              strong Telegram: 
              a(href=`https://t.me/${telegramMembro}` target="_blank" style="color: #2196f3; text-decoration: none;") @#{telegramMembro}
          if comuneResidenza
            .member-detail
              strong Comune: 
              | #{comuneResidenza} (#{provinciaResidenza})

          .territory-badge 📍 #{nomeTerritorio}

          if usernameInvitante
            .divider(style="margin: 20px auto; width: 80%;")
            h3(style="font-size: 14px; text-transform: uppercase; color: #2196f3; margin-bottom: 12px;") 👥 Invitato da
            .member-detail
              strong Invitante: 
              | #{usernameInvitante}
            if nomeInvitante
              if cognomeInvitante
                .member-detail
                  strong Nome: 
                  | #{nomeInvitante} #{cognomeInvitante}
              else
                .member-detail
                  strong Nome: 
                  | #{nomeInvitante}
            if telegramInvitante
              .member-detail
                strong Telegram: 
                a(href=`https://t.me/${telegramInvitante}` target="_blank" style="color: #2196f3; text-decoration: none;") @#{telegramInvitante}

        //- CTA principale
        .cta-section
          a.cta-button(href=linkAbilitazione target="_blank") 
            span.button-icon ✓
            | Abilita fiducia

          .divider(style="margin: 24px 0;")
          p(style="font-size: 16px; color: #666; margin-bottom: 16px;") Visualizza i profili
          .button-group(style="display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;")
            a.secondary-button(href=linkProfiloMembro target="_blank" style="display: inline-block; padding: 12px 24px; font-size: 16px; font-weight: 600; color: #2196f3; background: white; border: 2px solid #2196f3; border-radius: 25px; text-decoration: none; transition: all 0.3s ease;")
              span(style="margin-right: 6px;") 👤
              | Profilo Membro
            if linkProfiloInvitante
              a.secondary-button(href=linkProfiloInvitante target="_blank" style="display: inline-block; padding: 12px 24px; font-size: 16px; font-weight: 600; color: #7cb342; background: white; border: 2px solid #7cb342; border-radius: 25px; text-decoration: none; transition: all 0.3s ease;")
                span(style="margin-right: 6px;") 👥
                | Profilo Invitante

        //- Responsabilità
        .responsibility-box
          h3 📋 Compiti del Facilitatore RISO
          .responsibility-item
            span.responsibility-icon 🔍
            span.responsibility-text
              strong Verifica: 
              | Contatta il membro, se non lo conosci, oppure il suo invitante: #{usernameInvitante}
          .responsibility-item
            span.responsibility-icon 🌍
            span.responsibility-text
              strong Territorio: 
              | Assicurati che il membro appartenga effettivamente al territorio di competenza
          .responsibility-item
            span.responsibility-icon 👥
            span.responsibility-text
              strong Integrazione: 
              | Supporta il nuovo membro nell'attivazione e utilizzo del Circuito locale

        //- Info box
        .info-box
          p
            | ✓ Dopo l'abilitazione, #{usernameMembro} potrà accedere al #{nomeTerritorio}
          p
            | ✓ Il membro riceverà una notifica automatica dell'avvenuta attivazione

      //- Footer
      .email-footer
        .divider
        p Hai ricevuto questa email in qualità di Facilitatore RISO per #{nomeTerritorio}
        p(style="margin-top: 12px; font-size: 12px;")
          | #{new Date().getFullYear()} #{nomeapp}