/* =========================================
   1. 變數與基礎設定 (Variables & Base)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
    /* 提取主要色彩為變數，方便未來統一維護 */
    --bg-main: #FAFAFA;
    --text-main: #1e293b;
    --text-muted: #94a3b8;
    --accent-color: #1e293b;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

/* =========================================
   2. 表單與輸入框優化 (Forms)
   ========================================= */
/* 隱藏數字輸入框的上下箭頭（讓匯率輸入更美觀） */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    /* 補強 Firefox 瀏覽器支援 */
}

/* =========================================
   3. 佈局與區塊設定 (Layout & Sections)
   ========================================= */
/* 確保標題的捲動邊距足夠，避開頂部的 Sticky Header */
#shopping {
    scroll-margin-top: 110px;
}

/* 為購物清單的圖片容器設定固定寬高比，預留空間避免載入時畫面跳動 */
#shopping-list-container .w-12.h-12 {
    aspect-ratio: 1 / 1;
    background-color: #f3f4f6;
    /* 載入前的佔位背景色 */
}

/* =========================================
   4. 元件樣式 (Components)
   ========================================= */

/* --- 分帳頁頂部頁籤切換 --- */
.tab-active {
    border-bottom: 2px solid var(--accent-color);
    color: var(--accent-color);
    font-weight: 700;
}

.tab-inactive {
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}

/* --- 藥丸形導航按鈕樣式 --- */
.btn-pill-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* 邊框設定 */
    border: 1px solid var(--accent-color);

    /* 💡 加入這兩行：清除 iOS/Android 原生按鈕樣式，強制顯示自訂邊框 */
    -webkit-appearance: none;
    appearance: none;

    color: var(--accent-color);
    background-color: transparent;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 10px;
    margin-left: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    vertical-align: middle;
    white-space: nowrap;
}

.btn-pill-nav:active {
    transform: translateY(0);
}

/* =========================================
   5. 購物清單分類標籤 (Categories)
   取代原有的 Tailwind @apply，轉為純 CSS 獨立渲染
   ========================================= */
.category-muji {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fee2e2;
}

.category-drugstore {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.category-donki {
    background-color: #fefce8;
    color: #a16207;
    border: 1px solid #fef9c3;
}

.category-3coins {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #dcfce7;
}

.category-fashion {
    background-color: #faf5ff;
    color: #7e22ce;
    border: 1px solid #f3e8ff;
}

.category-convenience {
    background-color: #eef2ff;
    color: #4338ca;
    border: 1px solid #e0e7ff;
}

.category-souvenir {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}

.category-other {
    background-color: #f9fafb;
    color: #374151;
    border: 1px solid #f3f4f6;
}

/* =========================================
   6. 通用工具與動畫 (Utilities)
   ========================================= */
/* 手風琴與分帳明細展開動畫 */
.transition-max-height {
    transition: max-height 0.4s ease-in-out;
}

/* 隱藏原生捲軸（用於購物分類橫向滑動） */
.no-scrollbar {
    -ms-overflow-style: none;
    /* IE 與 Edge */
    scrollbar-width: none;
    /* Firefox */
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* 文字裁切（收據備註預覽限制顯示兩行） */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================================
   7. 響應式設定 (Media Queries)
   ========================================= */
@media (max-width: 640px) {

    /* 讓 Modal 在手機上以底部抽屜形式呈現 */
    #expense-modal>div,
    #add-modal>div {
        border-radius: 1.5rem 1.5rem 0 0;
    }
}

/* --- main.css --- */

/* 優先級小圓圈基本樣式 */
.priority-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid #cbd5e1;
    transition: all 0.2s;
    cursor: pointer;
}

.priority-dot.must-buy {
    background-color: #ef4444;
    border-color: #ef4444;
}

/* 紅色: 必買 */
.priority-dot.looking {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* 藍色: 看看 */

/* 長按彈出的自訂選單 */
#context-menu {
    position: fixed;
    z-index: 1000;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 160px;
    display: none;
    font-family: 'Noto Serif TC', serif;
}

.menu-item {
    padding: 10px 16px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.menu-item:hover {
    background-color: #f8fafc;
}

.menu-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

.shopping-card {
    /* 💡 核心修正：防止 iOS 彈出系統選單與文字選取 */
    -webkit-touch-callout: none;
    /* 禁用 iOS 長按彈出的系統選單 */
    -webkit-user-select: none;
    /* 禁用 iOS 文字選取 */
    user-select: none;
    /* 禁用標準文字選取 */

    /* 保持原本的樣式 */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* 移除點擊時的藍色高亮 */
}

/* 也可以在滑過時加一點點陰影變化 */
.shopping-card:hover {
    border-color: #cbd5e1;
    background-color: #fcfcfc;
}

/* main.css */

/* 隱藏捲動條但保留功能 */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 行程卡片的微調 */
.snap-start {
    scroll-snap-align: start;
}

/* 時間軸圓點與線條動態感 */
.itinerary-dot-active {
    border-color: #1e293b !important;
    background-color: #1e293b !important;
}

/* 營業時間的小標籤 */
.business-hour-tag {
    font-size: 9px;
    letter-spacing: 0.025em;
    font-weight: 600;
}