/* ==========================================================================
   shadcn-style theme · zinc palette · HSL tokens
   ========================================================================== */
:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 71% 45%;
    --warning: 38 92% 50%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 10% 3.9%;
    --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: 240 10% 3.9%;
        --foreground: 0 0% 98%;
        --card: 240 10% 3.9%;
        --card-foreground: 0 0% 98%;
        --popover: 240 10% 3.9%;
        --popover-foreground: 0 0% 98%;
        --primary: 0 0% 98%;
        --primary-foreground: 240 5.9% 10%;
        --secondary: 240 3.7% 15.9%;
        --secondary-foreground: 0 0% 98%;
        --muted: 240 3.7% 15.9%;
        --muted-foreground: 240 5% 64.9%;
        --accent: 240 3.7% 15.9%;
        --accent-foreground: 0 0% 98%;
        --destructive: 0 62.8% 30.6%;
        --destructive-foreground: 0 0% 98%;
        --border: 240 3.7% 15.9%;
        --input: 240 3.7% 15.9%;
        --ring: 240 4.9% 83.9%;
    }
}

/* ==========================================================================
   Base layout
   ========================================================================== */
body.pay-page {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, "Helvetica Neue", Arial,
                 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    font-feature-settings: "rlig" 1, "calt" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    padding: 2.5rem 1rem 3rem;
    line-height: 1.5;
}

.pay-wrap {
    max-width: 28rem;
    margin: 0 auto;
}

/* ==========================================================================
   Card
   ========================================================================== */
.pay-card {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
    overflow: hidden;
}

/* Header (flat, no gradient) */
.pay-header {
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--card));
}

.pay-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.625rem;
}

.pay-brand::before {
    content: "";
    width: 0.375rem;
    height: 0.375rem;
    background: hsl(var(--primary));
    border-radius: 9999px;
}

.pay-amount {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.035em;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-variant-numeric: tabular-nums;
    color: hsl(var(--foreground));
}

.pay-amount .symbol {
    font-size: 1rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    letter-spacing: 0;
}

.pay-subtitle {
    margin-top: 0.25rem;
    font-size: 0.813rem;
    color: hsl(var(--muted-foreground));
}

.pay-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem 0.25rem 0.5rem;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.875rem;
    color: hsl(var(--foreground));
    transition: border-color 0.15s, background 0.15s;
}

.pay-status .dot {
    position: relative;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: hsl(var(--warning));
    flex-shrink: 0;
}

.pay-status .dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: hsl(var(--warning));
    opacity: 0.4;
    animation: pay-ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pay-ping {
    75%, 100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

.pay-status.paid {
    background: hsl(var(--success) / 0.1);
    border-color: hsl(var(--success) / 0.25);
    color: hsl(var(--success));
}

.pay-status.paid .dot { background: hsl(var(--success)); }
.pay-status.paid .dot::after { display: none; }

/* ==========================================================================
   Body
   ========================================================================== */
.pay-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Countdown */
.pay-countdown {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pay-countdown.invisible { visibility: hidden; }

.pay-countdown .unit {
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    padding: 0.5rem 0.625rem;
    border-radius: calc(var(--radius) - 2px);
    text-align: center;
    min-width: 2.875rem;
}

.pay-countdown .unit .num {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
    color: hsl(var(--foreground));
}

.pay-countdown .unit .label {
    font-size: 0.625rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.375rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
}

/* QR code */
.pay-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.pay-qr {
    padding: 0.75rem;
    background: #ffffff;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
    text-align: center;
    line-height: 0;
}

.pay-qr img {
    display: block;
    width: 200px;
    height: 200px;
    border-radius: calc(var(--radius) - 4px);
}

.pay-chain-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 9999px;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   Data card (prominent amount / address)
   ========================================================================== */
.pay-data {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
    padding: 0.875rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.15s;
}

.pay-data:hover {
    border-color: hsl(var(--muted-foreground) / 0.3);
}

.pay-data-header {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.pay-data-header svg {
    width: 0.75rem;
    height: 0.75rem;
    opacity: 0.7;
}

.pay-data-value {
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.9375rem;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.5;
    color: hsl(var(--foreground));
    letter-spacing: 0.015em;
}

.pay-data-value.amount {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    line-height: 1.1;
}

.pay-data-value.amount .symbol {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    letter-spacing: 0;
}

.pay-data .copy-btn {
    margin-top: 0.375rem;
    width: 100%;
    height: 2.25rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid hsl(var(--primary));
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: opacity 0.15s, background 0.15s;
    line-height: 1;
    font-family: inherit;
}

.pay-data .copy-btn:hover {
    opacity: 0.9;
}

.pay-data .copy-btn:active {
    opacity: 0.8;
}

.pay-data .copy-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.pay-data .copy-btn svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

/* Alert / warning */
.pay-warning {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.813rem;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    line-height: 1.5;
}

.pay-warning .icon {
    flex-shrink: 0;
    margin-top: 0.0625rem;
    color: hsl(var(--warning));
}

/* Info list (bordered container with dividers) */
.pay-info-list {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    background: hsl(var(--card));
}

.pay-info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 0.813rem;
    min-height: 3rem;
}

.pay-info-item:last-child {
    border-bottom: 0;
}

.pay-info-item .label {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    flex-shrink: 0;
    min-width: 3.75rem;
    font-weight: 500;
}

.pay-info-item .value {
    flex: 1;
    font-weight: 500;
    word-break: break-all;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.75rem;
    color: hsl(var(--foreground));
    line-height: 1.5;
}

.pay-info-item .value.amount {
    font-size: 0.875rem;
    font-weight: 600;
    font-family: ui-sans-serif, system-ui, sans-serif;
}

.pay-info-item .copy-btn {
    border: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    padding: 0 0.625rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1;
}

.pay-info-item .copy-btn:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.pay-info-item .copy-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Footer */
.pay-footer {
    text-align: center;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

/* ==========================================================================
   Toast (Sonner-inspired)
   ========================================================================== */
.pay-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.pay-toast {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.813rem;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.08),
                0 4px 6px -4px rgb(0 0 0 / 0.08);
    opacity: 0;
    transform: translateX(120%);
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: auto;
    max-width: 22rem;
    min-width: 12rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    line-height: 1.25;
}

.pay-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.pay-toast::before {
    content: "";
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    background-color: hsl(var(--muted-foreground));
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><path d='M12 8h.01'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><path d='M12 8h.01'/></svg>") center/contain no-repeat;
}

.pay-toast.success::before {
    background-color: hsl(var(--success));
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><polyline points='9 12 11 14 15 10'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><polyline points='9 12 11 14 15 10'/></svg>") center/contain no-repeat;
}

.pay-toast.error::before {
    background-color: hsl(var(--destructive));
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><line x1='15' y1='9' x2='9' y2='15'/><line x1='9' y1='9' x2='15' y2='15'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><line x1='15' y1='9' x2='9' y2='15'/><line x1='9' y1='9' x2='15' y2='15'/></svg>") center/contain no-repeat;
}

/* ==========================================================================
   Paid overlay
   ========================================================================== */
.pay-overlay {
    position: fixed;
    inset: 0;
    background: hsl(240 10% 3.9% / 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 1rem;
}

.pay-overlay.show { opacity: 1; }

.pay-overlay-card {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    padding: 2rem 1.5rem 1.75rem;
    border-radius: calc(var(--radius) + 4px);
    text-align: center;
    max-width: 20rem;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.pay-overlay.show .pay-overlay-card { transform: scale(1); }

.pay-overlay-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    background: hsl(var(--success) / 0.12);
    color: hsl(var(--success));
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pay-overlay-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    letter-spacing: -0.01em;
}

.pay-overlay-desc {
    font-size: 0.813rem;
    color: hsl(var(--muted-foreground));
}

/* ==========================================================================
   State pages (Order expired / not found)
   ========================================================================== */
.pay-state {
    max-width: 24rem;
    margin: 4rem auto 0;
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 4px);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}

.pay-state-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pay-state-icon.muted {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.pay-state-icon.danger {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.pay-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    letter-spacing: -0.01em;
}

.pay-state-desc {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 1.25rem;
}

.pay-state .btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    height: 2.25rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
    border: 0;
}

.pay-state .btn-back:hover {
    opacity: 0.9;
    color: hsl(var(--primary-foreground));
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 480px) {
    body.pay-page { padding: 1rem 0.75rem 2rem; }
    .pay-header { padding: 1.25rem; }
    .pay-amount { font-size: 2rem; }
    .pay-data-value.amount { font-size: 1.75rem; }
    .pay-body { padding: 1.25rem; gap: 1rem; }
    .pay-qr img { width: 176px; height: 176px; }
    .pay-toast-container { right: 0.75rem; top: 0.75rem; left: 0.75rem; align-items: stretch; }
    .pay-toast { max-width: none; min-width: 0; }
    .pay-info-item { flex-wrap: wrap; }
    .pay-info-item .value { text-align: left; }
}
