/* ==========================================================================
   add-panel.css - 新增面板專屬 UI 樣式 (膠囊本人 Hero 展開版 - 防滾動絲滑微調版)
   ========================================================================== */

   .add-panel-container {
    display: flex;
    flex-direction: column;
    gap: 12px; 
    padding: 10px 0;
    transition: gap 0.4s var(--apple-spring);
}

/* 當容器內有人展開時，將按鈕間距歸零，讓消失的按鈕徹底不佔空間 */
.add-panel-container.has-expanded {
    gap: 0; 
}

/* =========================================
   🟢 膠囊本人 (完美繼承原本的狀態)
   ========================================= */
.add-menu-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    
    /* 點開前保持本來的狀態：999px 完美膠囊外觀與底色 */
    background: rgba(120, 120, 128, 0.13);
    border-radius: 999px; 
    overflow: hidden;
    
    max-height: 1000px;
    opacity: 1;
    transform: scale(1);
    
    /* ✨ 修正 1：把變形動畫改為平滑減速 (cubic-bezier)，拔除彈簧感，解決用力過猛的拉扯問題 */
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                border-radius 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.3s ease,
                opacity 0.3s ease, 
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                margin 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    will-change: max-height, opacity, transform, border-radius;
}

/* 將原本的 Hover 與 Active 微縮放效果加在外層膠囊上，保持本來的手感 */
@media (any-hover: hover) {
    .add-menu-item:not(.is-expanded):hover {
        background: rgba(120, 120, 128, 0.12);
        transform: scale(1.02);
    }
}

.add-menu-item:not(.is-expanded):active {
    transform: scale(0.96) !important;
    background: rgba(120, 120, 128, 0.16);
}

/* ✨ 展開後：膠囊本人變形成大面板 */
.add-menu-item.is-expanded {
    /* ✨ 修正 2：拔除多餘的 background 變色，只保留圓角的平滑收斂 */
    border-radius: 32px; 
}

/* 🛑 終極消滅魔法：當有人展開時，把「不是展開的膠囊」徹底隱藏並縮小！ */
.add-panel-container.has-expanded .add-menu-item:not(.is-expanded) {
    max-height: 0;
    opacity: 0;
    margin: 0;
    transform: scale(0.95) translateY(-10px);
    pointer-events: none;
}

/* =========================================
   🟢 可點擊的頭部區域 (原本的按鈕)
   ========================================= */
.add-menu-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    
    background: transparent; 
    border: none;
    padding: 18px 24px; 
    cursor: pointer;
    z-index: 2; 
}

.add-menu-text {
    text-align: left;
}

.add-menu-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

/* =========================================
   🟢 右側箭頭圖示 (Chevron)
   ========================================= */
   .add-menu-chevron {
    /* ✨ 淺色模式：很深的灰色 (確保在白底上非常清晰) */
    color: rgba(60, 60, 67, 0.6); 
    display: flex;
    align-items: center;
    /* 箭頭旋轉與顏色的平滑過渡設定 */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
}

/* 展開時箭頭轉 180 度，變成向上 */
.add-menu-item.is-expanded .add-menu-chevron {
    transform: rotate(180deg);
}

@media (prefers-color-scheme: dark) {
    .add-menu-chevron {
        /* ✨ 深色模式：很白的灰色 (確保在黑底上非常清晰) */
        color: rgba(235, 235, 245, 0.6); 
    }
}

/* =========================================
   🟢 展開內容區 (CSS Grid 動態高度魔法)
   ========================================= */
.add-menu-content-wrapper {
    display: grid;
    grid-template-rows: 0fr; 
    /* ✨ 修正 1：展開動畫也改為平滑減速 */
    transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.add-menu-item.is-expanded .add-menu-content-wrapper {
    grid-template-rows: 1fr;
}

.add-menu-content {
    overflow: hidden;
}

.add-menu-inner {
    opacity: 0;
    transform: translateY(-15px);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    height: 64.5vh; 
    max-height: 600px; 
    min-height: 250px; 
    
    /* ✨ 徹底鎖死：拔除 auto，改為 hidden！手機開啟這個視窗時禁止任何頁面滑動！ */
    overflow: hidden; 
    
    background: transparent; 
    margin-top: 0;
    border-radius: 0;
    padding: 0 24px 24px 24px; 
}

/* 展開時內容浮現 */
.add-menu-item.is-expanded .add-menu-inner {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================
   🟢 管理面板專屬卡片膠囊 (Management Capsules)
   ========================================= */
   .manage-card-capsule {
    display: flex;
    align-items: center;
    /* ✨ 改為 flex-start，讓所有內容乖乖從最左邊開始排列 */
    justify-content: flex-start; 
    gap: 16px; /* ✨ 控制「左側圖示區」與「右側文字」之間的完美距離 */
    padding: 16px 20px;
    border-radius: 999px; 
    font-size: 1.05rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.manage-card-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
    letter-spacing: 0.5px;
    text-align: left;
}

/* =========================================
   🟢 管理面板專屬卡片膠囊 (Management Capsules)
   ========================================= */
   .manage-card-capsule {
    display: flex;
    align-items: center;
    /* ✨ 讓內容平均分佈，配合 flex:1 會自動變成左中右排版 */
    justify-content: space-between; 
    gap: 16px; /* 控制三個元素之間的間距 */
    padding: 16px 20px;
    border-radius: 999px; 
    font-size: 1.05rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

/* 中間的名稱：設定 flex: 1 讓它自動把左右兩邊的圖示推到最邊緣 */
.manage-card-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
    letter-spacing: 0.5px;
    text-align: left;
}

/* ✨ 隱藏/顯示按鈕 (眼睛 - 左側) */
.manage-card-visibility {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.manage-card-visibility:active {
    transform: scale(0.85);
    opacity: 0.7;
}

/* ✨ 拖拉抓手 (三條線 - 右側) */
.manage-card-drag {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; 
    cursor: grab;
    touch-action: none; 
}

.manage-card-drag:active {
    cursor: grabbing;
}

/* ✨ 幽靈浮空狀態 (Drag Ghost) */
.manage-card-capsule.is-dragging {
    pointer-events: none; /* 讓滑鼠雷射光能穿透它打到底下的卡片 */
    z-index: 99999;
    box-shadow: 0 15px 35px rgba(0,0,0,0.25);
    transition: none; /* 拖拉時絕對跟手，不要延遲 */
}

/* ✨ 佔位虛線格 (Placeholder) */
.manage-card-placeholder {
    border-radius: 999px;
    background: rgba(120, 120, 128, 0.1);
    border: 2px dashed rgba(120, 120, 128, 0.3);
    margin: 0;
}

/* =========================================
   🟢 管理面板：隱藏區與分隔線 (完美對稱版)
   ========================================= */
   .manage-separator {
    height: 2px;
    background: rgba(120, 120, 128, 0.15);
    /* ✨ 拔除上下的 margin，只保留左右縮進 10px */
    margin: 0 10px; 
    border-radius: 2px;
}

.manage-hidden-area {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    /* ✨ 拔除上下的 padding，只保留左右縮進 10px */
    padding: 0 10px; 
}

/* 隱藏後的小膠囊 */
.manage-hidden-capsule {
    height: 56px; /* 與大膠囊高度一致 */
    border-radius: 999px; /* 維持圓角 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    user-select: none;
}

.manage-hidden-capsule:active {
    transform: scale(0.9);
    opacity: 0.8;
}

/* ✨ 一鍵刪除隱藏卡片的空心按鈕 */
.delete-all-hidden-btn {
    background: transparent !important;
    border: 2px solid rgba(120, 120, 128, 0.25) !important;
    color: rgba(120, 120, 128, 0.6) !important;
    box-shadow: none !important;
    box-sizing: border-box;
}

/* 點擊時會有微紅色的警告回饋感 */
.delete-all-hidden-btn:active {
    background: rgba(255, 59, 48, 0.1) !important;
    border-color: rgba(255, 59, 48, 0.4) !important;
    color: #FF3B30 !important;
}

/* 上方留下的空位虛線格 */
.empty-slot {
    height: 56px;
    box-sizing: border-box;
    border: 2px dashed rgba(120, 120, 128, 0.25);
    background: rgba(120, 120, 128, 0.05);
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(120, 120, 128, 0.5);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0 !important;
}