/* ==========================================================================
   style.css - iOS 全毛玻璃透明風 (Glassmorphism) + 四角懸浮 UX 升級版
   ========================================================================== */

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, "Microsoft JhengHei", sans-serif;
    background-color: #f3f4f6; 
    background: linear-gradient(135deg, #f3f4f6 0%, #eef2f7 100%);
    min-height: 100vh;
    margin: 0; padding: 0; color: #111827;
    overscroll-behavior-y: contain; 
    -webkit-tap-highlight-color: transparent; 
}

/* 確保 iOS 輸入框字體不小於 16px，防止強制自動放大 */
.field input, .field select,
.form-group input, .form-group select,
.search-input-fab {
    font-size: 16px !important;
}

/* ==========================================
   1. 登入版面介面
   ========================================== */
.login-container {
    display: flex; justify-content: center; align-items: center; 
    min-height: 100vh; 
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%); 
    padding: 20px; box-sizing: border-box; 
}
.login-box {
    background: rgba(255, 255, 255, 0.4); 
    backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 15px 35px rgba(31, 38, 135, 0.08); 
    padding: 40px; border-radius: 24px;
    width: 100%; max-width: 400px; box-sizing: border-box;
}
.login-box h2 { margin-top: 0; margin-bottom: 24px; color: #111827; text-align: center; font-weight: 700; }
.field { margin-bottom: 20px; }
.field label { display: block; margin-bottom: 8px; font-weight: 600; color: #374151; font-size: 14px; }

.field input, .field select {
    width: 100%; 
    height: 48px; 
    padding: 0 16px; 
    border-radius: 12px;
    box-sizing: border-box; 
    font-family: inherit;
    background: rgba(255, 255, 255, 0.5); 
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #111827; 
    transition: all 0.2s ease; 
}
.field input:focus, .field select:focus { 
    outline: none; 
    background: rgba(255, 255, 255, 0.8);
    border-color: #8b5cf6; 
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15); 
}

.login-box button {
    width: 100%; padding: 14px; background-color: #8b5cf6; color: white;
    border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; 
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); transition: all 0.2s ease;
    -webkit-user-select: none; user-select: none;
}
.login-box button:hover { background-color: #7c3aed; transform: translateY(-1px); }
.login-box button:active { transform: translateY(0); }

/* ==========================================
   2. 後台主畫面排版 (標題列重新整理)
   ========================================== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 0 20px 40px 20px; }

.sticky-area {
    position: sticky; top: 0; 
    background: rgba(243, 244, 246, 0.7); 
    backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); 
    border-bottom: 1px solid rgba(255, 255, 255, 0.4); 
    z-index: 100; 
    margin: 0 -20px 24px -20px;
    padding: 20px 20px 15px 20px;
}

.header-bar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
}

.header-bar h2 { 
    margin: 0; 
    color: #111827; 
    font-weight: 700; 
    text-align: left; 
    font-size: 24px;
    flex: 1 1 0%; 
    min-width: 0; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; 
}

.action-btn { 
    color: white; 
    border: none; 
    padding: 10px 20px; 
    border-radius: 25px; 
    cursor: pointer; 
    font-weight: 600; 
    transition: background 0.2s, transform 0.1s; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    -webkit-user-select: none; user-select: none;
    font-size: 14px;
    font-family: inherit;
    white-space: nowrap; 
}
.action-btn:active { transform: scale(0.96); } 

.user-btn { background-color: #3b82f6; }
.user-btn:hover { background-color: #2563eb; }
.logout-btn { background-color: #ef4444; }
.logout-btn:hover { background-color: #dc2626; }

/* ==========================================
   3. 物品卡片 Grid
   ========================================== */
.name-card-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.card {
    background: rgba(255, 255, 255, 0.45); 
    backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: 0 8px 24px rgba(31, 38, 135, 0.04);
    border-radius: 20px; padding: 24px; display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s ease; 
    opacity: 0; animation: fadeUp 0.5s ease-out forwards; 
}
.card:hover { 
    transform: translateY(-6px); background: rgba(255, 255, 255, 0.6); 
    border: 1px solid rgba(255, 255, 255, 0.8); box-shadow: 0 16px 32px rgba(31, 38, 135, 0.08); 
}
.card-avatar-wrapper { display: flex; justify-content: center; margin-bottom: 20px; }
.card-avatar { width: 140px; height: 140px; border-radius: 16px; object-fit: cover; border: 3px solid rgba(255, 255, 255, 0.6); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.card-avatar-placeholder { width: 140px; height: 140px; border-radius: 16px; background: rgba(255, 255, 255, 0.4); color: #8b5cf6; font-size: 48px; display: flex; justify-content: center; align-items: center; border: 3px solid rgba(255, 255, 255, 0.6); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.card-name { font-size: 19px; font-weight: 700; color: #111827; margin-bottom: 12px; text-align: center; word-break: break-all; }
.card-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.badge { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-category { background-color: rgba(224, 231, 255, 0.6); color: #4338ca; border: 1px solid rgba(224, 231, 255, 0.4); } 
.badge-status { background-color: rgba(220, 252, 231, 0.6); color: #15803d; border: 1px solid rgba(220, 252, 231, 0.4); }   
.card-notes { background: rgba(255, 255, 255, 0.35); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #4b5563; margin-bottom: 15px; border-left: 3px solid rgba(139, 92, 246, 0.5); }
.card-actions { margin-top: auto; padding-top: 10px; display: flex; justify-content: center; gap: 12px; }
.card-actions button { flex: 1; padding: 10px 0; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.2s; -webkit-user-select: none; user-select: none; }
.btn-edit { background: rgba(0, 0, 0, 0.04); color: #4b5563; }
.btn-edit:hover { background: rgba(0, 0, 0, 0.08); color: #111827; }
.btn-delete { background: rgba(239, 68, 68, 0.08); color: #ef4444; }
.btn-delete:hover { background: rgba(239, 68, 68, 0.15); color: #dc2626; }

/* ==========================================
   4. 通用表單彈窗 (Modal)
   ========================================== */
.forms { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s; padding: 20px; box-sizing: border-box; }
.forms.show { opacity: 1; visibility: visible; pointer-events: auto; }
.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.25); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.form-box { position: relative; background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1); width: 100%; max-width: 450px; padding: 35px; border-radius: 24px; z-index: 2001; transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15); box-sizing: border-box; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.forms.show .form-box { transform: scale(1); }
.form-box h3 { margin-top: 0; text-align: center; font-size: 22px; color: #111827; margin-bottom: 24px; font-weight: 700; }
.form-avatar-preview-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; }
.form-avatar-preview { width: 100px; height: 100px; border-radius: 16px; object-fit: cover; background-color: rgba(255, 255, 255, 0.4); border: 2px dashed rgba(0, 0, 0, 0.15); padding: 4px; cursor: pointer; transition: all 0.2s; }
.form-avatar-preview:hover { border-color: #8b5cf6; background-color: rgba(255, 255, 255, 0.7); }
.file-input-label { margin-top: 12px; font-size: 13px; color: #4b5563; background: rgba(0,0,0,0.04); padding: 6px 14px; border-radius: 20px; cursor: pointer; font-weight: 600; transition: background 0.2s; -webkit-user-select: none; user-select: none; }
.file-input-label:hover { background: rgba(0,0,0,0.08); }
.hidden-file-input { display: none !important; } 

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #4b5563; font-size: 14px; }
.form-group input, .form-group select { 
    width: 100%; height: 48px; padding: 0 16px; border-radius: 12px; box-sizing: border-box; font-family: inherit; transition: all 0.2s; background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(255, 255, 255, 0.5); color: #111827; 
}
.form-group input:focus, .form-group select:focus { outline: none; background: rgba(255, 255, 255, 0.8); border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

.form-btn-group { display: flex; justify-content: space-between; margin-top: 30px; gap: 12px; }
.form-btn-group button { flex: 1; padding: 12px; border: none; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 15px; transition: background 0.2s; -webkit-user-select: none; user-select: none; }
.btn-cancel { background: rgba(0,0,0,0.04); color: #4b5563; }
.btn-cancel:hover { background: rgba(0,0,0,0.08); }
.btn-save { background-color: #8b5cf6; color: white; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2); }
.btn-save:hover:not(:disabled) { background-color: #7c3aed; }
.btn-save:disabled { background-color: #d1d5db; cursor: not-allowed; box-shadow: none; } 

/* ==========================================
   5. 四角懸浮掣 (FABs)
   ========================================== */
.addButton {
    position: fixed; bottom: 40px; left: 40px; 
    width: 64px; height: 64px; border-radius: 50%; border: none;
    font-size: 32px; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 999; 
    -webkit-user-select: none; user-select: none;
    background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6); color: #8b5cf6; box-shadow: 0 8px 24px rgba(31, 38, 135, 0.08); 
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.addButton:hover { background: rgba(255, 255, 255, 0.6); transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 28px rgba(139, 92, 246, 0.15); }
.addButton:active { transform: scale(0.98) translateY(0); }

.trash-fab {
    position: fixed; bottom: 40px; right: 40px; 
    width: 64px; height: 64px; border-radius: 50%; border: none; font-size: 28px; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 999; 
    -webkit-user-select: none; user-select: none;
    background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6); color: #8b5cf6; box-shadow: 0 8px 24px rgba(31, 38, 135, 0.08); 
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.trash-fab:hover { background: rgba(255, 255, 255, 0.6); transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 28px rgba(31, 38, 135, 0.12); }
.trash-fab.active { background: rgba(239, 68, 68, 0.45); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); border: 1px solid rgba(255, 255, 255, 0.4); color: white; box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25); }
.trash-fab.active:hover { background: rgba(239, 68, 68, 0.6); box-shadow: 0 12px 28px rgba(239, 68, 68, 0.35); }

.search-fab-top-right { position: fixed; top: 105px; right: 40px; display: flex; align-items: center; gap: 12px; z-index: 1000; transition: all 0.4s ease; }

.search-fab {
    position: relative; 
    z-index: 2;         
    width: 64px; height: 64px; border-radius: 50%; border: none; font-size: 24px; cursor: pointer; display: flex; justify-content: center; align-items: center; flex-shrink: 0; -webkit-user-select: none; user-select: none;
    background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6); color: #8b5cf6; box-shadow: 0 8px 24px rgba(31, 38, 135, 0.08); 
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.search-fab:hover { background: rgba(255, 255, 255, 0.6); transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 28px rgba(139, 92, 246, 0.15); }
.search-wrapper-hidden { width: 0px; opacity: 0; overflow: hidden; transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1); }
.search-wrapper-hidden.show { width: 440px; opacity: 1; }
.search-input-fab {
    height: 64px; padding: 0 24px; border-radius: 32px; box-sizing: border-box; width: 100%; outline: none;
    background: rgba(255, 255, 255, 0.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6); color: #111827; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05); transition: all 0.3s ease;
}
.search-input-fab:focus { background: rgba(255, 255, 255, 0.8); border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

.notification-fab-container { position: fixed; top: 105px; left: 40px; z-index: 1000; }
.notification-fab {
    width: 64px; height: 64px; border-radius: 50%; border: none; font-size: 24px; cursor: pointer; display: flex; justify-content: center; align-items: center; -webkit-user-select: none; user-select: none;
    background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: 0 8px 24px rgba(31, 38, 135, 0.08); 
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1); position: relative;
}
.notification-fab:hover { background: rgba(255, 255, 255, 0.6); transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 28px rgba(139, 92, 246, 0.15); }
.notification-fab:active { transform: scale(0.98) translateY(0); }
.badge-count { position: absolute; top: 0px; right: 0px; background: #ef4444; color: white; font-size: 11px; font-weight: bold; padding: 2px 6px; border-radius: 12px; border: 2px solid #f3f4f6; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.3); }
.pending-blink {
    background: #ef4444 !important; color: #ffffff !important; border: 1px solid #ef4444;      
    padding: 2px 8px !important; border-radius: 10px;
    animation: pulse-ring 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1); 
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.notification-panel-left {
    position: absolute; top: 75px; left: 0; width: 280px; padding: 20px; border-radius: 20px;
    background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(25px) saturate(180%); -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8); box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    opacity: 0; visibility: hidden; transform: translateY(-15px) translateX(-10px); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: none; box-sizing: border-box;
}
.notification-panel-left.show { opacity: 1; visibility: visible; transform: translateY(0) translateX(0); pointer-events: auto; }
.notification-panel-left h4 { margin: 0 0 15px 0; font-size: 16px; color: #111827; border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: 10px; font-weight: 700; }
.stat-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: #4b5563; }
.stat-count { background: rgba(139, 92, 246, 0.15); color: #6d28d9; padding: 4px 10px; border-radius: 12px; font-size: 13px; }
.stat-total { border-top: 1px solid rgba(0,0,0,0.1); padding-top: 15px; margin-top: 15px; }
.stat-total .stat-count { background: rgba(16, 185, 129, 0.15); color: #047857; }

/* ==========================================
   6. 清空畫面
   ========================================== */
.no-data-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; text-align: center; background: transparent; grid-column: 1 / -1; }
.no-data-icon { font-size: 64px; margin-bottom: 20px; animation: float 3s ease-in-out infinite; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.05)); }
.no-data-title { font-size: 20px; font-weight: 700; color: #374151; margin: 0 0 10px 0; }
.no-data-subtitle { font-size: 15px; color: #6b7280; margin: 0; }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0px); } }

/* ==========================================
   7. 手機版最佳化 (RWD) 效能改善
   ========================================== */
@media (max-width: 768px) {
    .sticky-area { 
        margin: 0 -15px 20px -15px; 
        padding: 15px 15px 10px 15px; 
    }
    .header-bar { gap: 8px; }
    .header-bar h2 { font-size: 18px; }
    .header-actions { gap: 6px; }
    .action-btn { padding: 8px 12px; font-size: 13px; }
    
    .addButton { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 24px; width: 56px; height: 56px; font-size: 28px; }
    .trash-fab { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: 24px; width: 56px; height: 56px; font-size: 24px; }
    
    .search-fab-top-right { top: 75px; right: 16px; left: auto; justify-content: flex-end; }
    .search-fab { width: 56px; height: 56px; font-size: 18px; }
    
    .search-wrapper-hidden.show { position: fixed; top: 75px; right: 16px; left: auto; width: calc(100vw - 32px); z-index: 1; padding-right: 68px; box-sizing: border-box;}
    .search-input-fab { height: 56px; padding: 0 18px; border-radius: 28px; }
    
    .notification-fab-container { top: 75px; left: 16px; }
    .notification-fab { width: 56px; height: 56px; font-size: 20px; }
    .notification-panel-left { top: 65px; left: 0; width: 250px; }
    
    .main-content { padding: 15px 15px calc(100px + env(safe-area-inset-bottom, 0px)) 15px; } 
    .card-avatar { width: 100px; height: 100px; }
    .card-avatar-placeholder { width: 100px; height: 100px; font-size: 32px; }
    .form-box { padding: 25px 20px; border-radius: 20px; } 
    
    .card, .form-box, .login-box, .notification-panel-left, .addButton, .trash-fab, .search-fab, .notification-fab {
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(4px) saturate(100%);
        -webkit-backdrop-filter: blur(4px) saturate(100%);
    }
}

/* ==========================================
   8. UX 互動細節
   ========================================== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.toast { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px) saturate(160%); -webkit-backdrop-filter: blur(10px) saturate(160%); border: 1px solid rgba(255, 255, 255, 0.8); border-left: 5px solid #8b5cf6; padding: 14px 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); color: #111827; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: slideInToast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.toast.success { border-left-color: #10b981; } 
.toast.error { border-left-color: #ef4444; }   
.toast.info { border-left-color: #3b82f6; }    
.toast.fade-out { animation: fadeOutToast 0.3s ease forwards; }

@keyframes slideInToast { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutToast { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

.confirm-box { text-align: center; max-width: 350px; padding: 30px; }
.confirm-icon { font-size: 48px; margin-bottom: 15px; animation: scaleUp 0.3s ease; }
.confirm-message { font-size: 18px !important; margin-bottom: 24px !important; line-height: 1.5; white-space: pre-line; }
.confirm-btn-group button { border-radius: 12px; } 

@keyframes scaleUp { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after { content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 3px solid rgba(255,255,255,0.3); border-top-color: #ffffff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.required::after { content: " *"; color: #ef4444; font-weight: bold; margin-left: 4px; }