<template>
  <div class="home-container">
    <div class="welcome-section">
      <div class="welcome-card card">
        <div class="card-header">
          <h2 class="card-title">{{ $t('home.welcome') }}</h2>
        </div>
        <div class="card-body">
          <div v-if="!isAuthenticated" class="marketing">
            <section class="hero">
              <h1 class="hero-title">{{ $t('home.heroTitle') }}</h1>
              <p class="hero-subtitle">
                {{ $t('home.heroSubtitle') }}
              </p>
              <div class="auth-actions">
                <router-link to="/register" class="btn-primary">
                  <span class="btn-icon">🚀</span>
                  {{ $t('home.startFree') }}
                </router-link>
                <router-link to="/login" class="btn-secondary">
                  <span class="btn-icon">🔐</span>
                  {{ $t('navigation.login') }}
                </router-link>
              </div>
              <ul class="hero-bullets">
                <li>✔️ {{ $t('home.heroFeatures.memberManagement') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.trainingGroups') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.trainingDiary') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.tournaments') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.teamManagement') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.myTischtennis') }}</li>
                <li>✔️ {{ $t('home.heroFeatures.statistics') }}</li>
                <li>✔️ {{ $t('home.rolesAndPrivacy') }}</li>
              </ul>
            </section>

            <section class="features-section">
              <h3 class="section-title">{{ $t('home.whatCanYouDo') }}</h3>
              <div class="features-grid">
                <div class="feature-card card">
                  <div class="feature-icon">👥</div>
                  <h4 class="feature-title">{{ $t('home.features.manageMembers') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.manageMembersDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">📝</div>
                  <h4 class="feature-title">{{ $t('home.features.keepDiary') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.keepDiaryDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">📅</div>
                  <h4 class="feature-title">{{ $t('home.features.organizeSchedules') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.organizeSchedulesDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">📊</div>
                  <h4 class="feature-title">{{ $t('home.features.statistics') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.statisticsDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">🔒</div>
                  <h4 class="feature-title">{{ $t('home.features.security') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.securityDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">⚙️</div>
                  <h4 class="feature-title">{{ $t('home.features.predefinedActivities') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.predefinedActivitiesDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">👥</div>
                  <h4 class="feature-title">{{ $t('home.features.trainingGroups') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.trainingGroupsDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">🏅</div>
                  <h4 class="feature-title">{{ $t('home.features.officialTournaments') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.officialTournamentsDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">👔</div>
                  <h4 class="feature-title">{{ $t('home.features.teamManagement') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.teamManagementDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">🔗</div>
                  <h4 class="feature-title">{{ $t('home.features.myTischtennisIntegration') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.myTischtennisIntegrationDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">📄</div>
                  <h4 class="feature-title">{{ $t('home.features.pdfExport') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.pdfExportDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">🔐</div>
                  <h4 class="feature-title">{{ $t('home.features.permissionSystem') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.permissionSystemDesc') }}
                  </p>
                </div>

                <div class="feature-card card">
                  <div class="feature-icon">📋</div>
                  <h4 class="feature-title">{{ $t('home.features.activityLog') }}</h4>
                  <p class="feature-description">
                    {{ $t('home.features.activityLogDesc') }}
                  </p>
                </div>
              </div>
            </section>

            <section class="how-it-works">
              <h3 class="section-title">{{ $t('home.howItWorks') }}</h3>
              <div class="steps">
                <div class="step">
                  <div class="step-number">1</div>
                  <h4 class="step-title">{{ $t('home.step1.title') }}</h4>
                  <p>{{ $t('home.step1.description') }}</p>
                </div>
                <div class="step">
                  <div class="step-number">2</div>
                  <h4 class="step-title">{{ $t('home.step2.title') }}</h4>
                  <p>{{ $t('home.step2.description') }}</p>
                </div>
                <div class="step">
                  <div class="step-number">3</div>
                  <h4 class="step-title">{{ $t('home.step3.title') }}</h4>
                  <p>{{ $t('home.step3.description') }}</p>
                </div>
              </div>
            </section>

            <section class="seo-copy">
              <h3 class="section-title">{{ $t('home.forWhom') }}</h3>
              <p class="long-text">
                {{ $t('home.forWhomText') }}
              </p>
            </section>

            <section class="faq">
              <h3 class="section-title">{{ $t('home.faq') }}</h3>
              <details>
                <summary>{{ $t('home.faqFree.question') }}</summary>
                <p>{{ $t('home.faqFree.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqPrivacy.question') }}</summary>
                <p>{{ $t('home.faqPrivacy.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqInstallation.question') }}</summary>
                <p>{{ $t('home.faqInstallation.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqTournaments.question') }}</summary>
                <p>{{ $t('home.faqTournaments.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqMyTischtennis.question') }}</summary>
                <p>{{ $t('home.faqMyTischtennis.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqTrainingGroups.question') }}</summary>
                <p>{{ $t('home.faqTrainingGroups.answer') }}</p>
              </details>
              <details>
                <summary>{{ $t('home.faqPermissions.question') }}</summary>
                <p>{{ $t('home.faqPermissions.answer') }}</p>
              </details>
            </section>

            <div class="cta-bottom">
              <router-link to="/register" class="btn-primary">
                <span class="btn-icon">✅</span>
                {{ $t('home.registerNow') }}
              </router-link>
              <router-link to="/login" class="btn-secondary">
                <span class="btn-icon">🔐</span>
                {{ $t('home.haveAccount') }}
              </router-link>
            </div>
          </div>

          <div v-else class="user-welcome">
            <div class="user-avatar">
              <span class="avatar-icon">👋</span>
            </div>
            <p class="welcome-text">
              {{ $t('home.welcomeBack') }}
            </p>
            <div class="user-actions">
              <button @click="logout" class="btn-secondary">
                <span class="btn-icon">🚪</span>
                {{ $t('navigation.logout') }}
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div v-if="isAuthenticated" class="features-section">
      <h3 class="section-title">{{ $t('home.whatCanYouDo') }}</h3>
      <div class="features-grid">
        <div class="feature-card card">
          <div class="feature-icon">👥</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.manageMembers') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.manageMembersDesc') }}
          </p>
        </div>
        
        <div class="feature-card card">
          <div class="feature-icon">📝</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.keepDiary') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.keepDiaryDesc') }}
          </p>
        </div>
        
        <div class="feature-card card">
          <div class="feature-icon">👥</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.trainingGroups') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.trainingGroupsDesc') }}
          </p>
        </div>
        
        <div class="feature-card card">
          <div class="feature-icon">🏆</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.manageTournaments') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.manageTournamentsDesc') }}
          </p>
        </div>

        <div class="feature-card card">
          <div class="feature-icon">👔</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.teamManagement') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.teamManagementDesc') }}
          </p>
        </div>

        <div class="feature-card card">
          <div class="feature-icon">🔗</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.myTischtennisIntegration') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.myTischtennisIntegrationDesc') }}
          </p>
        </div>

        <div class="feature-card card">
          <div class="feature-icon">📊</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.statistics') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.statisticsDesc') }}
          </p>
        </div>

        <div class="feature-card card">
          <div class="feature-icon">📄</div>
          <h4 class="feature-title">{{ $t('home.authenticatedFeatures.pdfExport') }}</h4>
          <p class="feature-description">
            {{ $t('home.authenticatedFeatures.pdfExportDesc') }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';

export default {
  name: 'Home',
  computed: {
    ...mapGetters(['isAuthenticated']),
  },
  methods: {
    ...mapActions(['logout']),
  },
};
</script>

<style scoped>
.home-container {
  max-width: 1200px;
  margin: 0 auto;
}

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

.welcome-card {
  text-align: center;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.05), rgba(160, 112, 64, 0.05));
  border: 1px solid rgba(76, 175, 80, 0.2);
}

.card-title {
  color: var(--primary-color);
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.auth-message, .user-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.marketing {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  text-align: left;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hero-title {
  font-size: 1.875rem;
  line-height: 1.3;
  text-align: center;
  margin: 0.25rem 0 0.25rem 0;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 780px;
  text-align: center;
  margin: 0;
}

.hero-bullets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0 0;
  color: var(--text-secondary);
}

.message-text, .welcome-text {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 600px;
  margin: 0;
}

.auth-actions, .user-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.user-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.avatar-icon {
  font-size: 2rem;
}

.btn-icon {
  margin-right: 0.375rem;
  font-size: 1rem;
}

/* Features Section */
.features-section {
  margin-top: 3rem;
}

.section-title {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 600;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.feature-card {
  text-align: center;
  padding: 1.5rem 1.25rem;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.feature-card:hover::before {
  transform: scaleX(1);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-heavy);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

.feature-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.feature-description {
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  font-size: 0.9rem;
}

/* How it works */
.how-it-works .steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.step {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  background: white;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.step-title {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
}

.seo-copy .long-text {
  max-width: 900px;
  margin: 0 auto;
  color: var(--text-secondary);
}

.faq details {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.cta-bottom {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  .home-container {
    padding: 0 0.75rem;
  }
  
  .welcome-card {
    margin: 0 0.375rem;
  }
  
  .card-title {
    font-size: 1.5rem;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  
  .feature-card {
    padding: 1.25rem 1rem;
  }
  
  .auth-actions, .user-actions {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }
  
  .btn-primary, .btn-secondary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .card-title {
    font-size: 1.375rem;
  }
  
  .section-title {
    font-size: 1.375rem;
  }
  
  .feature-icon {
    font-size: 2.25rem;
  }
  
  .user-avatar {
    width: 56px;
    height: 56px;
  }
  
  .avatar-icon {
    font-size: 1.75rem;
  }
}
</style>
