﻿/* ===========================================================
   停車費線上繳費 - 三步驟流程（ParkingPayFlow 回植版）
   所有 class 加 pf- 前綴，避免與 Bootstrap 的 .btn / .modal / .toast 衝突。
   手機直式優先，桌面置中不超過 480px。
   =========================================================== */

#payflow {
    --pf-brand: #0b5fa5;
    --pf-brand-dark: #094b83;
    --pf-brand-light: #e8f1fa;
    --pf-text: #1a1a1a;
    --pf-muted: #6b7280;
    --pf-line: #d7dce3;
    --pf-surface: #ffffff;
    --pf-ok: #16a34a;
    --pf-danger: #dc2626;
    --pf-radius: 8px;

    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
    color: var(--pf-text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

#payflow * {
    box-sizing: border-box;
}

@media (min-width: 520px) {
    #payflow {
        margin-top: 12px;
        border: 1px solid var(--pf-line);
        border-radius: 12px;
        background: var(--pf-surface);
        padding-bottom: 28px;
    }
}

/* ---------- 頁首場站名 ---------- */

.pf-brand {
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--pf-brand);
    padding: 14px 0 0;
}

/* ---------- 步驟條 ---------- */

.pf-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px 8px 4px;
}

.pf-step {
    flex: 0 0 auto;
    width: 86px;
    text-align: center;
    position: relative;
}

.pf-step .pf-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #c7cdd6;
    margin: 0 auto 6px;
    transition: background .2s;
}

.pf-step .pf-label {
    font-size: 12px;
    color: var(--pf-muted);
    white-space: nowrap;
}

.pf-step:not(:first-child)::before {
    content: "";
    position: absolute;
    top: 6px;
    right: 50%;
    width: 100%;
    height: 1px;
    background: #c7cdd6;
}

.pf-step.done .pf-dot,
.pf-step.active .pf-dot {
    background: var(--pf-brand);
}

.pf-step.done .pf-label,
.pf-step.active .pf-label {
    color: var(--pf-brand);
}

.pf-step.done::before,
.pf-step.active::before {
    background: var(--pf-brand);
}

/* ---------- 區塊 ---------- */

.pf-panel {
    display: none;
}

.pf-panel.show {
    display: block;
}

.pf-title {
    text-align: center;
    font-size: 19px;
    font-weight: 600;
    margin: 18px 0 20px;
}

.pf-hint {
    font-size: 13px;
    color: var(--pf-muted);
    margin: -10px 0 14px;
    text-align: center;
}

/* ---------- 表單 ---------- */

.pf-field {
    margin-bottom: 16px;
}

.pf-field-label {
    display: block;
    font-size: 13px;
    color: var(--pf-muted);
    margin-bottom: 6px;
}

.pf-input {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    font-size: 17px;
    color: var(--pf-text);
    background: var(--pf-surface);
    border: 1px solid var(--pf-brand);
    border-radius: 4px;
    outline: none;
    font-family: inherit;
}

.pf-input::placeholder {
    color: #aab1bb;
    letter-spacing: normal;
}

.pf-input:focus {
    border-color: var(--pf-brand);
    box-shadow: 0 0 0 3px var(--pf-brand-light);
}

.pf-input.invalid {
    border-color: var(--pf-danger);
}

.pf-input:disabled {
    background: #f3f4f6;
    color: var(--pf-muted);
    border-color: var(--pf-line);
}

.pf-input#pfCarNumber {
    letter-spacing: 2px;
    font-weight: 600;
    text-transform: uppercase;
}

select.pf-input {
    appearance: auto;
}

.pf-error {
    display: none;
    margin-top: 6px;
    font-size: 12px;
    color: var(--pf-danger);
}

.pf-error.show {
    display: block;
}

.pf-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--pf-muted);
    margin: 6px 0 14px;
    cursor: pointer;
}

.pf-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--pf-brand);
    margin: 0;
}

/* 發票方式 */

.pf-radio-row {
    padding: 10px 0;
}

.pf-radio-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 15px;
    margin: 0;
}

.pf-radio-row input[type="radio"] {
    width: 17px;
    height: 17px;
    accent-color: var(--pf-brand);
    margin: 0;
    flex: 0 0 auto;
}

.pf-sub {
    display: none;
    margin: 4px 0 6px 25px;
    padding: 10px;
    border: 1px solid var(--pf-line);
    border-radius: 4px;
}

.pf-sub.show {
    display: block;
}

.pf-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pf-inline .pf-tag {
    font-size: 13px;
    color: var(--pf-muted);
    white-space: nowrap;
}

.pf-inline .pf-input {
    height: 38px;
    font-size: 15px;
}

/* ---------- 按鈕 ---------- */

.pf-btn {
    display: block;
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: var(--pf-brand);
    color: #fff;
    transition: background .15s;
    line-height: 1;
}

.pf-btn:active {
    background: var(--pf-brand-dark);
}

.pf-btn:disabled {
    background: #a9b4c0;
    cursor: not-allowed;
}

.pf-btn + .pf-btn {
    margin-top: 10px;
}

.pf-btn-outline {
    background: var(--pf-surface);
    color: var(--pf-brand);
    border: 1px solid var(--pf-brand);
}

.pf-btn-outline:active {
    background: var(--pf-brand-light);
}

.pf-btn-danger {
    background: var(--pf-surface);
    color: var(--pf-danger);
    border: 1px solid var(--pf-danger);
}

.pf-btn-small {
    width: auto;
    height: 34px;
    padding: 0 16px;
    font-size: 14px;
    display: inline-block;
}

.pf-link {
    display: block;
    width: 100%;
    margin-top: 16px;
    background: none;
    border: 0;
    font-family: inherit;
    font-size: 14px;
    color: var(--pf-muted);
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- 車輛候選清單 ---------- */

.pf-car-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pf-car {
    border: 1px solid var(--pf-line);
    border-radius: var(--pf-radius);
    overflow: hidden;
    background: var(--pf-surface);
}

.pf-car.selected {
    border-color: var(--pf-brand);
    box-shadow: 0 0 0 3px var(--pf-brand-light);
}

.pf-car-img {
    position: relative;
    width: 100%;
    background: #e5e7eb;
    overflow: hidden;
    line-height: 0;
}

/* 照片完整顯示：寬度填滿，高度依照片原比例（現場相機多為 16:9） */
.pf-car-img img {
    width: 100%;
    height: auto;
    display: block;
}

/* 載入中或沒有照片時，先用 16:9 佔位，避免版面跳動 */
.pf-car-img.loading,
.pf-car-img.noimg {
    aspect-ratio: 16 / 9;
}

.pf-car-img.loading img {
    position: absolute;
    inset: 0;
    height: 100%;
    object-fit: contain;
}

.pf-car-img .pf-noimg {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--pf-muted);
}

.pf-car-img.noimg img {
    display: none;
}

.pf-car-img.noimg .pf-noimg {
    display: flex;
}

.pf-car-body {
    padding: 10px 12px 12px;
}

.pf-car-plate {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
}

.pf-car-meta {
    font-size: 13px;
    color: var(--pf-muted);
    margin: 2px 0 10px;
}

.pf-car-meta .pf-conf {
    margin-left: 8px;
}

/* ---------- 停車資訊卡 ---------- */

.pf-card {
    border: 1px solid var(--pf-line);
    border-radius: var(--pf-radius);
    padding: 14px 16px 12px;
    margin-bottom: 18px;
}

.pf-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.pf-time {
    text-align: center;
    flex: 1;
}

.pf-time .pf-date {
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-time .pf-clock {
    font-size: 27px;
    font-weight: 300;
    color: var(--pf-brand);
    line-height: 1.25;
}

.pf-time-arrow {
    flex: 0 0 auto;
    color: #9aa3af;
    font-size: 18px;
    padding-top: 12px;
}

.pf-amount-row {
    text-align: right;
    margin-top: 6px;
}

.pf-amount-row .pf-caption {
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-amount-row .pf-value {
    font-size: 24px;
    font-weight: 400;
    color: var(--pf-brand);
}

.pf-car-row {
    margin-top: 4px;
    font-size: 15px;
    letter-spacing: 1px;
}

.pf-summary {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 7px 2px;
    font-size: 15px;
}

.pf-summary.total {
    border-top: 1px solid var(--pf-line);
    margin-top: 2px;
    padding-top: 12px;
    margin-bottom: 14px;
}

.pf-summary.total .pf-num {
    font-size: 20px;
    font-weight: 600;
}

.pf-summary .pf-discount {
    color: var(--pf-ok);
}

/* 發票摘要 */

.pf-receipt-box {
    border: 1px solid var(--pf-line);
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.pf-receipt-box .pf-caption {
    font-size: 12px;
    color: var(--pf-muted);
}

.pf-receipt-editor {
    display: none;
    border: 1px solid var(--pf-line);
    border-radius: 4px;
    padding: 6px 12px 10px;
    margin-bottom: 14px;
}

.pf-receipt-editor.show {
    display: block;
}

/* ---------- 付款方式 ---------- */

.pf-pay-methods {
    display: none;
    margin-top: 16px;
    border-top: 1px solid var(--pf-line);
    padding-top: 12px;
}

.pf-pay-methods.show {
    display: block;
}

.pf-pay-methods .pf-caption {
    font-size: 13px;
    color: var(--pf-muted);
    margin-bottom: 8px;
}

.pf-pay-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 12px;
    margin-bottom: 8px;
    background: var(--pf-surface);
    border: 1px solid var(--pf-line);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    color: var(--pf-text);
    text-align: left;
    cursor: pointer;
}

.pf-pay-option:active {
    background: #f7f9fc;
}

.pf-pay-option .pf-mark {
    flex: 0 0 auto;
    width: 46px;
    height: 26px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
    overflow: hidden;
}

.pf-pay-option .pf-mark img {
    height: 100%;
    width: auto;
    display: block;
}

.pf-mark-card { background: var(--pf-brand); }

.pf-pay-option.pf-apple {
    padding: 0;
    border: 0;
    background: none;
    display: block;
}

.pf-pay-option.pf-apple .apple-pay-button {
    width: 100%;
    height: 48px;
}

.pf-pay-option.pf-google {
    padding: 0;
    border: 0;
    background: none;
    display: block;
    min-height: 48px;
}

/* ---------- 掃描發票 ---------- */

.pf-scan-hint {
    text-align: center;
    color: var(--pf-brand);
    font-weight: 600;
    font-size: 15px;
    margin: 6px 0 12px;
}

.pf-scanner {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    line-height: 0;
}

.pf-scanner video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pf-scanner .scan-region-highlight {
    border-radius: 16px;
    outline: rgba(0, 0, 0, 0.5) solid 9999px !important;
}

.pf-scanner .scan-region-highlight-svg {
    display: none !important;
}

.pf-scan-tools {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
}

.pf-scan-tools select {
    flex: 1;
    height: 38px;
}

.pf-flash {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: 0;
    background: #198754;
    color: #fff;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.pf-flash.off {
    opacity: .5;
}

/* ---------- 結果 ---------- */

.pf-result {
    text-align: center;
    padding: 40px 0 16px;
}

.pf-result .pf-icon {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: 4px solid var(--pf-ok);
    color: var(--pf-ok);
    font-size: 42px;
    line-height: 70px;
    margin: 0 auto 22px;
}

.pf-result .pf-icon.fail {
    border-color: var(--pf-danger);
    color: var(--pf-danger);
}

.pf-result .pf-icon.info {
    border-color: var(--pf-brand);
    color: var(--pf-brand);
}

.pf-result h2 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 600;
}

.pf-result p {
    margin: 0;
    color: var(--pf-muted);
    font-size: 14px;
}

.pf-result .pf-paid {
    margin-top: 18px;
    font-size: 28px;
    font-weight: 600;
    color: var(--pf-text);
}

/* ---------- 共用 ---------- */

.pf-loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, .6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.pf-loading.show {
    display: flex;
}

.pf-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--pf-line);
    border-top-color: var(--pf-brand);
    border-radius: 50%;
    animation: pf-spin .8s linear infinite;
}

@keyframes pf-spin {
    to { transform: rotate(360deg); }
}

.pf-toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    max-width: 90%;
    background: rgba(0, 0, 0, .82);
    color: #fff;
    font-size: 14px;
    padding: 10px 18px;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 1110;
}

.pf-toast.show {
    opacity: 1;
}

.pf-terms ol {
    text-align: left;
    padding-left: 1.2em;
    font-size: 14px;
    margin: 0;
}

.pf-terms li {
    margin-bottom: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .pf-spinner {
        animation: none;
    }
}
