/* PayWith - LINE Pay Style Flat & Clean Stylesheet with Smooth Native Transitions */

:root {
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --line-green: #06c755;
    --line-green-hover: #05b04c;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #8e8e93;
    --border-color: #e5e7eb;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), 16px);
}

* {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-sizing: border-box;
    box-shadow: none !important;
}

input, textarea {
    user-select: text;
}

html, body {
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background-color: #ffffff;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

/* ================================================= */
/* App Viewport & Screen Containers                  */
/* ================================================= */
.app-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    max-height: 100dvh;
    overflow: hidden;
    background-color: #ffffff;
    transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1), transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.app-screen.hidden {
    display: none !important;
}

#wallet-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    max-height: 100dvh;
    overflow: hidden;
    background-color: #f8f9fa;
}

#wallet-screen > header {
    flex-shrink: 0;
    z-index: 30;
}

#wallet-screen > main {
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    padding-bottom: 0;
}

/* ================================================= */
/* Bulletproof Smooth Horizontal Sliding Panels      */
/* ================================================= */
.tab-view-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: 96px;
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.24s ease, visibility 0.3s;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    z-index: 1;
}

.tab-view-panel.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0%);
    z-index: 10;
}

.tab-view-panel.slide-left {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
    z-index: 1;
}

.tab-view-panel.slide-right {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    z-index: 1;
}

/* ================================================= */
/* App Startup Splash Screen Animation               */
/* ================================================= */
#app-splash-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    padding: 0;
    margin: 0;
    touch-action: none;
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

#app-splash-screen.splash-fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.03);
}

/* ================================================= */
/* LINE Pay 1:1 Pixel-Perfect PIN Screen & Keypad    */
/* ================================================= */
.pin-dot-linepay {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e5e5ea;
    transition: background-color 0.12s ease;
}

.pin-dot-linepay.filled {
    background: #111827;
}

.numpad-key-linepay {
    width: 72px;
    height: 64px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 300;
    color: #111827;
    background: transparent;
    border: none !important;
    margin: 0 auto;
    transition: background-color 0.08s ease;
}

.numpad-key-linepay:active {
    background-color: #f3f4f6;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.animate-shake {
    animation: shake 0.35s ease-in-out both;
}

/* ================================================= */
/* Main Wallet Components (Flat & Clean)             */
/* ================================================= */
.flat-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.flat-card:active {
    background-color: #fafafa;
    transform: scale(0.99);
}

.card-swiper {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 1.25rem;
    gap: 0.75rem;
    scrollbar-width: none;
}

.card-swiper::-webkit-scrollbar {
    display: none;
}

.swiper-item {
    scroll-snap-align: start;
    flex-shrink: 0;
}

.add-card-pill-flat {
    width: 64px;
    height: 148px;
    border-radius: 1rem;
    background: #ffffff;
    border: 2px dashed #d1d5db;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.add-card-pill-flat:active {
    background: #f3f4f6;
    border-color: var(--line-green);
    color: var(--line-green);
    transform: scale(0.97);
}

.flat-voucher-card {
    width: 250px;
    height: 148px;
    border-radius: 1rem;
    padding: 1.1rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.flat-voucher-card:active {
    background: #f9fafb;
    transform: scale(0.98);
}

/* ================================================= */
/* Apple Wallet Style Cascading Card Stack           */
/* ================================================= */
/* ================================================= */
/* ================================================= */
/* Apple Wallet Interactive Physics Deck             */
/* ================================================= */
.apple-wallet-stack {
    position: relative;
    width: 100%;
}

/* 1. Stack Mode (Apple Wallet 擬真互動層疊) */
.apple-wallet-stack.stack-mode {
    position: relative;
    min-height: 480px;
    padding-top: 4px;
    padding-bottom: 80px;
}

.apple-wallet-stack.stack-mode .apple-deck-card {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 220px;
    border-radius: 1.25rem;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.25), 0 10px 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.38s cubic-bezier(0.18, 0.95, 0.28, 1.05), opacity 0.3s ease, box-shadow 0.35s ease;
    will-change: transform, opacity;
    touch-action: pan-y;
}

.apple-wallet-stack.stack-mode .apple-deck-card.is-focused {
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55), 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.apple-wallet-stack.stack-mode .apple-deck-card:active {
    filter: brightness(1.05);
}

/* 2. List Mode (展開全卡片清單) */
.apple-wallet-stack.list-mode {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 4px;
    padding-bottom: 40px;
    min-height: auto;
}

.apple-wallet-stack.list-mode .apple-deck-card {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    opacity: 1 !important;
    width: 100%;
    height: 210px;
    border-radius: 1.25rem;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.apple-wallet-stack.list-mode .apple-deck-card:active {
    transform: scale(0.985) !important;
}

.apple-card-banner {
    width: 100%;
    height: 120px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.apple-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.apple-card-body {
    flex: 1;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* ================================================= */
/* Floating Stadium Capsule Island Bottom Nav        */
/* ================================================= */
.flat-bottom-nav-container {
    flex-shrink: 0;
    width: 100%;
    padding: 6px 14px max(env(safe-area-inset-bottom, 0px) + 8px, 12px) 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    z-index: 40;
    pointer-events: none;
}

.flat-bottom-nav {
    position: relative;
    width: 100%;
    max-width: 440px;
    height: 56px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
    touch-action: none;
    user-select: none;
    pointer-events: auto;
}

.nav-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    gap: 2px;
    flex: 1;
    height: 44px;
    border-radius: 9999px;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: manipulation;
}

.nav-tab-btn svg,
.nav-tab-btn i {
    width: 19px;
    height: 19px;
    stroke-width: 2.2;
    transition: transform 0.2s ease, stroke 0.2s ease;
}

.nav-tab-btn:active {
    transform: scale(0.94);
}

.nav-tab-btn.active {
    background-color: #e6f7ec;
    color: #06c755;
}

.nav-tab-btn.active svg,
.nav-tab-btn.active i {
    transform: scale(1.05);
    stroke-width: 2.5;
}

/* ================================================= */
/* In-App Fullscreen Voucher Viewer (Slide-Up Push)  */
/* ================================================= */
#voucher-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#voucher-viewer-modal.viewer-active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* Pull to Refresh */
#pull-to-refresh-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    pointer-events: none;
    transform: translateY(-100%);
    transition: transform 0.2s ease-out;
    background: #f3f4f6;
    border-bottom: 1px solid var(--border-color);
    z-index: 20;
}

#pull-to-refresh-indicator.pulling {
    transform: translateY(0);
}

.inapp-browser-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

/* ================================================= */
/* Smooth General Modals & Popups                    */
/* ================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.22s ease-out, visibility 0.22s ease-out;
}

.modal-overlay.modal-active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.modal-card-box {
    transform: scale(0.93) translateY(12px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    will-change: transform, opacity;
}

.modal-overlay.modal-active .modal-card-box {
    transform: scale(1) translateY(0);
}

::-webkit-scrollbar {
    display: none;
}
