/* ========== 基本設定 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background-color: #f2f3f5;
    color: #333;
    line-height: 1.6;
}

/* ========== 載入中畫面 ========== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #06c755;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    margin-top: 20px;
    color: #666;
    font-size: 16px;
}

/* ========== 主容器 ========== */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    background: #f2f3f5;
    min-height: 100vh;
    position: relative;
    padding-bottom: 100px;
}

.content-wrapper {
    padding: 16px;
}

/* ========== 卡片共用樣式 ========== */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
    padding: 24px;
}

/* ========== 會員卡片 ========== */
.member-card-container {
    /* 繼承 .card 樣式 */
}

.member-card-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    align-items: center;
}

.member-card-image-wrapper {
    grid-column: span 3 / span 3;
}

.member-card-image {
    width: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
}

/* 無圖片時隱藏圖片區塊，名字擴展填滿左側，點數維持靠右 */
.member-card-image-wrapper.hidden {
    display: none;
}

.member-card-image-wrapper.hidden ~ .member-info-wrapper {
    grid-column: span 9 / span 9;
}

.member-info-wrapper {
    grid-column: span 6 / span 6;
    min-width: 0;
}

.member-info {
    min-width: 0;
}

.member-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.member-name {
    font-size: 20px;
    font-weight: bold;
    color: #000000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 條碼快捷按鈕（條碼關閉時顯示於名字旁） */
.barcode-shortcut {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f3f4f6;
    border: none;
    color: #6657cc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.barcode-shortcut:hover {
    background: #ecebff;
}

.barcode-shortcut:active {
    background: #ddd9ff;
}

.member-level {
    font-size: 14px;
    color: #6b7280;
}

.member-points-wrapper {
    grid-column: span 3 / span 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.member-points-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.points-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #111827;
}

.points-info {
    text-align: right;
}

.points-value {
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    color: #000000;
}

.points-label {
    font-size: 14px;
    color: #6b7280;
}

.chevron-icon {
    width: 24px;
    height: 24px;
    color: #9ca3af;
    flex-shrink: 0;
    stroke-width: 2;
}

/* 進度條區域 */
.progress-section {
    margin-top: 16px;
    background: #f3f4f6;
    border-radius: 16px;
    padding: 16px;
}

.progress-bar-bg {
    height: 12px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: #a855f7;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 8px;
}

.progress-text {
    /* 繼承 progress-info 樣式 */
}

.progress-date {
    /* 繼承 progress-info 樣式 */
}

.upgrade-link {
    display: block;
    font-size: 12px;
    text-decoration: none;
}

/* ========== 條碼卡片 ========== */
.barcode-card {
    text-align: center;
}

.barcode-pattern {
    width: 100%;
    height: 96px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: block;
}

.member-id {
    font-size: 14px;
    color: #666666;
}

/* ========== 條碼彈窗 Modal ========== */
.barcode-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.barcode-modal-card {
    position: relative;
    width: 320px;
    max-width: 90%;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
    padding: 22px 20px 20px;
    text-align: center;
}

.barcode-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.2s;
}

.barcode-modal-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.barcode-modal-title {
    font-size: 16px;
    font-weight: bold;
    color: #111827;
    margin-bottom: 12px;
    margin-top: 4px;
}

.barcode-modal-image {
    height: 120px;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    padding: 12px;
}

.barcode-modal-image .barcode-pattern {
    width: 100%;
    height: 100%;
}

.barcode-modal-member-id {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.barcode-modal-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.5;
}

/* ========== 主要按鈕卡片 ========== */
.main-buttons-card {
    padding: 16px;
}

.main-buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.main-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #374151;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.main-button:active {
    background: #f9fafb;
}

.main-button-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-button-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.main-button-name {
    font-size: 12px;
    text-align: center;
    color: #374151;
    line-height: 1.3;
}

/* ========== 廣告輪播區塊 ========== */
.ad-section {
    margin-bottom: 16px;
}

/* 廣告佔位區（無廣告時顯示） */
.ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    background: #f9fafb;
}

.ad-placeholder-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
    margin-bottom: 12px;
}

.ad-placeholder-text {
    font-size: 14px;
    color: #9ca3af;
}

.coupons-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    color: #d1d5db;
}

.coupons-placeholder svg {
    margin-bottom: 8px;
}

.coupons-placeholder p {
    font-size: 14px;
    color: #9ca3af;
    margin: 0;
}

.banner-block {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
    padding: 12px;
    overflow: hidden;
}

.banner-block:last-child {
    margin-bottom: 0;
}

/* 靜態 Banner（一列排開不輪播） */
.static-banner-grid {
    display: grid;
    gap: 8px;
}

.static-banner-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.static-banner-item a {
    display: block;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.static-banner-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* 影片播放按鈕（thumbnail 模式） */
.static-banner-item,
.banner-swiper .swiper-slide {
    position: relative;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    pointer-events: none;
}

/* 輪播 Banner（Swiper） */
.banner-swiper {
    border-radius: 12px;
    overflow: hidden;
}

.banner-swiper .swiper-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.banner-swiper .swiper-slide a {
    display: block;
    width: 100%;
}

.banner-swiper .swiper-slide img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* 廣告名稱與副標題 */
.banner-slide-info {
    padding: 8px 4px 0;
    text-align: center;
}

.banner-slide-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
}

.banner-slide-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* Swiper 指示點客製 */
.banner-swiper .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background: #d1d5db;
    opacity: 1;
}

.banner-swiper .swiper-pagination-bullet-active {
    background: #4b5563;
}

.banner-swiper .dots-shadow .swiper-pagination-bullet {
    box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.3);
}

/* 有文字時，指示點在圖片與文字之間 */
.banner-swiper.has-info .banner-slide-info {
    padding-top: 20px;
}

.banner-swiper.has-info > .swiper-pagination {
    bottom: 38px;
}

/* Swiper 箭頭客製 */
.banner-swiper .swiper-button-next,
.banner-swiper .swiper-button-prev {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.banner-swiper .swiper-button-next::after,
.banner-swiper .swiper-button-prev::after {
    font-size: 14px;
    font-weight: bold;
}

/* ========== 優惠券卡片 ========== */
.coupons-card {
    padding: 16px;
}

.coupons-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.coupons-title {
    font-size: 16px;
    font-weight: bold;
    color: #1f2937;
}

.coupons-view-all {
    font-size: 14px;
    color: #2563eb;
    text-decoration: none;
    transition: text-decoration 0.2s;
}

.coupons-view-all:hover {
    text-decoration: underline;
}

.coupons-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 優惠券版型一：上下分層 (v1) */
.coupon-card-v1 {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    background: white;
}

.coupon-v1-top {
    position: relative;
    padding: 16px 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
}

.coupon-v1-top::before,
.coupon-v1-top::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: #f2f3f5;
    border-radius: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.coupon-v1-top::before {
    left: -8px;
}

.coupon-v1-top::after {
    right: -8px;
}

.coupon-v1-divider {
    width: 72px;
    flex-shrink: 0;
    padding-right: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    margin-right: 16px;
}

.coupon-v1-divider::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    border-right: 1px dashed rgba(255, 255, 255, 0.4);
}

.coupon-value {
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coupon-type {
    font-size: 10px;
    opacity: 0.9;
    margin-top: 2px;
}

.coupon-info {
    flex: 1;
    min-width: 0;
}

.coupon-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coupon-expiry {
    font-size: 9px;
}

.coupon-bottom {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.coupon-status {
    font-size: 10px;
}

.coupon-days {
    font-weight: bold;
}

.coupon-button {
    padding: 6px 20px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.coupon-button:active {
    opacity: 0.8;
}

/* ========== 登出按鈕 ========== */
.logout-section {
    padding: 0 16px;
    margin-bottom: 16px;
}

.logout-button {
    width: 100%;
    background: #fafafa;
    border: 2px solid #cccccc;
    color: #666666;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-button:hover {
    background: #f0f0f0;
}

.logout-button:active {
    transform: scale(0.98);
}

/* ========== 頁尾按鈕 ========== */
.page-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f8f7fb;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.1), 0 -4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 12px 14px 14px;
    z-index: 100;
    max-width: 600px;
    margin: 0 auto;
}

.footer-buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    align-items: center;
    justify-items: center;
    padding: 0 8px;
}

.footer-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    width: 100%;
    max-width: 72px;
    transition: all 0.2s;
}

.footer-button-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 4px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.footer-button-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.footer-button-name {
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1.2;
}

/* ========== 響應式設計 ========== */
@media (max-width: 480px) {
    .member-card-grid {
        gap: 12px;
    }

    .member-name {
        font-size: 18px;
    }

    .points-value {
        font-size: 20px;
    }

    .main-buttons-grid {
        gap: 8px;
    }

    .main-button-icon {
        width: 40px;
        height: 40px;
    }

    .main-button-name {
        font-size: 11px;
    }
}
