/* --- THEME & DARK MODE VARIABLES --- */
:root {
    --theme-color-primary: #1976D2;
    --theme-color-title: #2196F3;
    --theme-color-summary-bg: #E3F2FD;
    --theme-color-summary-border: #2196F3;
    --theme-color-summary-text: #1565C0;

    --color-bg: #f3f4f6;
    --color-surface: #ffffff;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-tertiary: #9ca3af;
    --color-border: #e5e7eb;
    --color-table-header-bg: #f8fafc;
    --color-table-row-odd-bg: transparent;

    --md-sys-color-primary: var(--theme-color-primary);
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: var(--theme-color-title);
    --md-sys-color-on-primary-container: #FFFFFF;
    --md-sys-color-secondary-container: var(--theme-color-summary-bg);
    --md-sys-color-on-secondary-container: var(--theme-color-summary-text);
    --md-sys-color-surface: var(--color-surface);
    --md-sys-color-on-surface: var(--color-text-primary);
    --md-sys-color-surface-variant: var(--color-table-header-bg);
    --md-sys-color-on-surface-variant: var(--color-text-secondary);
    --md-sys-color-outline: var(--color-border);
}

html.dark {
    --color-bg: #0d1117;
    --color-surface: #161b22;
    --color-text-primary: #e2e8f0; 
    --color-text-secondary: #b0b8c4; 
    --color-text-tertiary: #586069;
    --color-border: #30363d;
    --color-table-header-bg: #1c2128;
    --color-table-row-odd-bg: transparent;

    --md-sys-color-primary: var(--theme-color-title);
    --md-sys-color-on-primary: #0d1117;
    --md-sys-color-primary-container: var(--theme-color-primary);
    --md-sys-color-on-primary-container: #FFFFFF;
    --md-sys-color-secondary-container: #21262d;
    --md-sys-color-on-secondary-container: var(--color-text-primary);
    --md-sys-color-surface-variant: var(--color-table-header-bg);
    --md-sys-color-surface-container: #1c2128;
    --md-sys-color-surface-container-highest: #30363d;
    --md-menu-container-color: #1c2128;
    --md-list-container-color: #1c2128;
}

/* 網頁底層：極致炫彩極光對比漸變背景 */
body { 
    font-family: 'Roboto', 'Noto Sans TC', sans-serif; 
    color: var(--color-text-primary); 
    min-height: 100vh; 
    /* 使用色彩極其飽和、大跨度的霓虹極光漸層底色 */
    background: linear-gradient(135deg, #a5b4fc 0%, #fef08a 40%, #fbcfe8 75%, #99f6e4 100%);
    background-attachment: fixed;
    transition: background 0.3s, color 0.3s;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

/* 禁用長按圖片彈出原生系統選單，並防止選取 */
img {
    -webkit-touch-callout: none !important; /* 禁用 iOS Safari 圖片長按選單 */
    -webkit-user-select: none !important;   /* 禁用 iOS Safari 選取 */
    user-select: none !important;           /* 禁用標準選取 */
    pointer-events: none;                   /* 點擊穿透給父容器，避開 Android 原生彈窗 */
}

/* 慢速漂浮動畫：最大化減少 CPU 消耗，僅使用 transform 和 scale */
@keyframes floatOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(6vw, 4vh) scale(1.15); }
}
@keyframes floatOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-5vw, -6vh) scale(1.12); }
}
@keyframes floatOrb3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-4vw, 5vh) scale(1.08); }
}

/* 極光氣泡 1：左上角（高飽和深靛藍） */
body::before {
    content: ''; position: fixed; top: -15%; left: -15%; width: 75vw; height: 75vw;
    background: radial-gradient(circle, rgba(67, 56, 202, 0.55) 0%, rgba(67, 56, 202, 0) 70%);
    border-radius: 50%; z-index: -1; pointer-events: none;
    animation: floatOrb1 25s infinite ease-in-out;
}
/* 極光氣泡 2：右下角（高飽和艷麗玫瑰紅） */
body::after {
    content: ''; position: fixed; bottom: -20%; right: -15%; width: 85vw; height: 85vw;
    background: radial-gradient(circle, rgba(225, 29, 72, 0.45) 0%, rgba(225, 29, 72, 0) 70%);
    border-radius: 50%; z-index: -1; pointer-events: none;
    animation: floatOrb2 30s infinite ease-in-out;
}
/* 極光氣泡 3：中左側（鮮豔翡翠綠） */
html::before {
    content: ''; position: fixed; top: 25%; left: -20%; width: 65vw; height: 65vw;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.4) 0%, rgba(13, 148, 136, 0) 70%);
    border-radius: 50%; z-index: -1; pointer-events: none;
    animation: floatOrb3 22s infinite ease-in-out;
}

/* 深色模式底層：高飽和度迷幻霓虹夜色 */
html.dark body { 
    background: linear-gradient(135deg, #03001e 0%, #12002f 40%, #1c0024 75%, #001a1a 100%); 
}
html.dark body::before { 
    background: radial-gradient(circle, rgba(139, 92, 246, 0.45) 0%, rgba(139, 92, 246, 0) 75%); 
    animation-duration: 20s;
}
html.dark body::after { 
    background: radial-gradient(circle, rgba(244, 63, 94, 0.38) 0%, rgba(244, 63, 94, 0) 75%); 
    animation-duration: 25s;
}
html.dark html::before { 
    background: radial-gradient(circle, rgba(6, 182, 212, 0.35) 0%, rgba(6, 182, 212, 0) 75%); 
    animation-duration: 18s;
}

/* 主容器玻璃設定（調回最適透光度，強化模糊特效） */
.main-container { 
    background-color: rgba(255, 255, 255, 0.45); 
    backdrop-filter: blur(32px); 
    -webkit-backdrop-filter: blur(32px); 
    border: 1px solid rgba(255, 255, 255, 0.85); 
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    transition: background-color 0.3s, border-color 0.3s; 
}
html.dark .main-container { 
    background-color: rgba(22, 27, 34, 0.45); 
    border: 1px solid rgba(255, 255, 255, 0.15); 
}

/* 匯總區塊玻璃設定 */
.summary-box { 
    background-color: rgba(227, 242, 253, 0.35); 
    backdrop-filter: blur(16px); 
    -webkit-backdrop-filter: blur(16px); 
    border: 1px solid rgba(33, 150, 243, 0.35); 
    color: var(--theme-color-summary-text); 
    transition: all 0.3s ease; 
}
html.dark .summary-box { 
    background-color: rgba(33, 38, 45, 0.35); 
    border: 1px solid rgba(255, 255, 255, 0.12); 
}

/* 紀錄卡片磨砂玻璃設定 */
.record-card { 
    touch-action: pan-y; 
    background-color: rgba(255, 255, 255, 0.25); 
    backdrop-filter: blur(24px); 
    -webkit-backdrop-filter: blur(24px); 
    border: 1px solid rgba(255, 255, 255, 0.75);
    position: relative; 
    z-index: 2; 
    transform: translateX(0); 
    will-change: transform; 
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
}
html.dark .record-card { 
    background-color: rgba(28, 33, 40, 0.30); 
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-shadow: 0 0 1px rgba(255,255,255,0.25); 
}

.tabular-nums { font-variant-numeric: tabular-nums; }
.summary-divider::after { content: ''; position: absolute; right: 0; top: 25%; height: 50%; width: 1px; background-color: var(--theme-color-summary-border); opacity: 0.2; }

/* --- 滑動刪除與飛入動畫樣式 --- */
.slide-in-left {
    opacity: 0;
    transform: translateX(-40px);
    will-change: opacity, transform;
}
.slide-in-left.is-visible {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.5s ease-out, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.swipe-container { position: relative; overflow: hidden; border-radius: 1.5rem; transform: translateZ(0); }
.swipe-action-bg { position: absolute; right: 0; top: 0; bottom: 0; width: 100px; background-color: #ef4444; color: white; display: flex; align-items: center; justify-content: flex-end; padding-right: 1.25rem; font-weight: bold; border-radius: 1.5rem; z-index: 1; cursor: pointer; opacity: 0; transition: opacity 0.2s ease; }

.platform-title { cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.global-stats-table thead { background-color: var(--color-table-header-bg); color: var(--color-text-secondary); border-bottom: 1px solid var(--color-border); }
.global-stats-table tbody tr { border-bottom: 1px solid var(--color-border); transition: background-color 0.2s; }
.global-stats-table tbody tr:hover { background-color: var(--color-table-header-bg); }

.used { opacity: 0.8; }
.coupon-value { cursor: pointer; transition: all 0.2s; }
.coupon-value.invalid { cursor: not-allowed; }
.coupon-value:not(.invalid):hover { transform: scale(1.05); }
.coupon-value.striked { text-decoration: line-through; opacity: 0.8; }

.chart-container { position: relative; height: 300px; width: 100%; }
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; vertical-align: middle; }
md-outlined-select, md-outlined-text-field { width: 100%; min-width: 0; }
md-select-option { --md-menu-item-one-line-container-height: 32px; white-space: nowrap; }
md-select-option::part(label-text) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
md-dialog { --md-dialog-container-color: var(--color-surface); }
.platform-color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.theme-dot { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s; }
.theme-dot.selected { border-color: var(--theme-color-primary); transform: scale(1.1); }
md-filled-tonal-button .material-symbols-outlined, md-filled-button .material-symbols-outlined { line-height: 0.7; }

.skeleton-loader { background-color: var(--color-border); border-radius: 0.25rem; animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.global-stats-table tbody tr { background-color: rgba(255, 255, 255, 0.5); backdrop-filter: blur(8px); }
.global-stats-table th.sticky-col { position: sticky; left: 0; background-color: var(--color-table-header-bg); z-index: 20; box-shadow: 1px 0 0 var(--color-border); }
.global-stats-table td.sticky-col { position: sticky; left: 0; background-color: var(--color-surface); z-index: 10; box-shadow: 1px 0 0 var(--color-border); font-weight: 700; }
html.dark .global-stats-table td.sticky-col { background-color: var(--color-table-header-bg); }

.app-toast { pointer-events: auto; animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.app-toast.fade-out { animation: toastFadeOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes toastSlideIn { from { transform: translateY(-150%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastFadeOut { to { transform: translateY(-150%); opacity: 0; } }

.platform-chip { touch-action: manipulation; user-select: none; -webkit-user-select: none; }