/* ============================================================
   NM WIT Short — Institutional Design System
   ============================================================ */
:root {
  /* Brand */
  ---nm-purple-900: #0A1F4A;
  ---nm-purple-800: #0E2A5C;
  ---nm-purple-700: #12306B;
  ---nm-purple-600: #1B417F;
  ---nm-purple-100: #E8EEF9;
  ---nm-purple-50: #F3F6FC;

  --nm-purple-900: #24103F;
  --nm-purple-800: #35145F;
  --nm-purple-700: #481A78;
  --nm-purple-600: #5D2491;
  --nm-purple-100: #EDE4F5;
  --nm-purple-50: #F8F4FB;

  /* Accent */
  --nm-gold-600: #A8843A;
  --nm-gold-500: #C8A24C;
  --nm-gold-300: #E3CB8B;
  --nm-gold-100: #FAF3E2;

  /* Semantic */
  --nm-success: #0F7B54;
  --nm-success-bg: #E7F5EF;
  --nm-danger: #B42318;
  --nm-danger-bg: #FDECEA;
  --nm-warning: #B54708;

  /* Neutral */
  --nm-ink: #101828;
  --nm-body: #344054;
  --nm-muted: #667085;
  --nm-line: #E4E7EC;
  --nm-surface: #FFFFFF;
  --nm-bg: #F7F8FB;

  /* Shape & Motion */
  --nm-r-sm: .625rem;
  --nm-r-md: .875rem;
  --nm-r-lg: 1.125rem;
  --nm-r-xl: 1.5rem;
  --nm-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --nm-shadow-md: 0 4px 12px rgba(10, 31, 74, .07), 0 1px 3px rgba(10, 31, 74, .05);
  --nm-shadow-lg: 0 18px 40px -12px rgba(10, 31, 74, .18), 0 2px 8px rgba(10, 31, 74, .06);
  --nm-ease: cubic-bezier(.4, 0, .2, 1);
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Noto Sans Thai", sans-serif;
  color: var(--nm-body);
  background-color: var(--nm-bg);
  background-image:
    radial-gradient(820px 420px at 50% -180px, rgba(18, 48, 107, .10) 0%, transparent 70%),
    linear-gradient(180deg, #FBFCFE 0%, var(--nm-bg) 320px);

  background-repeat: no-repeat;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

main {
  background-image: url(../img/background.png);
  background-size: 100%;
  background-repeat: no-repeat;
}


/* ---------- Header / Brand ---------- */
.brand-badge {}

.brand-badge img {
  width: 100%;
}

h1 {
  color: var(--nm-ink);
  letter-spacing: -.02em;
}

.text-gradient {
  background: linear-gradient(95deg, var(--nm-gold-600), var(--nm-gold-500) 60%, var(--nm-gold-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-rule {
  width: 56px;
  height: 3px;
  margin: 1rem auto 1.1rem;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--nm-gold-500), var(--nm-gold-300));
}

.brand-sub {
  color: var(--nm-muted);
  font-size: 1.02rem;
}

/* ---------- Card ---------- */
.card-app {
  background: var(--nm-surface);
  border: 1px solid var(--nm-line);
  border-radius: var(--nm-r-xl);
  box-shadow: var(--nm-shadow-lg);
  overflow: hidden;
  position: relative;
}

.card-app::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #5c2ac3, #e8e3f9 55%, #9C27B0);
  opacity: .9;
}

/* ---------- Form ---------- */
.form-label {
  color: var(--nm-ink);
  font-size: .9rem;
  letter-spacing: .01em;
}

.form-control,
.input-group-text {
  border-color: var(--nm-line);
  color: var(--nm-ink);
  background-color: #fff;
}

.form-control::placeholder {
  color: #98A2B3;
}

.input-group-lg>.form-control,
.input-group-lg>.input-group-text {
  font-size: 1rem;
  padding-block: .72rem;
  border-radius: var(--nm-r-md);
}

.form-control:focus {
  border-color: var(--nm-purple-600);
  box-shadow: 0 0 0 3.5px rgba(18, 48, 107, .13);
}

.input-group:focus-within .input-group-text {
  border-color: var(--nm-purple-600);
}

.input-group-text {
  background: var(--nm-purple-50);
  color: var(--nm-purple-700);
}

.prefix-text {
  background: linear-gradient(180deg, var(--nm-purple-100), var(--nm-purple-50));
  color: var(--nm-purple-800);
  font-weight: 600;
  white-space: nowrap;
  border-color: var(--nm-line);
}

.form-text {
  color: var(--nm-muted);
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 48px;
  font-weight: 600;
  letter-spacing: .01em;
  border-radius: 99px;
  transition: all .18s var(--nm-ease);
}

.btn-brand {
  background: linear-gradient(150deg, var(--nm-purple-600) 0%, var(--nm-purple-800) 100%);
  border: 1px solid var(--nm-purple-900);
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(10, 31, 74, .55), inset 0 1px 0 rgba(255, 255, 255, .14);
}

.btn-brand:hover:not(:disabled),
.btn-brand:focus-visible {
  color: #fff;
  transform: translateY(-1.5px);
  background: linear-gradient(150deg, var(--nm-purple-700) 0%, var(--nm-purple-900) 100%);
  box-shadow: 0 12px 26px -8px rgba(10, 31, 74, .62), inset 0 1px 0 rgba(255, 255, 255, .18);
}

.btn-brand:active:not(:disabled) {
  transform: translateY(0);
}

.btn-brand:disabled {
  opacity: .65;
  box-shadow: none;
}

.btn-gold {
  background: linear-gradient(150deg, var(--nm-gold-500), var(--nm-gold-600));
  border: 1px solid var(--nm-gold-600);
  color: #3D2E0B;
  box-shadow: 0 8px 18px -9px rgba(168, 132, 58, .6);
}

.btn-gold:hover {
  color: #3D2E0B;
  transform: translateY(-1.5px);
}

.btn-outline-brand {
  border: 1.5px solid var(--nm-purple-600);
  color: var(--nm-purple-700);
  background: #fff;
}

.btn-outline-brand:hover {
  background: var(--nm-purple-700);
  border-color: var(--nm-purple-700);
  color: #fff;
}

.btn-ghost {
  background: var(--nm-purple-50);
  border: 1px solid var(--nm-line);
  color: var(--nm-purple-800);
}

.btn-ghost:hover {
  background: var(--nm-purple-100);
  color: var(--nm-purple-900);
}

.btn:focus-visible {
  outline: 3px solid rgba(18, 48, 107, .28);
  outline-offset: 2px;
}

/* ---------- Result Section ---------- */
.result-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--nm-success);
  font-weight: 700;
  padding: .7rem 1rem;
  border-radius: var(--nm-r-md);
  background: var(--nm-success-bg);
  border: 1px solid rgba(15, 123, 84, .18);
}

.short-url-box {
  background: linear-gradient(180deg, #fff, var(--nm-purple-50));
  border: 1px solid var(--nm-purple-100);
  border-left: 4px solid var(--nm-gold-500);
  border-radius: var(--nm-r-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--nm-shadow-sm);
}

.short-url-text {
  display: block;
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--nm-purple-800);
  text-decoration: none;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.short-url-text:hover {
  color: var(--nm-purple-600);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field-caption {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--nm-muted);
}

/* ---------- QR ---------- */
.qr-frame {
  width: min(248px, 74vw);
  aspect-ratio: 1;
  margin-inline: auto;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--nm-line);
  border-radius: var(--nm-r-lg);
  box-shadow: var(--nm-shadow-md);
  display: grid;
  place-items: center;
  position: relative;
}

.qr-frame::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: .75rem;
  border: 1px solid var(--nm-gold-300);
  pointer-events: none;
  opacity: .55;
}

.qr-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: .35rem;
}

.qr-caption {
  font-size: .8rem;
  color: var(--nm-muted);
  margin-top: .6rem;
}

/* ---------- Status ---------- */
.alias-ok {
  color: var(--nm-success);
}

.alias-bad {
  color: var(--nm-danger);
}

.invalid-feedback {
  color: var(--nm-danger);
  font-weight: 500;
}

.trust-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem .75rem;
  margin-top: 1.5rem;
}

.trust-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--nm-line);
  color: var(--nm-body);
  box-shadow: var(--nm-shadow-sm);
}

.trust-chip i {
  color: var(--nm-gold-600);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--nm-line);
  color: var(--nm-muted);
  font-size: .85rem;
}

.site-footer strong {
  color: var(--nm-purple-800);
}

/* ---------- Helpers ---------- */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.fade-in-up {
  animation: nmFadeUp .45s var(--nm-ease) both;
}

@keyframes nmFadeUp {
  from {
    opacity: 0;
    transform: translateY(14px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

/* ---------- SweetAlert2 Theme ---------- */
.swal2-popup {
  border-radius: var(--nm-r-xl) !important;
  font-family: 'Sarabun', sans-serif !important;
}

.swal2-title {
  color: var(--nm-ink) !important;
  font-size: 1.3rem !important;
  font-weight: 700 !important;
}

.swal2-html-container {
  color: var(--nm-body) !important;
}

.swal2-styled.swal2-confirm {
  background: linear-gradient(150deg, var(--nm-purple-600), var(--nm-purple-800)) !important;
  border-radius: 99px !important;
  padding: .65rem 1.9rem !important;
  font-weight: 600 !important;
  box-shadow: 0 8px 18px -8px rgba(10, 31, 74, .55) !important;
}

.swal2-styled.swal2-cancel {
  background: var(--nm-purple-50) !important;
  color: var(--nm-purple-800) !important;
  border-radius: 99px !important;
  padding: .65rem 1.9rem !important;
  font-weight: 600 !important;
}

.swal2-toast {
  border-radius: var(--nm-r-md) !important;
  box-shadow: var(--nm-shadow-lg) !important;
}

.qr-frame .qr-alt,
.qr-box .qr-alt {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.qr-frame .qr-alt canvas,
.qr-frame .qr-alt img,
.qr-box .qr-alt canvas,
.qr-box .qr-alt img {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: .35rem;
}

/* ----- Card ----- */
.stats-card {
  position: relative;
  min-height: 96px;
  padding: 18px 24px;
  display: flex;
  gap: 20px;
  background: #f5f4fe;
  border: 2px solid #b8bcf3;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(61, 36, 145, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  transition: all 0.25s ease;
  align-items: center;
}

.gold {
  background: #fefaf4;
  border: 2px solid #f6dec9;
}

.stats-icon {
  flex: 0 0 65px;
  width: 65px;
  height: 65px;
  display: flex;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg,
      #5424bd,
      #743bd3);

  color: #fff;
  font-size: 50px;
  box-shadow:
    0 6px 15px rgba(84, 36, 189, 0.22);
}

.gold .stats-icon {
  background: linear-gradient(135deg,
      #e69d14,
      #f9cd89);
}

/* แสงจาง ๆ ด้านขวา */
.stats-card::after {
  content: "";
  position: absolute;
  width: 100px;
  height: 100px;

  right: -35px;
  top: -35px;

  border-radius: 50%;

  background: rgba(84, 36, 189, 0.08);

  pointer-events: none;
}

.stats-card.gold::after {

  background: #fcf1e5;
}

.stats-card:hover {
  transform: translateY(-2px);

  box-shadow:
    0 12px 30px rgba(61, 36, 145, 0.12),
    0 3px 8px rgba(0, 0, 0, 0.04);
}

.stats-label {
  position: relative;
  z-index: 1;
  font-size: 16px;
  font-weight: 800;
  color: #4b2995;
  margin-bottom: 4px;
}

.stats-value {
  position: relative;
  z-index: 1;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  text-align: justify;
  color: #4d22b8;
}

.gold .stats-label {
  color: #b56f12;
}

.gold .stats-value {
  color: #b56f12;
}

/* ---------- Responsive ---------- */
@media (max-width:575.98px) {


  h1 {
    font-size: 1.6rem;
  }

  .brand-sub {
    font-size: .94rem;
  }

  .card-app {
    border-radius: 1.15rem;
  }

  .prefix-text {
    font-size: .82rem !important;
    padding-inline: .65rem;
  }

  .short-url-text {
    font-size: 1rem;
  }

  .stats-card {
    padding: 18px 10px;
    gap: 4px;

  }

  .stats-icon {
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    font-size: 36px;
  }
}

@media (orientation:landscape) and (max-height:500px) {
  .app-header {
    margin-bottom: 1.15rem !important;
  }

  .brand-badge {
    width: 48px;
    height: 48px;
    font-size: 1.45rem;
  }

  .brand-rule {
    margin-block: .6rem .7rem;
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  body {
    background: #fff;
  }

  .btn,
  .site-footer,
  .trust-bar,
  #formCard {
    display: none !important;
  }

  .card-app {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}