<script setup lang="ts">
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { formatNumber } from "@/utils/common";
import type { ThemeColors } from "@/config/themes";

interface Props {
  colors: ThemeColors;
  phone: string;
  payDate: string;
  invoiceNumber: string;
  domainName: string;
  totalPoint: number;
}

const props = defineProps<Props>();
const emit = defineEmits<{ (e: "submit"): void }>();
const { t } = useI18n();

const resolvedDomainName = computed(() => props.domainName || "HKT");

const next = () => {
  emit("submit");
};
</script>

<template>
  <div class="pt2-page">

    <!-- Page title -->
    <h2 class="pt2-page-title">{{ t("pay_view.point_expiration_reminder.page_title") }}</h2>

    <form @submit.prevent="next" class="pt2-card">

      <!-- User info bar -->
      <div class="pt2-user-bar">
        <div class="pt2-user-bar-left">
          <div class="pt2-user-icon">
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
          </div>
          <span class="pt2-user-label">{{ t("pay_view.point_expiration_reminder.greeting") }}</span>
        </div>
        <span class="pt2-user-value">{{ phone }}</span>
      </div>

      <!-- Points highlight -->
      <div class="pt2-points-section">
        <p class="pt2-points-desc">
          {{ t("pay_view.point_expiration_reminder.reminder_prefix") }}
          <strong class="pt2-brand">{{ resolvedDomainName }}</strong>
          {{ t("pay_view.point_expiration_reminder.reminder_middle") }}
        </p>
        <div class="pt2-points-display">
          <span class="pt2-points-num">{{ formatNumber(totalPoint) }}</span>
          <span class="pt2-points-unit">{{ t("pay_view.point_expiration_reminder.points_unit") }}</span>
        </div>
        <p class="pt2-points-suffix">{{ t("pay_view.point_expiration_reminder.reminder_suffix") }}</p>
      </div>

      <div class="pt2-divider"></div>

      <!-- Promotion box -->
      <div class="pt2-promo-box">
        <div class="pt2-promo-icon">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
        </div>
        <p>{{ t("pay_view.point_expiration_reminder.promotion_description") }}</p>
      </div>

      <!-- Notes -->
      <div class="pt2-notes">
        <h3 class="pt2-notes-title">
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
          {{ t("pay_view.point_expiration_reminder.important_title") }}
        </h3>
        <ul class="pt2-notes-list">
          <li>{{ t("pay_view.point_expiration_reminder.note_item_1") }}</li>
          <li>{{ t("pay_view.point_expiration_reminder.note_item_2") }}</li>
          <li>{{ t("pay_view.point_expiration_reminder.note_item_3") }}</li>
        </ul>
      </div>

      <!-- CTA + button -->
      <p class="pt2-cta-text">{{ t("pay_view.point_expiration_reminder.call_to_action") }}</p>

      <button type="submit" class="pt2-submit-btn">
        {{ t("Next Step") }}
      </button>

      <!-- Security line -->
      <div class="pt2-security">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
        <span>SSL &middot; PCI-DSS</span>
      </div>

    </form>
  </div>
</template>

<style scoped>
.pt2-page {
  min-height: 100vh;
  background: linear-gradient(160deg, #f0f4ff 0%, #f8fafc 60%, #f5f7fa 100%);
  padding: 24px 14px 40px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Page title ===== */
.pt2-page-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 20px;
  letter-spacing: -0.3px;
}

/* ===== Card ===== */
.pt2-card {
  max-width: 520px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(226,232,240,0.8);
  box-shadow:
    0 0 0 1px rgba(148,163,184,0.05),
    0 4px 6px -2px rgba(15,23,42,0.04),
    0 12px 32px -8px rgba(15,23,42,0.1);
  overflow: hidden;
  padding: 0 0 20px;
}

/* ===== User bar ===== */
.pt2-user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

.pt2-user-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pt2-user-icon {
  width: 30px;
  height: 30px;
  background: color-mix(in srgb, var(--global-primary-color, #3b82f6) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--global-primary-color, #3b82f6) 20%, #fff);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pt2-user-icon svg {
  width: 15px;
  height: 15px;
  color: var(--global-primary-color, #3b82f6);
  stroke: var(--global-primary-color, #3b82f6);
}

.pt2-user-label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}

.pt2-user-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.02em;
}

/* ===== Points section ===== */
.pt2-points-section {
  text-align: center;
  padding: 24px 24px 16px;
}

.pt2-points-desc {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 12px;
}

.pt2-brand {
  color: var(--global-primary-color, #3b82f6);
  font-weight: 700;
}

.pt2-points-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.pt2-points-num {
  font-size: 3rem;
  font-weight: 900;
  color: var(--global-primary-color, #3b82f6);
  letter-spacing: -2px;
  line-height: 1;
}

.pt2-points-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--global-primary-color, #3b82f6);
}

.pt2-points-suffix {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0;
}

/* ===== Divider ===== */
.pt2-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e2e8f0, transparent);
  margin: 4px 24px 16px;
}

/* ===== Promo box ===== */
.pt2-promo-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 20px 16px;
  padding: 13px 14px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
}

.pt2-promo-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pt2-promo-icon svg {
  width: 18px;
  height: 18px;
  stroke: #0ea5e9;
}

.pt2-promo-box p {
  margin: 0;
  font-size: 0.83rem;
  color: #0369a1;
  line-height: 1.6;
}

/* ===== Notes ===== */
.pt2-notes {
  margin: 0 20px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 14px 16px;
}

.pt2-notes-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #c2410c;
  margin: 0 0 10px;
}

.pt2-notes-title svg {
  width: 14px;
  height: 14px;
  stroke: #f97316;
  flex-shrink: 0;
}

.pt2-notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pt2-notes-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: #92400e;
  line-height: 1.5;
}

.pt2-notes-list li::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f97316;
  flex-shrink: 0;
  margin-top: 6px;
}

/* ===== CTA ===== */
.pt2-cta-text {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  margin: 8px 20px 16px;
  line-height: 1.5;
}

/* ===== Submit button ===== */
.pt2-submit-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px;
  height: 52px;
  background: var(--global-primary-color, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--global-primary-color, #3b82f6) 35%, transparent);
  position: relative;
  overflow: hidden;
}

.pt2-submit-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
  pointer-events: none;
}

.pt2-submit-btn:hover  { filter: brightness(1.07); }
.pt2-submit-btn:active { transform: scale(0.985); filter: brightness(0.95); }

/* ===== Security line ===== */
.pt2-security {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 14px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #9ca3af;
}

.pt2-security svg {
  width: 11px;
  height: 11px;
  stroke: #34d399;
  flex-shrink: 0;
}
</style>
