/* =========================================
   1. 基礎重置與 iOS 風格設定
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    /* 點擊時不要有奇怪的藍色閃爍 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #1c1c1e;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* =========================================
   2. 登入與註冊畫面 (iOS 質感設計)
   ========================================= */
#login-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* 讓整個表單在手機螢幕上垂直置中 */
    padding: 20px;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.login-form {
    width: 100%;
}

.login-form input {
    width: 100%;
    padding: 16px;
    margin-bottom: 16px;
    background-color: #f2f2f7;
    /* iOS 輸入框經典灰 */
    border: 1px solid transparent;
    /* 預留邊框位置避免 focus 時跳動 */
    border-radius: 12px;
    font-size: 16px;
    /* 防止 iOS Safari 點擊時自動放大畫面 */
    color: #1c1c1e;
    outline: none;
    transition: all 0.2s ease;
}

.login-form input:focus {
    border: 1px solid #007AFF;
    /* 點擊時出現 iOS 經典藍色邊框 */
    background-color: #ffffff;
}

.login-form input::placeholder {
    color: #8e8e93;
}

.login-form button {
    width: 100%;
    padding: 16px;
    background-color: #1c1c1e;
    /* 呼應整體字體顏色的深色按鈕 */
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.login-form button:active {
    opacity: 0.7;
    /* 點擊時的回饋感 */
}

/* =========================================
   3. 頂部導航 (App Header)
   ========================================= */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.9);
    /* 微微透明感 */
    backdrop-filter: blur(10px);
    /* iOS 毛玻璃特效 */
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #f2f2f7;
    /* 淡淡的底線分隔 */
}

.header-actions {
    display: flex;
    gap: 16px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #1c1c1e;
    cursor: pointer;
}

.logout-btn {
    background: none;
    border: none;
    color: #FF3B30;
    /* iOS 警告紅 */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* =========================================
   4. 主要內容區 (Cards & Typography)
   ========================================= */
#app-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
}

/* 大分類標題 (如：蝦品) */
.category-title {
    font-size: 28px;
    font-weight: 800;
    margin: 10px 0 20px 0;
}

/* 小分類標題 (如：鞋子、衣服) */
.subcategory-title {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: #333;
}

/* 預覽卡片設計 */
.link-card {
    background-color: #e5e5ea;
    /* 淺灰色背景 */
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    padding-right: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.card-source {
    font-size: 12px;
    color: #8e8e93;
}

.card-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-color: #d1d1d6;
    /* 圖片載入前的佔位色 */
    object-fit: cover;
}

/* =========================================
   5. 底部工具列 (Footer)
   ========================================= */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 30px 24px 30px;
    /* 底部留白給 iPhone 的橫條 */
    background: #f9f9f9;
    border-top: 1px solid #e5e5ea;
}

.edit-btn {
    background-color: #f2f2f7;
    border: none;
    border-radius: 12px;
    padding: 10px;
    font-size: 18px;
}

/* =========================================
   6. 彈出視窗 (Modal)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    /* iOS 毛玻璃背景 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
    /* 簡單的滑入動畫 */
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: #f2f2f7;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 12px;
    color: #8e8e93;
    cursor: pointer;
}

.add-form input,
.add-form select {
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
    background-color: #f2f2f7;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
}

/* 讓 select 下拉選單更有質感 */
.add-form select {
    appearance: none;
    color: #1c1c1e;
    cursor: pointer;
}

.add-form button.submit-btn {
    width: 100%;
    padding: 16px;
    background-color: #007AFF;
    /* iOS 預設藍色 */
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.add-form button.submit-btn:active {
    opacity: 0.8;
}

/* =========================================
   7. 頂部按鈕統一風格 (Header Buttons)
   ========================================= */
.header-actions {
    display: flex;
    gap: 12px;
    /* 按鈕之間的間距 */
    align-items: center;
}

.header-btn {
    padding: 6px 16px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    /* 統一的圓角 */
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: transparent;
    /* 背景透明 */
}

/* 「新增」按鈕的樣式 (藍色系) */
.primary-btn {
    color: #007AFF;
    border: 1px solid #007AFF;
    /* 藍色外框 */
}

.primary-btn:active {
    background-color: #007AFF;
    color: #ffffff;
    /* 點擊時反白 */
}

/* 「登出」按鈕的樣式 (紅色系) */
.danger-btn {
    color: #FF3B30;
    border: 1px solid #FF3B30;
    /* 紅色外框 */
}

.danger-btn:active {
    background-color: #FF3B30;
    color: #ffffff;
    /* 點擊時反白 */
}

/* =========================================
   8. 左滑刪除特效 (終極精準打擊版)
   ========================================= */
.swipe-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
    border-radius: 16px;
    margin-bottom: 12px;
    background-color: transparent;
    gap: 0 !important;
    /* 確保中間無縫隙 */
}

.swipe-container::-webkit-scrollbar {
    display: none;
}

/* 🎯 狙擊左側卡片 */
.swipe-container a.swipe-content.link-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    box-sizing: border-box;
    margin: 0 !important;
    border-radius: 16px 0 0 16px !important;
    -webkit-user-drag: none;
}

/* 🎯 狙擊右側外框 */
.swipe-container .swipe-actions {
    flex: 0 0 80px;
    scroll-snap-align: end;
    display: flex;
    align-items: stretch;
    margin: 0 !important;
    padding: 0 !important;
}

/* 🎯 狙擊右側按鈕 */
.swipe-container .swipe-actions button {
    background-color: #FF3B30;
    color: white;
    border: none;
    width: 100%;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin: 0 !important;
    border-radius: 0 16px 16px 0 !important;
    transition: opacity 0.2s;
}

.swipe-container .swipe-actions button:active {
    opacity: 0.7;
}

/* =========================================
   9. 分類管理清單樣式
   ========================================= */
.edit-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f2f2f7;
}

.edit-list-item:last-child {
    border-bottom: none;
}

.edit-item-name {
    font-size: 16px;
    font-weight: 600;
    color: #1c1c1e;
}

.sub-edit-list {
    margin-left: 20px;
    padding-left: 15px;
    border-left: 2px solid #e5e5ea;
    margin-top: 10px;
    margin-bottom: 20px;
}

.sub-edit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.sub-item-name {
    font-size: 15px;
    color: #333;
}

.action-btns button {
    background: none;
    border: none;
    font-size: 14px;
    margin-left: 12px;
    cursor: pointer;
}

.edit-action-btn {
    color: #007AFF;
}

.delete-action-btn {
    color: #FF3B30;
}

/* =========================================
   10. 手風琴折疊介面 (Accordion) & 標籤
   ========================================= */
.accordion-header {
    width: 100%;
    text-align: left;
    background-color: #f2f2f7;
    /* iOS 經典灰底 */
    padding: 18px 20px;
    font-size: 20px;
    font-weight: 700;
    border: none;
    border-radius: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #1c1c1e;
    transition: background-color 0.2s, transform 0.1s;
}

.accordion-header:active {
    background-color: #e5e5ea;
    transform: scale(0.98);
    /* 點擊時微縮的物理回饋 */
}

.accordion-content {
    display: none;
    /* 預設隱藏，點擊才展開 */
    padding: 4px 0 16px 0;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.arrow-icon {
    font-size: 14px;
    color: #8e8e93;
    transition: transform 0.3s ease;
    /* 箭頭旋轉動畫 */
}

/* 小分類的精緻小標籤 */
.sub-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #007AFF;
    background-color: #e5f1ff;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
}

/* =========================================
   11. 小分類橫向篩選列 (Filter Chips)
   ========================================= */
.filter-chips-container {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 4px 16px 16px 16px;
    scrollbar-width: none;
    /* 隱藏 Firefox 捲軸 */
    -ms-overflow-style: none;
    /* 隱藏 IE 捲軸 */
}

.filter-chips-container::-webkit-scrollbar {
    display: none;
    /* 隱藏 Chrome/Safari 捲軸 */
}

.filter-chip {
    white-space: nowrap;
    /* 文字不換行 */
    padding: 6px 14px;
    background-color: #f2f2f7;
    color: #8e8e93;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 被選中時的樣式 (深色反白) */
.filter-chip.active {
    background-color: #1c1c1e;
    color: #ffffff;
}

/* 包裝卡片的容器，用來做篩選動畫過渡 */
.category-cards-wrapper {
    padding: 0 16px;
    /* 將卡片的左右間距移到這裡統一管理 */
}

/* ================= iOS 備忘錄風格卡片 ================= */

/* 卡片主體排版 */
.memo-style-card {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    /* 移除超連結底線 */
    padding: 12px 16px;
    background-color: #e5e5ea;
    /* 備忘錄經典淺灰色底 */
    border-radius: 12px;
    color: #1c1c1e;
}

/* 左側文字區塊：自動佔滿剩餘空間 */
.card-text-area {
    flex: 1;
    overflow: hidden;
    padding-right: 12px;
    /* 與右邊圖片保持距離 */
}

/* 標題：粗體黑字、超出範圍變點點點 */
.card-text-area .card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 來源：灰色小字 */
.card-text-area .card-source {
    font-size: 13px;
    color: #8e8e93;
}

/* 右側縮圖區塊 */
.card-image-area {
    flex-shrink: 0;
    /* 防止圖片被擠壓 */
}

/* 圖片樣式：正方形、圓角、裁切適應 */
.card-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    /* 讓長方形圖片完美裁切成正方形 */
    display: block;
    background-color: #ffffff;
}

/* 預設圖示 (抓不到圖片時使用) */
.fallback-thumbnail {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #d1d1d6;
    color: #8e8e93;
    font-size: 24px;
}

/* ================= 現代化行動端佈局 (漢堡選單 + FAB) ================= */

/* 頂部排版優化 */
.header-right-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workspace-card {
    background: #f2f2f7;
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}

.modern-select {
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #1c1c1e;
    outline: none;
    cursor: pointer;
}

/* 漢堡按鈕樣式 */
.hamburger-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #1c1c1e;
    cursor: pointer;
    padding: 4px 8px;
    transition: opacity 0.2s;
}
.hamburger-btn:hover {
    opacity: 0.6;
}

/* --- 側邊隱藏選單本體 --- */
.side-menu {
    position: fixed;
    top: 0;
    right: -280px; /* 預設躲在右邊螢幕外面 */
    width: 280px;
    height: 100%;
    background: #ffffff;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 2000; /* 確保在最上層 */
    transition: right 0.3s ease; /* 核心魔法：滑入滑出的流暢動畫 */
    display: flex;
    flex-direction: column;
}

/* 當啟用時，右邊距歸零，選單就會滑進來 */
.side-menu.active {
    right: 0;
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5ea;
}

.close-menu-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    color: #8e8e93;
    cursor: pointer;
}

.side-menu-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 選單內按鈕美化 */
.menu-item-btn {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    border: none;
    background: #f2f2f7;
    color: #1c1c1e;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.menu-item-btn:hover {
    background: #e5e5ea;
}
.menu-item-btn.logout-btn {
    background: #ffe5e5;
    color: #ff3b30;
}
.menu-item-btn.logout-btn:hover {
    background: #ffd1d1;
}

/* 背景遮罩 */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    display: none; /* 預設隱藏 */
    opacity: 0;
    transition: opacity 0.3s ease;
}
.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* --- 右下角懸浮按鈕 (FAB) --- */
.floating-action-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background-color: #007aff;
    color: white;
    border: none;
    border-radius: 50%; /* 完美的圓形 */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4); /* 漂亮的藍色發光陰影 */
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s;
}
.floating-action-btn:hover {
    background-color: #005bb5;
    transform: scale(1.05); /* 滑鼠懸停時微放大 */
}
.floating-action-btn:active {
    transform: scale(0.95); /* 點擊時微縮小，增加按鈕回饋感 */
}