<!-- eslint-disable vue/multi-word-component-names -->
<template>
   <div class="success-wrapper">
      <div class="success-container">
        <!-- Success Icon with Animation -->
        <div class="success-icon-container mb-6">
          <div class="success-icon-bg">
            <v-icon 
              icon="mdi-check-circle" 
              size="100" 
              class="success-icon"
            />
          </div>
          <!-- <div class="success-checkmark">
            <div class="check-icon">
              <span class="icon-line line-tip"></span>
              <span class="icon-line line-long"></span>
              <div class="icon-circle"></div>
              <div class="icon-fix"></div>
            </div>
          </div> -->
        </div>

        <!-- Success Content -->
        <div class="success-content">
          <h2 class="success-title mb-4">
            Pembayaran Berhasil
          </h2>
          
          <div class="success-message mb-8">
            <p class="message-line">Silahkan Menunggu Bukti</p>
            <p class="message-line">Pembayaran</p>
          </div>

          <!-- Payment Details Summary (Optional) -->
          <div class="payment-summary mb-8" v-if="paymentStore.patientInfo">
            <div class="summary-card">
              <div class="summary-row">
                <span class="summary-label">Pasien:</span>
                <span class="summary-value">{{ paymentStore.patientInfo.name }}</span>
              </div>
              <div class="summary-row">
                <span class="summary-label">Nominal:</span>
                <span class="summary-value amount">{{ formatCurrency(paymentStore.patientInfo.amount) }}</span>
              </div>
              <div class="summary-row">
                <span class="summary-label">Status:</span>
                <v-chip color="success" variant="flat" size="small">
                  <v-icon size="14" class="mr-1">mdi-check</v-icon>
                  Berhasil
                </v-chip>
              </div>
            </div>
          </div>

          <!-- Action Button -->
          <div class="action-section">
            <v-btn 
              color="primary" 
              size="x-large" 
              variant="flat" 
              rounded="xl"
              class="success-btn"
              @click="paymentStore.reset"
            >
              <v-icon class="mr-2">mdi-home</v-icon>
              Kembali ke Awal
            </v-btn>
          </div>
        </div>
      </div>
    </div>
</template>

<script setup>
import { usePaymentStore } from '~/stores/payment';

const paymentStore = usePaymentStore();

const formatCurrency = (amount) => {
  return new Intl.NumberFormat('id-ID', {
    style: 'currency',
    currency: 'IDR',
    minimumFractionDigits: 0
  }).format(amount);
};
</script>

<style scoped>
.payment-step {
  background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%);
  min-height: 100vh;
  height: auto;
  padding: 1rem;
  display: flex;
  margin: 80px;
  align-items: center;
  justify-content: center;
}

.success-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 0;
  padding: 0rem;
}

.success-container {
  background: rgb(255, 255, 255);
  border-radius: 24px;
  padding: 0.5rem 0.5rem;
  text-align: center;
  /* backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8); */
}

/* Success Icon Animation */
.success-icon-container {
  position: relative;
  display: inline-block;
}

.success-icon-bg {
  position: relative;
  display: inline-block;
  animation: successPulse 2s ease-in-out infinite;
}

.success-icon {
  color: #4caf50 !important;
  filter: drop-shadow(0 4px 20px rgba(76, 175, 80, 0.3));
}

@keyframes successPulse {
  0%, 100% { 
    transform: scale(1); 
    opacity: 1; 
  }
  50% { 
    transform: scale(1.05); 
    opacity: 0.9; 
  }
}

/* Animated Checkmark */
.success-checkmark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.check-icon {
  width: 50px;
  height: 50px;
  position: relative;
  border-radius: 50%;
  box-sizing: content-box;
  border: 3px solid #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

.icon-line {
  height: 3px;
  background-color: #4caf50;
  display: block;
  border-radius: 2px;
  position: absolute;
  z-index: 10;
}

.icon-line.line-tip {
  top: 23px;
  left: 8px;
  width: 15px;
  transform: rotate(45deg);
  animation: checkTip 0.75s ease-in-out 1s both;
}

.icon-line.line-long {
  top: 18px;
  right: 8px;
  width: 25px;
  transform: rotate(-45deg);
  animation: checkLong 0.75s ease-in-out 1.2s both;
}

@keyframes checkTip {
  0% { width: 0; left: 1px; top: 19px; }
  54% { width: 0; left: 1px; top: 19px; }
  70% { width: 15px; left: -2px; top: 37px; }
  84% { width: 17px; left: 8px; top: 23px; }
  100% { width: 15px; left: 8px; top: 23px; }
}

@keyframes checkLong {
  0% { width: 0; right: 46px; top: 54px; }
  65% { width: 0; right: 46px; top: 54px; }
  84% { width: 25px; right: 0px; top: 17px; }
  100% { width: 25px; right: 8px; top: 18px; }
}

/* Success Content */
.success-content {
  position: relative;
  z-index: 2;
}

.success-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1a1a1a;
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.success-message {
  color: #666;
  font-size: 1rem;
  font-weight: 500;
  line-height: 2;
}

.message-line {
  margin: 0;
  padding: 0.25rem 0;
}

/* Payment Summary */
.payment-summary {
  margin: 1rem 0;
}

.summary-card {
  background: rgba(76, 175, 80, 0.06);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid rgba(76, 175, 80, 0.2);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  color: #666;
  font-weight: 600;
  font-size: 0.95rem;
}

.summary-value {
  color: #1a1a1a;
  font-weight: 700;
  font-size: 1rem;
}

.summary-value.amount {
  color: #4caf50;
  font-size: 1.1rem;
}

/* Action Button */
.action-section {
  margin-top: 2rem;
}

.success-btn {
  background: linear-gradient(135deg, #ff9248 0%, #ff7043 100%) !important;
  color: white !important;
  font-weight: 700 !important;
  font-size: 1.1rem !important;
  text-transform: none !important;
  padding: 0 3rem !important;
  min-width: 200px;
  box-shadow: 
    0 8px 25px rgba(255, 146, 72, 0.3),
    0 4px 15px rgba(255, 146, 72, 0.2) !important;
  transition: all 0.3s ease !important;
}

.success-btn:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 12px 35px rgba(255, 146, 72, 0.4),
    0 8px 25px rgba(255, 146, 72, 0.3) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .payment-step {
    padding: 1rem 0;
  }
  
  .success-wrapper {
    padding: 0 0.5rem;
  }
  
  .success-container {
    padding: 2rem 1.5rem;
  }
  
  .success-title {
    font-size: 2rem;
  }
  
  .success-message {
    font-size: 1.1rem;
  }
  
  .success-icon {
    font-size: 80px !important;
  }
}

@media (max-width: 480px) {
  .success-container {
    padding: 2rem 1rem;
  }
  
  .success-title {
    font-size: 1.8rem;
  }
  
  .success-message {
    font-size: 1rem;
  }
  
  .success-btn {
    min-width: 100%;
    margin-top: 1rem;
  }
}

/* Landscape Tablet */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 600px) {
  .payment-step {
    padding: 1rem 0;
  }
  
  .success-container {
    padding: 2rem;
    max-width: 500px;
    margin: 0 auto;
  }
  
  .success-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }
  
  .success-message {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .payment-summary {
    margin: 1rem 0;
  }
  
  .success-icon {
    font-size: 70px !important;
  }
}
</style>