/* Member Discount - Frontend Styles */

.md-tier-widget {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.md-tier-widget h3 {
    margin-top: 0;
    color: #fff;
    font-size: 24px;
}

.md-tier-widget .tier-name {
    font-size: 32px;
    font-weight: bold;
    margin: 10px 0;
}

.md-tier-widget .tier-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.md-tier-widget .info-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 5px;
}

.md-tier-widget .info-item .label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 5px;
}

.md-tier-widget .info-item .value {
    font-size: 20px;
    font-weight: 600;
}

/* Progress Section */
.md-progress-section {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.md-progress-section h4 {
    margin-top: 0;
    color: #fff;
}

.md-progress-bar {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 30px;
    overflow: hidden;
    margin: 15px 0;
    position: relative;
    /* Added for label positioning */
}

.md-progress-bar-fill {
    background: #fff;
    height: 100%;
    display: block;
    /* Changed from flex */
    color: #667eea;
    font-weight: 600;
    transition: width 0.5s ease;
    overflow: visible;
    /* Allow label to show even if width is 0 */
}

.md-progress-label {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    z-index: 1;
}

/* Tier Comparison Table */
.md-tiers-table {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin: 30px 0;
    padding: 30px;
}

.md-tiers-table h2 {
    font-size: 1.5rem;
    padding: 0 0px;
    /* Add some side padding if needed inside the container */
    margin-top: 0;
}

.md-tiers-table table {
    width: 100%;
    border-collapse: collapse;
    border: none;
}

/* 覆蓋 WooCommerce shop_table 邊框 */
.md-tiers-table table.shop_table,
.md-history-table.shop_table {
    border: none;
}

.md-tiers-table th {
    background: #f8f9fa;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
}

.md-tiers-table td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f1;
}

.md-tiers-table tr:last-child td {
    border-bottom: none;
}

.md-tiers-table .current-tier {
    background: #f0f7ff;
}

/* Product Notice */
.md-product-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
}

.md-product-notice.upgrade {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

/* Cart Notice Customization */
.woocommerce-message.md-tier-message {
    border-top-color: #667eea;
}

.woocommerce-message.md-tier-message::before {
    color: #667eea;
}

/* Account Page Tier Section */
.woocommerce-account .md-member-tier-page {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
}

.md-member-tier-page h2 {
    margin-top: 0;
    color: #333;
}

.md-benefits-list {
    list-style: none;
    padding: 0;
}

.md-benefits-list li {
    padding: 10px 0;
    padding-left: 30px;
    position: relative;
}

.md-benefits-list li::before {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

/* ============================================
   Progress Bar - 會員中心進度條組件
   ============================================ */

/* 等級資訊卡片 */
.md-tier-info-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

/* 非會員標題區 */
.md-tier-info-card.no-tier-header {
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
}

.md-tier-info-card.no-tier-header .tier-badge {
    justify-content: center;
    margin-bottom: 10px;
}

.md-tier-info-card.no-tier-header .tier-intro {
    margin: 15px 0 0 0;
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.95);
}

.md-tier-widget.no-tier {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.tier-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.tier-icon {
    font-size: 32px;
}

.tier-name {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.tier-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.detail-item {
    flex: 1;
    min-width: 150px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-item.warning {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.5);
}

.detail-item .label {
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item .value {
    font-size: 18px;
    font-weight: 600;
}

/* 進度條容器 */
.md-progress-bars {
    margin: 20px 0;
}

/* 進度卡片 */
.md-progress-card {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.md-progress-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.md-progress-card.eligible {
    border: 2px solid #28a745;
}

/* 卡片頭部 */
.md-progress-card .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

.md-progress-card.eligible .card-header {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.md-progress-card .card-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #495057;
}

.md-progress-card.eligible .card-header h4 {
    color: #155724;
}

.tier-name-inline {
    color: #667eea;
    font-weight: 700;
}

/* 卡片主體 */
.md-progress-card .card-body {
    padding: 20px;
}

/* 金額與狀態行 */
.progress-amount-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.current-amount {
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-badge.eligible {
    background: #28a745;
    color: #fff;
}

.status-badge.not-eligible {
    background: #ffc107;
    color: #856404;
}

.status-badge .badge-icon {
    font-size: 16px;
    font-weight: bold;
}

/* 進度條包裝器 */
.progress-bar-wrapper {
    margin: 15px 0;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    animation: shimmer 10s infinite;
}

.progress-fill.success {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* 進度說明文字 */
.progress-footer {
    margin-top: 12px;
}

.progress-hint {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.5;
    margin: 0;
}

/* 續會成功訊息 */
.renewal-success-message {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    margin-bottom: 15px;
}

.success-icon {
    width: 40px;
    height: 40px;
    background: #28a745;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.success-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    color: #155724;
}

/* 最高等級永久會籍 */
.md-progress-card.max-tier-permanent {
    border: 2px solid #ffc107;
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.md-progress-card.max-tier-permanent .card-header {
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
}

.md-progress-card.max-tier-permanent .card-header h4 {
    color: #fff;
}

.congratulation-text {
    font-size: 16px;
    color: #f57f17;
    text-align: center;
    line-height: 1.6;
    margin: 0;
}

/* 操作按鈕區 */
.md-tier-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.md-tier-actions .button,
.md-tier-actions .button-secondary {
    flex: 1;
    text-align: center;
    padding: 12px 24px;
    border-radius: 10px !important;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    background: #667eea !important;
    color: #ffffff !important;
    border: none !important;
}

.md-tier-actions .button:hover,
.md-tier-actions .button-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background: #5a6fd6 !important;
    /* Slightly darker on hover */
    opacity: 1 !important;
}

/* 統一進度條樣式 */
.md-unified-progress-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.md-unified-progress-card .progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.md-unified-progress-card .header-left,
.md-unified-progress-card .header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.md-unified-progress-card .tooltip-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: help;
}

.md-unified-progress-card .info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.md-unified-progress-card .icon-text {
    font-weight: 500;
    color: #333;
}

/* Tooltip 樣式 */
.md-unified-progress-card .tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 10px 14px;
    background: #333;
    color: white;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 300px;
    white-space: normal;
    width: max-content;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.md-unified-progress-card .tooltip-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.md-unified-progress-card .tooltip-icon:hover::after,
.md-unified-progress-card .tooltip-icon:hover::before {
    opacity: 1;
}

/* 右側 tooltip 向左對齊 */
.md-unified-progress-card .header-right .tooltip-icon::after {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.md-unified-progress-card .header-right .tooltip-icon::before {
    left: auto;
    right: 10px;
    transform: translateX(0);
}

.md-unified-progress-card .progress-content {
    color: #333;
}

.md-unified-progress-card .progress-amount-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 16px;
}

.md-unified-progress-card .current-amount {
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
}

.md-unified-progress-card .target-amount {
    font-size: 20px;
    color: #999;
}

.md-unified-progress-card .remaining-badge {
    margin-left: auto;
    padding: 4px 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

.md-unified-progress-card.eligible .remaining-badge {
    background: #d1fae5;
    color: #065f46;
}

.md-unified-progress-card .progress-bar-wrapper {
    margin-bottom: 12px;
}

.md-unified-progress-card .progress-bar {
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.md-unified-progress-card .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.md-unified-progress-card .progress-fill.complete {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.md-unified-progress-card .progress-hint {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* ============================================
   Mobile Responsive - 與桌面版風格一致
   ============================================ */
@media (max-width: 768px) {

    /* --- 會員等級頁面容器 --- */
    .woocommerce-account .md-member-tier-page {
        padding: 0;
    }

    /* --- 等級資訊卡片 (與 Widget 一致) --- */
    .md-tier-widget {
        padding: 20px;
        border-radius: 10px;
        margin-bottom: 20px;
    }

    .md-tier-widget h3 {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .md-tier-widget .tier-name {
        font-size: 28px;
        margin: 10px 0;
    }

    /* tier-info 使用 flex wrap 而非 grid，與桌面版一致 */
    .md-tier-widget .tier-info {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .md-tier-widget .info-item {
        flex: 1 1 calc(50% - 10px);
        min-width: 140px;
        padding: 12px 15px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 5px;
    }

    .md-tier-widget .info-item .label {
        font-size: 12px;
        opacity: 0.8;
        margin-bottom: 5px;
    }

    .md-tier-widget .info-item .value {
        font-size: 18px;
        font-weight: 600;
    }

    /* 生日優惠券區塊 - 全寬顯示 */
    .md-tier-widget .info-item.birthday-coupon-info {
        flex: 1 1 100%;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .md-tier-widget .info-item.birthday-coupon-info .value {
        font-size: 15px;
    }

    /* --- 進度區塊 --- */
    .md-progress-section {
        padding: 15px;
        margin: 15px 0;
        border-radius: 8px;
    }

    .md-progress-section h4 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .md-progress-section p {
        font-size: 14px;
        line-height: 1.5;
    }

    .md-progress-bar {
        height: 30px;
    }

    /* --- 等級說明表格 (卡片式，與桌面風格一致) --- */
    .md-tiers-table {
        padding: 20px;
        margin: 20px 0;
        border-radius: 10px;
    }

    .md-tiers-table h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .md-tiers-table table {
        display: block;
    }

    .md-tiers-table thead {
        display: none;
    }

    .md-tiers-table tbody {
        display: block;
    }

    .md-tiers-table tr {
        display: block;
        background: #f8f9fa;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 15px;
    }

    .md-tiers-table tr.current-tier {
        background: #f0f7ff;
        border: 2px solid #667eea;
    }

    .md-tiers-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid #e9ecef;
        width: 100%;
        box-sizing: border-box;
        font-size: 14px;
    }

    .md-tiers-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .md-tiers-table td:first-child {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        border-bottom: 2px solid #e9ecef;
        padding-bottom: 12px;
        margin-bottom: 5px;
    }

    .md-tiers-table td:first-child strong {
        font-size: 18px;
        color: #333;
    }

    .md-tiers-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #495057;
        font-size: 13px;
        flex-shrink: 0;
    }

    .md-tiers-table td:first-child::before {
        display: none;
    }

    /* 目前等級 Badge */
    .md-tiers-table .md-badge.active {
        display: inline-block;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: #fff;
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        margin-left: 0;
    }

    /* --- 等級說明表格 - 移除 WooCommerce 邊框 --- */
    .md-tiers-table table.shop_table,
    .md-tiers-table .shop_table {
        border: none !important;
    }

    .md-tiers-table table.shop_table td,
    .md-tiers-table table.shop_table th {
        border: none !important;
    }

    /* --- 等級變更歷史表格 (卡片式) --- */
    .md-tier-history-frame {
        padding: 20px;
        margin: 20px 0;
        border-radius: 10px;
    }

    .md-history-title {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .md-history-table,
    .md-history-table.shop_table {
        border: none !important;
        border-collapse: collapse;
        width: 100% !important;
    }

    .md-history-table thead {
        display: none;
    }

    .md-history-table tbody {
        display: block;
        width: 100%;
    }

    .md-history-table tr {
        display: block;
        background: #f8f9fa;
        border: 1px solid #e9ecef !important;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .md-history-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        padding: 10px 0 !important;
        border: none !important;
        border-bottom: 1px solid #e9ecef !important;
        width: 100% !important;
        box-sizing: border-box;
        text-align: right;
        gap: 15px;
    }

    .md-history-table td::before {
        content: attr(data-title);
        font-weight: 600;
        color: #495057;
        font-size: 13px;
        text-align: left;
        flex-shrink: 0;
        min-width: 70px;
    }

    .md-history-table td:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    .md-history-table .md-status-label {
        font-size: 13px;
        padding: 5px 10px;
        white-space: normal;
        word-break: keep-all;
        text-align: right;
        line-height: 1.4;
        flex: 1;
    }

    /* 變更內容欄位允許自然換行 */
    .md-history-table td.md-content {
        flex-wrap: wrap;
    }

    /* --- tier-details (Widget 結構) --- */
    .tier-details {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .detail-item {
        flex: 1 1 calc(50% - 10px);
        min-width: 140px;
    }

    /* --- 進度條相關 --- */
    .progress-amount-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .current-amount {
        font-size: 24px;
    }

    .md-tier-actions {
        flex-direction: column;
        gap: 10px;
    }

    .md-tier-actions .button,
    .md-tier-actions .button-secondary {
        width: 100%;
    }

    .renewal-success-message {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    /* --- 統一進度條 --- */
    .md-unified-progress-card {
        padding: 20px;
        margin: 15px 0;
        border-radius: 12px;
    }

    .md-unified-progress-card .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 15px;
    }

    .md-unified-progress-card .tooltip-icon::after {
        max-width: 280px;
        font-size: 12px;
        left: 0;
        transform: translateX(0);
    }

    .md-unified-progress-card .progress-amount-row {
        flex-wrap: wrap;
        gap: 5px;
        align-items: baseline;
    }

    .md-unified-progress-card .current-amount {
        font-size: 24px;
    }

    .md-unified-progress-card .target-amount {
        font-size: 18px;
    }

    .md-unified-progress-card .remaining-badge {
        margin-left: auto;
        margin-top: 0;
    }

    .md-unified-progress-card .progress-hint {
        font-size: 13px;
    }

    /* --- 會員詳細資料 --- */
    .md-member-detail {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Extra Small Devices (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .md-tier-widget {
        padding: 15px;
    }

    .md-tier-widget .tier-name {
        font-size: 24px;
    }

    .md-tier-widget .info-item {
        flex: 1 1 100%;
    }

    .md-tier-widget .info-item .value {
        font-size: 16px;
    }

    .md-tiers-table,
    .md-tier-history-frame {
        padding: 0;
    }

    .md-tiers-table tr,
    .md-history-table tr {
        padding: 12px;
    }

    .md-tiers-table td:first-child strong {
        font-size: 16px;
    }

    .detail-item {
        flex: 1 1 100%;
    }

    .md-unified-progress-card .remaining-badge {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-top: 8px;
    }
}


/* Member Tier History Page */
.md-tier-history-frame {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin: 30px 0;
    padding: 30px;
}

.md-history-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

/* 表格基本樣式 */
.md-history-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    border-radius: 0;
    border: none;
}

.md-history-table th,
.md-history-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.md-history-table thead th {
    background-color: #f9f9f9;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #e5e5e5;
}

/* 內容欄位寬度與對齊 */
.md-history-table .md-date {
    width: 25%;
}

.md-history-table .md-content {
    width: 35%;
}

.md-history-table .md-note {
    width: 40%;
}

/* 最後一行去除底線 */
.md-history-table tbody tr:last-child td {
    border-bottom: none;
}

/* 狀態標籤樣式 (Badge Style) */
.md-status-label {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.95em;
    line-height: 1.2;
}

/* 綠色標籤 (升級) */
.md-status-label.upgrade,
.md-status-label.renewal,
.md-status-label.initial {
    background-color: #dbf0dc;
    /* 淺綠底 */
    color: #155724;
    /* 深綠字 */
}

/* 灰色/紅色標籤 (降級) */
.md-status-label.downgrade {
    background-color: #f8d7da;
    color: #721c24;
}

/* 藍色標籤 (手動調整) */
.md-status-label.manual {
    background-color: #cce5ff;
    color: #004085;
}

/* 響應式：手機版調整 */
@media (max-width: 768px) {
    .md-tier-history-frame {
        padding: 15px;
        /* 手機版減少 padding 以爭取空間 */
    }

    .md-history-table thead {
        display: none;
    }

    .md-history-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #e5e5e5;
        border-radius: 4px;
    }

    .md-history-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
        text-align: right;
        width: 100%;
        box-sizing: border-box;
    }

    .md-history-table td:before {
        content: attr(data-title);
        float: left;
        font-weight: 600;
        color: #333;
    }

    .md-history-table td:last-child {
        border-bottom: none;
    }

    .md-status-label {
        display: inline-block;
        max-width: 100%;
    }
}

.md-tier-history-link a {
    color: #ffffff !important;
}

/* ============================================
   生日優惠券區塊樣式
   ============================================ */
.birthday-coupon-info .coupon-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.birthday-coupon-info .md-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.birthday-coupon-info .md-badge.available {
    background: rgba(40, 167, 69, 0.9);
    color: #fff;
}

.birthday-coupon-info .md-badge.used {
    background: rgba(108, 117, 125, 0.9);
    color: #fff;
}

.birthday-coupon-info .md-badge.expired {
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
}

.birthday-coupon-info .coupon-code {
    font-size: 14px;
    opacity: 0.95;
}

.birthday-coupon-info .coupon-code code {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.birthday-coupon-info .coupon-expiry,
.birthday-coupon-info .coupon-product,
.birthday-coupon-info .coupon-preview,
.birthday-coupon-info .coupon-product-preview {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.5;
}

/* ============================================
   會員等級說明表格 - 目前等級徽章
   ============================================ */
.md-tiers-table .md-badge.active {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* 手機版：移除左邊距 */
@media (max-width: 768px) {
    .md-tiers-table .md-badge.active {
        margin-left: 0;
    }
}