/* 載入字體 */
@import url('./fonts/noto-sans-tc.css');

:root {
  /* Light Mode Colors */
  --bg-light: #f8fafc;
  --bg-hover-light: #f1f5f9;
  --bg-secondary-light: #f1f5f9;
  --bg-muted-light: #f1f5f9;
  --card-light: #ffffff;
  --card-bg-light: #ffffff;
  --input-bg-light: #f1f5f9;
  --border-light: #e2e8f0;
  --border-color-light: #e2e8f0;
  --text-light: #1e293b;
  --text-primary-light: #1e293b;
  --text-secondary-light: #64748b;
  --text-color-light: #1e293b;
  --text-muted-light: #64748b;
  --text-muted-hover-light: #475569; /* 更深的灰色 */
  --accent-light: #3b82f6;
  --accent-hover-light: #1d4ed8; /* 更深的藍色 */
  --accent-bg-light: rgba(59, 130, 246, 0.1);
  --primary-color-light: #3b82f6;
  --primary-light: rgba(59, 130, 246, 0.1);
  --error-color-light: #ef4444;
  --hover-bg-light: #f1f5f9;
  --success-light: #10b981;
  --warning-light: #f59e0b;
  --danger-light: #ef4444;
  --danger-hover-light: #b91c1c; /* 更深的紅色 */
  --danger-bg-light: rgba(220, 38, 38, 0.1);
  --shadow-light: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  
  /* Dark Mode Colors */
  --bg-dark: #0f172a;
  --bg-hover-dark: #1e293b;
  --bg-secondary-dark: #1e293b;
  --bg-muted-dark: #1a2332;
  --card-dark: #1e293b;
  --card-bg-dark: #1e293b;
  --input-bg-dark: #334155;
  --border-dark: #334155;
  --border-color-dark: #475569;
  --text-dark: #f1f5f9;
  --text-primary-dark: #f1f5f9;
  --text-secondary-dark: #94a3b8;
  --text-color-dark: #f1f5f9;
  --text-muted-dark: #94a3b8;
  --text-muted-hover-dark: #64748b; /* 更深的灰色 */
  --accent-dark: #60a5fa;
  --accent-hover-dark: #3b82f6; /* 更深的藍色 */
  --accent-bg-dark: rgba(96, 165, 250, 0.2);
  --primary-color-dark: #60a5fa;
  --primary-dark: rgba(96, 165, 250, 0.2);
  --error-color-dark: #f87171;
  --hover-bg-dark: #1e293b;
  --success-dark: #34d399;
  --warning-dark: #fbbf24;
  --danger-dark: #f87171;
  --danger-hover-dark: #dc2626; /* 更深的紅色 */
  --danger-bg-dark: rgba(248, 113, 113, 0.2);
  --shadow-dark: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  
  /* Common Colors */
  --bg: var(--bg-light);
  --bg-hover: var(--bg-hover-light);
  --bg-secondary: var(--bg-secondary-light);
  --bg-muted: var(--bg-muted-light);
  --card: var(--card-light);
  --card-bg: var(--card-bg-light);
  --input-bg: var(--input-bg-light);
  --border: var(--border-light);
  --border-color: var(--border-color-light);
  --text: var(--text-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --text-color: var(--text-color-light);
  --text-muted: var(--text-muted-light);
  --text-muted-hover: var(--text-muted-hover-light);
  --accent: var(--accent-light);
  --accent-hover: var(--accent-hover-light);
  --accent-bg: var(--accent-bg-light);
  --primary-color: var(--primary-color-light);
  --primary: var(--primary-light);
  --error-color: var(--error-color-light);
  --hover-bg: var(--hover-bg-light);
  --success: var(--success-light);
  --warning: var(--warning-light);
  --danger: var(--danger-light);
  --danger-hover: var(--danger-hover-light);
  --danger-bg: var(--danger-bg-light);
  --shadow: var(--shadow-light);
  
  /* Spacing & Typography */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font-sans: 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  
  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
  --bg: var(--bg-dark);
  --bg-hover: var(--bg-hover-dark);
  --bg-secondary: var(--bg-secondary-dark);
  --bg-muted: var(--bg-muted-dark);
  --card: var(--card-dark);
  --card-bg: var(--card-bg-dark);
  --input-bg: var(--input-bg-dark);
  --border: var(--border-dark);
  --border-color: var(--border-color-dark);
  --text: var(--text-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --text-color: var(--text-color-dark);
  --text-muted: var(--text-muted-dark);
  --text-muted-hover: var(--text-muted-hover-dark);
  --accent: var(--accent-dark);
  --accent-hover: var(--accent-hover-dark);
  --accent-bg: var(--accent-bg-dark);
  --primary-color: var(--primary-color-dark);
  --primary: var(--primary-dark);
  --error-color: var(--error-color-dark);
  --hover-bg: var(--hover-bg-dark);
  --success: var(--success-dark);
  --warning: var(--warning-dark);
  --danger: var(--danger-dark);
  --danger-hover: var(--danger-hover-dark);
  --danger-bg: var(--danger-bg-dark);
  --shadow: var(--shadow-dark);
}

/* Auto-detect system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--bg-dark);
    --bg-hover: var(--bg-hover-dark);
    --bg-secondary: var(--bg-secondary-dark);
    --bg-muted: var(--bg-muted-dark);
    --card: var(--card-dark);
    --card-bg: var(--card-bg-dark);
    --input-bg: var(--input-bg-dark);
    --border: var(--border-dark);
    --border-color: var(--border-color-dark);
    --text: var(--text-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --text-color: var(--text-color-dark);
    --text-muted: var(--text-muted-dark);
    --text-muted-hover: var(--text-muted-hover-dark);
    --accent: var(--accent-dark);
    --accent-hover: var(--accent-hover-dark);
    --accent-bg: var(--accent-bg-dark);
    --primary-color: var(--primary-color-dark);
    --primary: var(--primary-dark);
    --error-color: var(--error-color-dark);
    --hover-bg: var(--hover-bg-dark);
    --success: var(--success-dark);
    --warning: var(--warning-dark);
    --danger: var(--danger-dark);
    --danger-hover: var(--danger-hover-dark);
    --danger-bg: var(--danger-bg-dark);
    --shadow: var(--shadow-dark);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Top Navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10002;
  box-shadow: var(--shadow);
}

/* 供應商管理頁：移除進場動畫，與其他頁一致 */
body.page-vendors * {
  animation: none !important;
}

.nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.nav-links button {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
  white-space: nowrap;
}

/* 主題切換按鈕樣式 - 已移至導航樣式模組 */

/* 隱藏但可被輔助工具讀取的文字 */
.sr-only{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

/* 響應式導航列 */
@media (max-width: 720px) {
  .top-nav {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    position: relative;
  }
  
  .nav-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .nav-links button {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  /* 主題切換按鈕樣式已移至導航樣式模組 */
}

/* 超小螢幕適配 */
@media (max-width: 480px) {
  .top-nav {
    padding: 12px;
  }
  
  .nav-links {
    gap: 4px;
  }
  
  .nav-links button {
    padding: 5px 10px;
    font-size: 12px;
  }
  
  /* 主題切換按鈕樣式已移至導航樣式模組 */
}

.header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 0px;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.025em;
}

/* 舊的 header-controls 和 admin-panel 樣式已移除，改用 top-nav */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header .btn {
  flex-shrink: 0;
}

.card-body {
  padding-top: 0;
}

.card:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.card h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 20px 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* 防止 grid 子項因預設 min-width:auto 造成內容溢出、跨欄重疊 */
.form-grid > * { min-width: 0; }

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 500;
  gap: 8px;
  color: var(--text);
}

/* 修正包含 checkbox 的 label 為水平排列 */
.form-grid label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: var(--transition);
  font-family: var(--font-sans);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}
.actions{grid-column:1/-1;display:flex;gap:12px;flex-wrap:wrap}
button{padding:10px 16px;border-radius:var(--radius);border:2px solid var(--border);background:var(--bg);color:var(--text);cursor:pointer;transition:var(--transition)}

/* 圖示按鈕樣式（覆蓋全域 button padding） */
.theme-toggle,
.logout-btn,
.admin-toggle,
.mobile-menu-toggle,
.mobile-menu-close {
    padding: 8px !important;
    border: none !important;
    background: transparent !important;
}
button:hover{border-color:var(--accent);color:var(--accent)}
button.primary{background:var(--accent);border-color:var(--accent);color:#fff}
button.primary:hover{background:var(--accent-hover);border-color:var(--accent-hover)}
button.secondary{background:transparent}
button.danger{background:var(--danger);border-color:var(--danger);color:#fff}
button.hidden{display:none}
.table-wrapper{position:relative;overflow:auto;border-radius:var(--radius);border:1px solid var(--border);box-shadow:var(--shadow)}

/* 表格控制項樣式 */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.sort-controls select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.sort-controls select:hover {
  border-color: var(--accent);
}

.sort-controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
table{width:100%;border-collapse:collapse;background:var(--card)}
th,td{padding:12px 14px;border-bottom:1px solid var(--border);font-size:14px;vertical-align:top}
th{text-align:left;background:linear-gradient(to bottom, rgba(0,0,0,0.02), rgba(0,0,0,0));color:var(--text-muted);font-weight:600}

/* 確保表格最後一行有底線 */
tbody tr:last-child td {
    border-bottom: 1px solid var(--border);
}

/* 當有載入提示或空狀態時，表格容器需要最小高度 */
.table-wrapper:has(.loading-indicator),
.table-wrapper:has(.empty-state) {
    min-height: 300px;
}

/* 表格操作按鈕對齊 */
td.actions {
    vertical-align: middle;
    text-align: center;
}

/* 商品列表手機響應式優化 - 卡片式布局 */
@media (max-width: 768px) {
    /* 隱藏表格標題 */
    #product-table thead {
        display: none;
    }
    
    /* 將表格改為塊級元素 */
    #product-table,
    #product-table tbody,
    #product-table tr,
    #product-table td {
        display: block;
        width: 100%;
    }
    
    /* 表格行改為卡片樣式 */
    #product-table tbody tr {
        display: flex;
        flex-direction: column;
        padding: 16px;
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--card);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    #product-table tbody tr:last-child {
        margin-bottom: 0;
    }
    
    /* 移除表格邊框 */
    #product-table tbody tr td {
        border: none;
        padding: 8px 0;
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }
    
    /* 縮圖欄位 */
    #product-table tbody tr td.product-thumb-cell {
        justify-content: center;
        padding: 0 0 12px 0;
    }
    
    #product-table tbody tr td.product-thumb-cell img {
        width: 80px !important;
        height: 80px !important;
    }
    
    /* 使用 data-label 顯示標籤 */
    #product-table tbody tr td:not(.product-thumb-cell):not(.product-actions-cell)::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        min-width: 100px;
        flex-shrink: 0;
        font-size: 13px;
    }
    
    /* 商品名稱特殊處理 - 確保橫向顯示 */
    #product-table tbody tr td.product-name-cell {
        flex-direction: row;
        align-items: flex-start;
        word-break: break-word;
        white-space: normal;
    }
    
    #product-table tbody tr td.product-name-cell::before {
        min-width: 80px;
    }
    
    /* 操作按鈕區域 */
    #product-table tbody tr td.product-actions-cell {
        justify-content: flex-start;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
        margin-top: 8px;
    }
    
    #product-table tbody tr td.product-actions-cell::before {
        content: '';
        display: none;
    }
    
    #product-table tbody tr td.product-actions-cell button {
        flex: 1;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* 確保文字內容正常顯示 */
    #product-table tbody tr td:not(.product-thumb-cell):not(.product-actions-cell) {
        color: var(--text);
        font-size: 14px;
        line-height: 1.5;
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
    }
    
    /* 商品名稱確保橫向顯示 */
    #product-table tbody tr td.product-name-cell {
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
        white-space: normal !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* 確保所有欄位內容正常換行 */
    #product-table tbody tr td:not(.product-thumb-cell):not(.product-actions-cell) {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* 移除表格容器的滾動 */
    .table-wrapper {
        overflow: visible;
    }
    
    /* 確保表格不會超出容器 */
    #product-table {
        max-width: 100%;
    }
}

td.actions button {
    margin: 0 4px;
    padding: 6px 12px;
    font-size: 12px;
}
.search-bar{display:flex;gap:8px;margin-bottom:12px}
#search-input{flex:1;min-width:0}

/* 專案事項搜尋過濾區塊 */
.search-filter-container {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-group {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 0;
  align-items: center;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 300px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input-wrapper #searchInput {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
}

.search-input-wrapper #searchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: none;
}

.clear-search-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.search-input-wrapper #searchInput:not(:placeholder-shown) + .clear-search-btn {
  display: block;
}

.status-filter {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-width: 140px;
  cursor: pointer;
  transition: var(--transition);
}

.status-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.results-count {
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* 專案關鍵字樣式 */
.project-keywords {
  margin: 8px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tag {
  display: inline-block;
  padding: 4px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  transition: var(--transition);
}

.keyword-tag:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* Dialog Modal Styles */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 900px;
  width: 95%;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  background: var(--card);
  position: fixed;
  inset: 0;
  margin: auto;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text);
  z-index: 9999;
}

/* 確保 dialog 作為定位上下文，讓載入指示器可以正確覆蓋 */
dialog:has(.product-modal-loading) {
  position: relative;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .6);
  z-index: 9998;
}

/* 全螢幕檔案預覽（Lightbox） */
dialog.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none; /* 預設隱藏，避免關閉後仍顯示在背後 */
  align-items: center;
  justify-content: center;
  z-index: 3000; /* 高於 dialog backdrop 與頂部導航 */
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: rgba(0,0,0,0.88) !important;
}

dialog.viewer-overlay[open] { display: flex; }

.viewer-overlay .viewer-content {
  position: relative;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-overlay .viewer-content img,
.viewer-overlay .viewer-content iframe {
  max-width: 95vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border: none;
  box-shadow: none;
  background: transparent;
}

/* PDF 以 iframe 滿版顯示 */
.viewer-overlay .viewer-content iframe {
  width: 95vw;
  height: 90vh;
}

.viewer-overlay .viewer-close {
  /* 移除 position: absolute，讓 Grid 布局生效 */
  /* position: absolute; */
  /* top: 16px; */
  /* right: 20px; */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-overlay, .viewer-overlay .viewer-content { cursor: zoom-out; }
.viewer-overlay .viewer-content img, .viewer-overlay .viewer-content iframe { cursor: default; }

/* 行動裝置：開啟任一 dialog 時鎖定背景滾動，避免跳到頁首 */
@media (max-width: 720px) {
  html:has(dialog[open]) {
    overflow: hidden;
  }
}

dialog h3, dialog h4 {
  color: var(--text);
  margin: 0 0 16px 0;
}

dialog form {
  padding: 20px;
}

/* 客戶選擇 Modal 內容邊界間距 */
#customer-select-modal > .form-grid {
  padding: 20px;
}

/* 編輯表單的特殊佈局 */
.edit-form-grid {
  grid-template-columns: 1fr 1fr !important;
  max-width: none !important;
}

.edit-form-grid label[style*="grid-column: 1/-1"] {
  grid-column: 1 / -1 !important;
}

/* 強制編輯表單中的前兩個 label 並排顯示 */
.edit-form-grid label:nth-child(3),
.edit-form-grid label:nth-child(4) {
  grid-column: auto !important;
  min-width: 0 !important;
}

/* 覆蓋 .form-grid 的 minmax 規則 */
.edit-form-grid > label {
  min-width: 0 !important;
  max-width: none !important;
}

/* 更強制的選擇器，直接針對編輯表單 */
#customer-modal #customer-edit-form.edit-form-grid {
  grid-template-columns: 1fr 1fr !important;
  display: grid !important;
}

/* 強制標題佔據整行 */
#customer-modal #customer-edit-form.edit-form-grid > h3 {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  margin-bottom: 20px !important;
}

#customer-modal #customer-edit-form.edit-form-grid > label:nth-child(3),
#customer-modal #customer-edit-form.edit-form-grid > label:nth-child(4) {
  grid-column: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

#customer-modal #customer-edit-form.edit-form-grid > label[style*="grid-column: 1/-1"] {
  grid-column: 1 / -1 !important;
}

/* 編輯供應商表單的特殊佈局 */
#vendor-modal #vendor-edit-form.edit-vendor-form-grid {
  grid-template-columns: 1fr 1fr !important;
  display: grid !important;
}

/* 強制標題佔據整行 */
#vendor-modal #vendor-edit-form.edit-vendor-form-grid > h3 {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  margin-bottom: 20px !important;
}
#vendor-modal #vendor-edit-form.edit-vendor-form-grid > label:nth-child(3),
#vendor-modal #vendor-edit-form.edit-vendor-form-grid > label:nth-child(4) {
  grid-column: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

#vendor-modal #vendor-edit-form.edit-vendor-form-grid > label[style*="grid-column: 1/-1"] {
  grid-column: 1 / -1 !important;
}

/* 編輯商品類別表單的特殊佈局 */
#category-modal #category-edit-form.edit-category-form-grid {
  grid-template-columns: 1fr 1fr !important;
  display: grid !important;
}

/* 強制標題佔據整行 */
#category-modal #category-edit-form.edit-category-form-grid > h3 {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  margin-bottom: 20px !important;
}

#category-modal #category-edit-form.edit-category-form-grid > label:nth-child(3),
#category-modal #category-edit-form.edit-category-form-grid > label:nth-child(4) {
  grid-column: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

#category-modal #category-edit-form.edit-category-form-grid > label[style*="grid-column: 1/-1"] {
  grid-column: 1 / -1 !important;
}

/* Modal Styles - 與 modal.js 保持一致 */
.modal {
  background: var(--modal-bg, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  /* 預設不顯示，開啟時以 .show 控制 */
  display: none;
}

.modal.show {
  transform: scale(1);
  opacity: 1;
  display: block;
}

/* 模態框滾動條樣式 */
.modal::-webkit-scrollbar {
  width: 8px;
}

.modal::-webkit-scrollbar-track {
  background: var(--bg-muted, #f1f5f9);
  border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb {
  background: var(--text-muted, #94a3b8);
  border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #64748b);
}

/* Firefox 滾動條樣式 */
.modal {
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted, #94a3b8) var(--bg-muted, #f1f5f9);
}

.modal-content {
  border-radius: var(--radius);
  width: 100%;
  min-height: 100%;
  position: relative;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* 模態框表單樣式 */
.modal-body .form-group {
  margin-bottom: 1.5rem;
}

.modal-body .form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.modal-body .form-label i {
  margin-right: 0.5rem;
  color: var(--accent);
}

.modal-body .form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.modal-body .form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.modal-body .form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

/* 專案檔案預覽模態框 */
.file-preview-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.95) !important;
  z-index: 99999 !important;
  display: none !important;
  flex-direction: column !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
}

.file-preview-modal.show {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 確保模態框覆蓋所有元素 */
.file-preview-modal * {
  z-index: inherit !important;
}

/* 強制覆蓋導航列 */
.file-preview-modal {
  z-index: 999999 !important;
}

.preview-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 1rem 2rem !important;
  background: rgba(0, 0, 0, 0.9) !important;
  color: white !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  min-height: 60px !important;
  position: relative !important;
  z-index: 100000 !important;
}

.preview-nav {
  display: flex !important;
  gap: 1rem !important;
  align-items: center !important;
  position: relative !important;
  z-index: 100001 !important;
}

.preview-title-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  min-width: 200px !important;
}

.preview-description {
  font-size: 0.875rem !important;
  color: rgba(255, 255, 255, 0.7) !important;
  font-style: italic !important;
  margin-bottom: 0.25rem !important;
  max-width: 300px !important;
  word-wrap: break-word !important;
  line-height: 1.3 !important;
}

.preview-nav button {
  color: white !important;
  background: rgba(0, 123, 255, 0.8) !important;
  border: 2px solid white !important;
  border-radius: 50% !important;
  padding: 12px !important;
  cursor: pointer !important;
  font-size: 20px !important;
  font-weight: bold !important;
  position: relative !important;
  z-index: 100002 !important;
  width: 48px !important;
  height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
}

.preview-nav button:hover {
  background: rgba(0, 123, 255, 1) !important;
  transform: scale(1.1) !important;
}

.preview-nav button.disabled {
  background: rgba(128, 128, 128, 0.5) !important;
  border-color: rgba(128, 128, 128, 0.7) !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

.preview-nav button.disabled:hover {
  background: rgba(128, 128, 128, 0.5) !important;
  transform: none !important;
}

.preview-content {
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  position: relative !important;
  z-index: 100000 !important;
  overflow: hidden !important;
}

.preview-controls {
  display: flex !important;
  gap: 0.5rem !important;
  align-items: center !important;
  position: relative !important;
  z-index: 100001 !important;
}

.preview-controls button {
  color: white !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 50% !important;
  padding: 12px !important;
  cursor: pointer !important;
  font-size: 18px !important;
  font-weight: bold !important;
  position: relative !important;
  z-index: 100002 !important;
  width: 48px !important;
  height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
}

.preview-controls button:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  transform: scale(1.1) !important;
}

.preview-media {
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.preview-pdf {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

/* ==================== 投票功能樣式 ==================== */

/* 投票列表 */
.vote-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--card-bg);
  transition: all 0.3s ease;
}

.vote-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.vote-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.vote-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon.edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.btn-icon.edit:hover {
  color: var(--accent);
  background: var(--accent-bg, rgba(59, 130, 246, 0.1));
}

.btn-icon.move-up,
.btn-icon.move-down {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.btn-icon.move-up:hover,
.btn-icon.move-down:hover {
  color: var(--accent);
  background: var(--accent-bg, rgba(59, 130, 246, 0.1));
}

.option-image-item {
  position: relative;
  display: inline-block;
  margin: 0.25rem;
}

.option-image-item .option-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--border);
}

.option-image-item .btn-icon.delete {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger);
  color: white;
  border: 2px solid var(--bg);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  padding: 0;
}

.option-image-item .btn-icon.delete:hover {
  background: var(--danger-hover, #dc2626);
}

.vote-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.vote-status {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.vote-status.active {
  background: var(--success);
  color: white;
}

.vote-status.closed {
  background: var(--danger);
  color: white;
}

.vote-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.vote-description {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.vote-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* 投票選項 */
.vote-options {
  margin-top: 1rem;
}

.vote-option {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.vote-option:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
}

.vote-option.selected {
  background: var(--primary-light);
  border-color: var(--primary);
}

.vote-option input[type="radio"] {
  margin-right: 0.75rem;
  transform: scale(1.2);
}

.vote-option-content {
  flex: 1;
}

.vote-option-text {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.vote-option-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* 投票結果 */
.vote-results {
  margin-top: 1rem;
}

.vote-results h4 {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: 1.1rem;
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-text {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.result-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.result-images {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.result-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid transparent;
}

.result-thumbnail:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

.result-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  margin-top: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
}

.result-bar {
  flex: 1;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  margin: 0 1rem;
  overflow: hidden;
}

.result-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.result-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-voters {
  margin-top: 0px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 投票建立模態框 */
.vote-modal .modal-content {
  max-width: 700px;
  min-height: 500px;
}

/* 投票模態框標題 */
.vote-modal .modal-header {
  padding: 2rem 2rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--card) 0%, var(--bg-muted) 100%);
}

.vote-modal .modal-title-section {
  flex: 1;
}

.vote-modal .modal-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.vote-modal .modal-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 投票模態框底部 */
.vote-modal .modal-footer {
  padding: 1.5rem 2rem 2rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}

.vote-modal .modal-footer-content {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.vote-modal .modal-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
  justify-content: center;
}

.vote-modal .modal-btn i {
  font-size: 0.8rem;
}

.vote-modal .modal-btn.secondary {
  background: var(--text-muted);
  color: white;
}

.vote-modal .modal-btn.secondary:hover {
  background: var(--text-muted-hover, #94a3b8);
  transform: translateY(-1px);
}

.vote-modal .modal-btn.primary {
  background: var(--accent);
  color: white;
}

.vote-modal .modal-btn.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* 投票表單樣式 */
.vote-form {
  padding: 0;
}

/* 表單區塊 */
.form-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.form-section:last-child {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent);
}

.section-title i {
  color: var(--accent);
  font-size: 1rem;
}

/* 表單行 */
.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  flex: 1;
}

/* 表單標籤 */
.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* AI 自動修飾連結樣式 */
.ai-enhance-link {
  float: right;
  margin-left: auto;
}

/* 在空狀態中的 AI 連結樣式 */
.empty-state .ai-enhance-link {
  float: none;
  margin-left: 0;
}
.ai-enhance-link a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-block;
}

.ai-enhance-link a:hover {
  color: var(--accent-hover);
  background-color: var(--accent-bg);
  text-decoration: none;
}

.form-label i {
  color: var(--accent);
  font-size: 0.8rem;
  width: 14px;
  text-align: center;
}

.required {
  color: var(--danger);
  font-weight: 600;
}

/* 表單控制項 */
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* 選項列表 */
.option-list {
  margin-bottom: 1.5rem;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem;
  margin-bottom: 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  transition: all 0.2s ease;
  position: relative;
}

.option-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.option-item:hover .option-content {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.option-item:last-child {
  margin-bottom: 0;
}

.option-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 8px;
}

.option-text {
  width: 100%;
  padding: 0px;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text);
  transition: all 0.2s ease;
  margin-bottom: 0px;
}

.option-text:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.option-description {
  width: 100%;
  padding: 0px;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text);
  resize: vertical;
  min-height: 40px;
  transition: all 0.2s ease;
  margin-bottom: 0px;
}

.option-description:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.option-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* 圖片拖放區樣式 */
.option-dropzone {
  margin-top: 0px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 0rem 0.75rem;
  background: var(--bg-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.option-dropzone:hover { border-color: var(--accent); }
.option-dropzone.dragover { border-color: var(--accent); background: var(--bg-muted); }
.option-dropzone .dz-instruction { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.option-dropzone .dz-previews { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.option-dropzone .dz-thumb { position: relative; width: 50px; height: 50px; border-radius: 4px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.option-dropzone .dz-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.option-dropzone .dz-thumb .dz-remove { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; border: none; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center; }

/* 投票選項佈局樣式 */
.vote-option-layout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.vote-option-images {
  display: flex;
  flex-direction: row;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.vote-option-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.vote-option-image:hover {
  transform: scale(1.05);
}

.vote-option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vote-option-text {
  font-weight: 500;
  font-size: 1rem;
  color: var(--text);
}

.vote-option-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* 投票列表縮圖樣式 */
.vote-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.vote-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.vote-thumbnail:hover {
  transform: scale(1.1);
}

/* 討論區樣式 */
.discussion-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg);
  transition: box-shadow 0.2s ease;
}

.discussion-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.discussion-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.discussion-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.author-initial {
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.author-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.author-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.author-department {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.discussion-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.time-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.discussion-content {
  color: var(--text);
  line-height: 1.6;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.btn-icon.delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.btn-icon.delete:hover {
  color: var(--danger);
  background: var(--danger-bg, rgba(220, 38, 38, 0.1));
}

/* 討論區模態框樣式 */
.discussion-modal .modal-body {
  padding: 1.5rem;
}

.discussion-modal textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s ease;
}

.discussion-modal textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 59, 130, 246), 0.1);
}

.discussion-modal textarea::placeholder {
  color: var(--text-muted);
}

/* 響應式設計 */
@media (max-width: 768px) {
  .discussion-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .discussion-time {
    align-self: flex-end;
  }
  
  .author-avatar {
    width: 36px;
    height: 36px;
  }
  
  .author-initial {
    font-size: 0.9rem;
  }
}

/* 圖片預覽模態框樣式 */
.image-preview-modal, .vote-image-preview-modal {
  background: rgba(0, 0, 0, 0.8) !important;
  z-index: 20000 !important; /* 確保在其他模態框之上 */
  position: fixed !important; /* 覆蓋基礎 .modal 的 position: relative */
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: none !important; /* 預設隱藏，避免覆蓋整頁 */
  align-items: center !important;
  justify-content: center !important;
  max-width: none !important; /* 覆蓋基礎 .modal 的 max-width */
  max-height: none !important; /* 覆蓋基礎 .modal 的 max-height */
  transform: none !important; /* 覆蓋基礎 .modal 的 transform */
  border-radius: 0 !important; /* 背景不需要圓角 */
  box-shadow: none !important; /* 背景不需要陰影 */
}

.image-preview-modal.show, .vote-image-preview-modal.show {
  display: flex !important; /* 開啟時以 .show 顯示 */
}

.image-preview-modal .modal-content, .vote-image-preview-modal .modal-content {
  background: var(--bg);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
}

.image-preview-modal .modal-header, .vote-image-preview-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.vote-image-preview-modal .preview-title-container {
  flex: 1;
}

.vote-image-preview-modal .preview-counter {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.image-preview-modal .modal-close, .vote-image-preview-modal .modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.5rem;
}

.image-preview-modal .modal-close:hover, .vote-image-preview-modal .modal-close:hover {
  color: var(--text);
}

.image-preview-modal .modal-body, .vote-image-preview-modal .modal-body {
  padding: 1rem;
  text-align: center;
}

.vote-image-preview-modal .preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.vote-image-preview-modal .preview-image-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.vote-image-preview-modal .preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.vote-image-preview-modal .preview-nav {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  color: var(--text);
}

.vote-image-preview-modal .preview-nav:hover:not(.disabled) {
  background: var(--accent);
  color: white;
}

.vote-image-preview-modal .preview-nav.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.vote-image-preview-modal .preview-filename {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* 按鈕圖標樣式 */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-icon.btn-danger:hover {
  background: var(--danger-hover, #dc2626);
  transform: scale(1.05);
}

/* 新增選項區塊 */
.add-option-section {
  background: var(--bg-muted);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1rem; /* 減少左側留白 */
  margin-top: 1rem;
}

/* 減少新增區塊整體左側視覺縮排 */
.add-option-section .form-group,
.add-option-section .add-option-actions {
  margin-left: 0;
  margin-bottom: 0px;
}

.add-option-header {
  margin-bottom: 1rem;
}

.add-option-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.add-option-title i {
  color: var(--accent);
}

.add-option-form {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

/* 新增選項區塊：欄位改為上下排列（所有螢幕尺寸都適用） */
.add-option-form .form-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.add-option-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0px;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .vote-modal .modal-content {
    max-width: 95vw;
    margin: 1rem;
  }
  
  .form-section {
    padding: 1rem;
  }
  
  .form-row {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .option-item {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .option-number {
    align-self: flex-start;
  }
  
  .option-actions {
    align-self: flex-end;
  }
  
  /* 已在全域為 column，這裡保留以確保相容性 */
  .add-option-form .form-row { flex-direction: column; }
}

.vote-form-group {
  margin-bottom: 1rem;
}

.vote-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.vote-form-group input,
.vote-form-group textarea,
.vote-form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.vote-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* 選項管理 */
.option-management {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
}

.option-list {
  margin-bottom: 1rem;
}

.option-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
}

.option-item-content {
  flex: 1;
  margin-right: 0.5rem;
}

.option-item-actions {
  display: flex;
  gap: 0.25rem;
}

.add-option-form .form-group {
  flex: 1;
}

.add-option-form .form-group label {
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.add-option-form .form-group input,
.add-option-form .form-group textarea {
  padding: 0.5rem;
  font-size: 0.8rem;
}

.add-option-form .form-group textarea {
  min-height: 60px;
}

/* 空狀態 */
.vote-empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.vote-empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* 載入狀態 */
.vote-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.vote-loading i {
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .vote-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .vote-meta {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .vote-actions {
    flex-wrap: wrap;
  }
  
  .result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .result-bar {
    width: 100%;
    margin: 0;
  }
  
  .add-option-form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* 響應式設計 */
@media (max-width: 768px) {
  .preview-header {
    padding: 0.5rem 1rem !important;
    min-height: 50px !important;
  }
  
  .preview-nav button,
  .preview-controls button {
    width: 40px !important;
    height: 40px !important;
    padding: 8px !important;
    font-size: 16px !important;
  }
  
  .preview-nav {
    gap: 0.5rem !important;
  }
  
  .preview-title-container {
    min-width: 150px !important;
  }
  
  .preview-description {
    font-size: 0.8rem !important;
    max-width: 200px !important;
  }
}
/* Modal Sections */
.modal-section {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.modal-section h4 {
  color: var(--text);
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  padding-bottom: 0;
}

/* 基本資料標題容器的底線樣式 */
.basic-info-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding-bottom: 8px;
}

/* File Upload Areas */
.drop-area {
  border: 3px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  position: relative;
  background: var(--card);
  margin-bottom: 12px;
}

.drop-area:hover, .drop-area.drag-over {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

.drop-area p {
  margin: 0;
  pointer-events: none;
}

/* Upload Actions */
.upload-actions {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

/* File Lists */
.file-list {
  margin-top: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--card);
  color: var(--text);
}

.file-item .meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.file-item .meta span {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* Progress Bars */
.progress-container {
  width: 100%;
  background-color: var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  height: 20px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%; /* 預設寬度，會被 JavaScript 動態覆蓋 */
  background-color: var(--success);
  border-radius: var(--radius-sm);
  transition: width 0.3s ease-in-out;
}

.progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  line-height: 20px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.input-group{display:flex;gap:8px;align-items:center;width:100%}
.input-group input{flex:1;min-width:0}
.input-group button{white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;min-width:96px;flex-shrink:0}
.vendor-list{max-height:300px;overflow-y:auto;border:1px solid var(--border);border-radius:var(--radius);margin:8px 0;background:var(--bg)}
.vendor-item{padding:12px;border-bottom:1px solid var(--border);cursor:pointer;transition:var(--transition)}
.vendor-item:hover{filter:brightness(1.05)}
.vendor-item:last-child{border-bottom:none}
.breadcrumb{font-size:14px;margin-bottom:8px;color:var(--text-muted)}
.breadcrumb a{color:var(--accent);text-decoration:none}
.breadcrumb a:hover{text-decoration:underline}
/* 模態框關閉按鈕樣式 */
.modal-close {
  position: absolute !important;
  top: 15px !important;
  right: 15px !important;
  width: 30px !important;
  height: 30px !important;
  border: none !important;
  background: var(--danger) !important;
  color: white !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 16px !important;
  font-weight: bold !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 10000 !important;
  transition: all 0.2s ease !important;
}

.modal-close:hover {
  background: var(--danger-dark) !important;
  transform: scale(1.1) !important;
}

.modal-close:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3) !important;
}
/* 重複的 drop-area 樣式已移除，使用上方統一的樣式 */
/* Additional Dark Mode fixes */
dialog label, dialog .modal-section label {
  color: var(--text);
}

dialog input, dialog select, dialog textarea {
  color: var(--text);
  background: var(--card);
  border-color: var(--border);
}

dialog input:readonly {
  background: var(--bg);
  color: var(--text-muted);
}

/* 商品供應商資訊區塊樣式 */
.vendor-info-container {
  margin-top: 16px;
}

.vendor-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.product-vendors-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-height: 60px;
}

/* 供應商列表為空時的提示樣式 */
.product-vendors-list:empty::after {
  content: var(--no-vendors-message, "尚未添加任何供應商");
  display: block;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-style: italic;
}

/* 確保 CSS 變數有預設值 */
:root {
  --no-vendors-message: "尚未添加任何供應商";
  --vendor-search-tip: "💡 提示：點擊項目選擇，Esc 關閉";
}

.vendor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.vendor-item:last-child {
  border-bottom: none;
}

.vendor-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vendor-name {
  font-weight: 600;
  color: var(--text);
}

.vendor-details {
  font-size: 12px;
  color: var(--text-muted);
}

.component-name {
  /* 提升在明亮/暗黑主題下的對比度 */
  background: #2563eb; /* 高對比藍（Light 模式） */
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-block;
  margin-top: 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}

[data-theme="dark"] .component-name {
  background: #1d4ed8; /* 更深藍（Dark 模式） */
  color: #ffffff;
  border: 1px solid #1e3a8a;
  text-shadow: 0 1px 1px rgba(0,0,0,.35);
}

.vendor-actions {
  display: flex;
  gap: 8px;
}

/* 供應商搜尋 Modal 樣式 */
.vendor-search-container {
  padding: 20px;
  max-width: 700px;
  width: min(90vw, 700px);
  margin: 0 auto;
}

.vendor-search-container h3 {
  margin-bottom: 20px;
  text-align: center;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.search-input-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.search-input-container input {
  flex: 1;
  min-width: 0; /* 防止 flex 項目最小寬度限制 */
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
  padding-left: 40px;
}

.search-input-container input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.search-input-container input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.search-input-container button {
  white-space: nowrap;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
}

.search-input-container button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-input-container button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.search-input-container button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.search-info {
  margin-bottom: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

#vendor-count-info {
  background: var(--accent);
  color: white;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: inline-block;
}

/* 效能優化 */
.vendor-search-container {
  padding: 20px;
  max-width: 700px;
  width: 90vw;
  will-change: transform;
  contain: layout style paint;
}

.vendor-search-results {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 20px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  contain: layout style paint;
  will-change: scroll-position;
}

.vendor-search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--card);
  position: relative;
  contain: layout style;
  will-change: transform, background-color;
}

/* 刪除供應商管理頁獨有的進場動畫，統一風格 */

/* 移除延遲動畫，與其他頁面一致 */

.vendor-search-result-item:hover {
  background: var(--bg);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.vendor-search-result-item:last-child {
  border-bottom: none;
}

.vendor-search-result-item:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
}

.vendor-search-result-info {
  flex: 1;
  margin-right: 16px;
}

.vendor-search-result-name {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
}

.vendor-search-result-details {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.vendor-search-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.vendor-search-actions button {
  padding: 12px 24px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
}

.vendor-search-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* 編輯部件 Modal 樣式 */
.edit-component-container {
  padding: 20px;
  max-width: 500px;
  width: min(90vw, 500px);
  margin: 0 auto;
}

.edit-component-container h3 {
  margin-bottom: 20px;
  text-align: center;
}

.edit-component-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Hidden class utility */
.hidden {
  display: none !important;
}

/* 載入狀態樣式 */
.loading-state {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-style: italic;
}

.loading-state::before {
  content: "⏳ ";
  margin-right: 8px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 錯誤狀態樣式 */
.error-state {
  text-align: center;
  padding: 20px;
  color: var(--danger);
  font-style: italic;
}

.error-state::before {
  content: "⚠️ ";
  margin-right: 8px;
}

/* 重試按鈕樣式 */
.retry-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-top: 12px;
}

.retry-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@media (max-width:720px){
  .form-grid{grid-template-columns:1fr}
  .top-nav{flex-direction:column;gap:12px;padding:16px}
  .nav-links{justify-content:center}
}

.vendor-search-result-item button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 60px;
}

.vendor-search-result-item button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.vendor-search-result-item button.primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 自定義滾動條樣式 */
.vendor-search-results::-webkit-scrollbar {
  width: 8px;
}

.vendor-search-results::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 4px;
}

.vendor-search-results::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.vendor-search-results::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox 滾動條樣式 */
.vendor-search-results {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

/* 響應式設計 */
@media (max-width: 768px) {
  .vendor-search-container {
    padding: 16px;
    max-width: 95vw;
    margin: 0 auto;
  }
  
  .search-bar {
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0; /* 防止容器最小寬度限制 */
  }
  
  .search-input-container {
    flex-direction: column;
    gap: 8px;
    min-width: 0; /* 防止容器最小寬度限制 */
  }
  
  .search-input-container input,
  .search-input-container button {
    width: 100%;
    min-width: 0; /* 防止按鈕最小寬度限制 */
    flex-shrink: 0; /* 防止按鈕被壓縮 */
  }
  
  .vendor-search-result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .vendor-search-result-item button.primary {
    align-self: flex-end;
  }
  
  .vendor-search-results {
    max-height: 300px;
  }
  
  .vendor-search-container::after {
    content: var(--vendor-search-tip, "💡 提示：點擊項目選擇，Esc 關閉");
    display: block;
    font-size: 11px;
    margin-top: 12px;
    padding: 6px;
  }
}

@media (max-width: 480px) {
  .vendor-search-container h3 {
    font-size: 18px;
  }
  
  .vendor-search-result-item {
    padding: 12px;
  }
  
  .vendor-search-result-name {
    font-size: 14px;
  }
  
  .vendor-search-result-details {
    font-size: 12px;
  }
  
  .search-input-container input {
    min-width: 0; /* 防止 flex 項目最小寬度限制 */
    padding: 10px 12px;
    font-size: 16px; /* 避免 iOS 縮放 */
  }
  
  .search-input-container button {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .vendor-search-actions button {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .vendor-search-container {
    padding: 12px;
  }
  
  .vendor-search-container h3 {
    font-size: 16px;
    margin-bottom: 16px;
  }
  
  .search-bar {
    gap: 4px;
    min-width: 0; /* 防止容器最小寬度限制 */
  }
  
  .search-input-container {
    gap: 6px;
    min-width: 0; /* 防止容器最小寬度限制 */
  }
  
  .vendor-search-result-item {
    padding: 10px;
  }
  
  .vendor-search-result-name {
    font-size: 13px;
  }
  
  .vendor-search-result-details {
    font-size: 11px;
  }
}

.vendor-search-result-item:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
  background: var(--bg);
}

/* 可訪問性樣式 */
.vendor-search-result-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
  background: var(--bg);
}

/* 高對比度模式支援 */
@media (prefers-contrast: high) {
  .vendor-search-result-item {
    border-width: 2px;
  }
  
  .vendor-search-result-item:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
  }
  
  .vendor-search-result-item:hover .vendor-search-result-name,
  .vendor-search-result-item:hover .vendor-search-result-details {
    color: white;
  }
}

/* 減少動畫模式支援 */
@media (prefers-reduced-motion: reduce) {
  .vendor-search-result-item {
    animation: none;
    transition: none;
  }
  
  .vendor-search-result-item:hover {
    transform: none;
  }
  
  .loading-state::before {
    animation: none;
  }
  
  .vendor-search-result-item button.primary:hover {
    transform: none;
  }
  
  .vendor-search-result-item button.primary:active {
    transform: none;
  }
}

/* 深色模式優化 */
@media (prefers-color-scheme: dark) {
  .vendor-search-container::after {
    background: var(--bg);
    border-color: var(--border);
    opacity: 0.9;
  }
  
  .vendor-search-results {
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
  }
  
  .vendor-search-result-item:not(:last-child)::after {
    background: var(--border);
    opacity: 0.3;
  }
}
/* 工具提示樣式 */
.vendor-search-container::after {
  content: var(--vendor-search-tip, "💡 提示：使用方向鍵 ↑↓ 導航，Enter 選擇，Esc 關閉");
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  opacity: 0.8;
}

/* 列印樣式 */
@media print {
  .vendor-search-container {
    max-width: none;
    width: 100%;
    padding: 0;
    box-shadow: none;
    border: none;
  }
  
  .vendor-search-container h3 {
    color: black;
    border-bottom: 2px solid black;
    padding-bottom: 8px;
  }
  
  .search-input-container,
  .vendor-search-actions,
  .vendor-search-container::after {
    display: none;
  }
  
  .vendor-search-results {
    max-height: none;
    overflow: visible;
    border: none;
    box-shadow: none;
  }
  
  .vendor-search-result-item {
    break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 8px;
    padding: 12px;
    background: white;
    color: black;
  }
  
  .vendor-search-result-item button {
    display: none;
  }
  
  .vendor-search-result-name {
    font-weight: bold;
    color: black;
  }
  
  .vendor-search-result-details {
    color: #666;
  }
  
  #vendor-count-info {
    background: none;
    color: black;
    border: 1px solid #ccc;
    padding: 4px 8px;
  }
}

/* 硬體加速 */
.vendor-search-result-item,
.vendor-search-result-item button.primary,
.search-input-container input,
.search-input-container button {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 主題切換支援 */
[data-theme="light"] .vendor-search-container {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .vendor-search-result-item {
  background: #f9fafb;
  border-color: #e5e7eb;
}

[data-theme="light"] .vendor-search-result-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

[data-theme="dark"] .vendor-search-container {
  background: #1f2937;
  border: 1px solid #374151;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .vendor-search-result-item {
  background: #111827;
  border-color: #374151;
}

[data-theme="dark"] .vendor-search-result-item:hover {
  background: #1f2937;
  border-color: #4b5563;
}

[data-theme="dark"] .vendor-search-result-name {
  color: #f9fafb;
}

[data-theme="dark"] .vendor-search-result-details {
  color: #9ca3af;
}

/* 高對比度主題 */
[data-theme="high-contrast"] .vendor-search-container {
  background: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
}

[data-theme="high-contrast"] .vendor-search-result-item {
  background: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
}

[data-theme="high-contrast"] .vendor-search-result-item:hover {
  background: #ffffff;
  color: #000000;
}

[data-theme="high-contrast"] .vendor-search-result-item:hover .vendor-search-result-name,
[data-theme="high-contrast"] .vendor-search-result-item:hover .vendor-search-result-details {
  color: #000000;
}

/* 
 * 供應商搜尋介面樣式文檔
 * 
 * 這個檔案包含了「選擇供應商」介面的所有樣式定義，包括：
 * 
 * ## 主要組件
 * - .vendor-search-container: 搜尋容器
 * - .search-input-container: 搜尋輸入區域
 * - .vendor-search-results: 搜尋結果列表
 * - .vendor-search-result-item: 單個搜尋結果項目
 * 
 * ## 狀態樣式
 * - .loading-state: 載入狀態
 * - .empty-state: 空結果狀態
 * - .error-state: 錯誤狀態
 * 
 * ## 響應式設計
 * - 768px 以下：垂直佈局，適合平板
 * - 480px 以下：緊湊佈局，適合手機
 * - 360px 以下：最小佈局，適合小螢幕
 * 
 * ## 可訪問性支援
 * - 高對比度模式
 * - 減少動畫模式
 * - 深色模式
 * - 焦點管理
 * 
 * ## 主題支援
 * - light: 明亮主題
 * - dark: 暗黑主題
 * - high-contrast: 高對比度主題
 * 
 * ## 效能優化
 * - CSS containment
 * - 硬體加速
 * - 動畫優化
 * 
 * ## 瀏覽器相容性
 * - 現代瀏覽器：完整支援
 * - 舊版瀏覽器：漸進增強
 * - 列印模式：專門優化
 * 
 * 作者：AI Assistant
 * 版本：2.0.0
 * 更新日期：2024
 */

/* 模組化導航樣式 */
.navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 10002;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 20px;
    height: 60px;
    min-width: 0;
    gap: 10px;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 1.1em;
}

.brand-logo {
    height: 32px;
    width: auto;
    margin-right: 0px;
    filter: var(--logo-filter, none);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
    min-width: 0;
}

/* 下拉選單樣式 */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.nav-dropdown-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 10003;
    margin-top: 4px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-light);
}

.nav-dropdown-item:last-child {
    border-bottom: none;
}

.nav-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.nav-dropdown-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    font-weight: 500;
}

/* 強制暗黑模式下下拉選單樣式 - 解決跨瀏覽器相容性問題 */
[data-theme="dark"] .nav-dropdown-menu {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .nav-dropdown-item {
    color: #f1f5f9 !important;
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .nav-dropdown-item:hover {
    background: #334155 !important;
    color: #60a5fa !important;
}

[data-theme="dark"] .nav-dropdown-item.active {
    background: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

/* 系統偏好暗黑模式下的下拉選單樣式 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .nav-dropdown-menu {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9 !important;
    }
    
    :root:not([data-theme="light"]) .nav-dropdown-item {
        color: #f1f5f9 !important;
        border-bottom-color: #334155 !important;
    }
    
    :root:not([data-theme="light"]) .nav-dropdown-item:hover {
        background: #334155 !important;
        color: #60a5fa !important;
    }
    
    :root:not([data-theme="light"]) .nav-dropdown-item.active {
        background: rgba(96, 165, 250, 0.2) !important;
        color: #60a5fa !important;
    }
}

.nav-link {
    display: inline-block;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text);
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
    white-space: nowrap;
    border: 2px solid transparent;
    background: var(--card);
    font-weight: 500;
}

/* 未啟用的功能按鈕樣式 */
.nav-link:not(.active) {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

/* 未啟用按鈕的 hover 效果 */
.nav-link:not(.active):hover {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* 啟用中的功能按鈕樣式 */
.nav-link.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: 600;
}

/* 啟用中按鈕的 hover 效果 */
.nav-link.active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    min-width: 0;
    justify-content: flex-end;
    margin-left: auto;
}

.user-info {
    display: flex;
    align-items: center;
    font-size: 0.85em;
    /* 確保樣式能被媒體查詢覆蓋 */
    transition: all 0.3s ease;
}

.user-name {
    color: var(--text);
    font-weight: 500;
}

.user-username {
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 400;
}

.user-role {
    color: var(--text-muted);
    font-size: 0.8em;
}


.user-name-link:hover {
    color: var(--accent);
}

/* 用戶頭像容器 */
.user-name-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

.nav-user-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    border: none;
}

.nav-user-avatar img {
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: border-color 0.3s ease;
}

.nav-user-avatar:hover img {
    border-color: var(--accent);
}

.nav-user-avatar .employee-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid var(--border);
    transition: border-color 0.3s ease;
    overflow: hidden;
    background: var(--accent);
}

.nav-user-avatar:hover .employee-initial {
    border-color: var(--accent);
}

/* 推播通知按鈕 */
.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    position: relative !important;
}

.notification-toggle:hover {
    background: var(--accent) !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

.notification-toggle svg {
    width: 18px !important;
    height: 18px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    flex-shrink: 0 !important;
    min-width: 18px !important;
    min-height: 18px !important;
}

/* 推播徽章 */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 12px;
    padding: 0 4px;
    border: 2px solid var(--card);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: notificationPulse 2s infinite;
}

@keyframes notificationPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 推播 Modal */
.notification-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10003;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.notification-modal.show {
    opacity: 1;
    visibility: visible;
}

.notification-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.notification-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1;
    transform: translate(-50%, -48%) scale(0.95);
    transition: all 0.3s ease;
}

.notification-modal.show .notification-modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.notification-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    position: relative;
}

.notification-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.notification-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    position: absolute;
    top: 12px;
    right: 12px;
}

.notification-modal-close:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.notification-modal-close i {
    font-size: 18px;
    color: currentColor;
}

.notification-modal-body {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0;
}

/* 推播通知模態框滾動條樣式 */
.notification-modal-body::-webkit-scrollbar {
    width: 8px;
}

.notification-modal-body::-webkit-scrollbar-track {
    background: var(--bg-muted);
    border-radius: 4px;
}

.notification-modal-body::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.notification-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Firefox 滾動條樣式 */
.notification-modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-muted);
}

/* 推播區塊 */
.notification-section {
    border-bottom: 1px solid var(--border);
}

.notification-section:last-child {
    border-bottom: none;
}

.notification-section-title {
    margin: 0;
    padding: 16px 24px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notification-list {
    padding: 0 0 8px;
}

/* 推播項目 */
.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
    position: relative;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--hover-bg);
}

.notification-item.unread {
    background: var(--accent-bg);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
}

.notification-avatar {
    flex-shrink: 0;
    margin-right: 12px;
}

.notification-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.notification-avatar-initial {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid var(--border);
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.notification-actor {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.notification-message {
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 8px;
    word-break: normal;
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.notification-actions {
    display: flex;
    gap: 8px;
}

.notification-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.notification-link:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* 空狀態 */
.notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.notification-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.notification-empty-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* 推播通知載入中狀態 */
.notification-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.notification-loading p {
    color: var(--text-secondary);
    font-size: 16px;
    margin: 0;
}

/* 推播通知錯誤狀態 */
.notification-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.notification-error i {
    font-size: 48px;
    color: var(--error);
    margin-bottom: 16px;
}

.notification-error p {
    color: var(--text-secondary);
    font-size: 16px;
    margin: 0 0 20px 0;
}

.retry-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .notification-modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px;
    }
    
    .notification-modal-header {
        padding: 16px 20px;
    }
    
    .notification-section-title {
        padding: 12px 20px 6px;
    }
    
    .notification-item {
        padding: 12px 20px;
    }
    
    .notification-empty {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .notification-modal-content {
        width: 92%;
        max-width: 420px;
        min-height: 300px;
        max-height: 88vh;
        border-radius: 12px;
        margin: 16px auto;
        display: flex;
        flex-direction: column;
        align-self: center;
        /* 確保模態框位置穩定 */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -48%) scale(0.95);
        background: var(--card);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    }
    
    .notification-modal.show .notification-modal-content {
        transform: translate(-50%, -50%) scale(1);
    }
    
    .notification-modal-header {
        padding: 16px 20px 12px;
        background: var(--card);
        border-bottom: 2px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 1;
        flex-shrink: 0;
    }
    
    /* 手機版滑動指示器 */
    .notification-modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
    }
    
    .notification-modal-close {
        width: 44px !important;
        height: 44px !important;
        background: var(--accent) !important;
        color: white !important;
        border-radius: 12px !important;
        font-size: 24px !important;
        font-weight: bold !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
        border: 2px solid var(--accent) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .notification-modal-close:hover {
        background: var(--accent-hover) !important;
        transform: scale(1.05) !important;
    }
    
    .notification-modal .notification-modal-close i {
        font-size: 24px !important;
        color: white !important;
        font-weight: 600 !important;
    }
    
    .notification-modal-title {
        font-size: 20px !important;
        font-weight: 700 !important;
    }
    
    .notification-modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 0;
        /* 改善觸控滾動體驗 */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* 防止滾動穿透 */
        touch-action: pan-y;
    }
    
    .notification-section-title {
        padding: 12px 20px 6px;
        font-size: 16px;
        font-weight: 600;
        background: var(--hover-bg);
        border-bottom: 1px solid var(--border);
    }
    
    .notification-item {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border);
    }
    
    .notification-avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    .notification-content {
        margin-left: 12px;
    }
    
    .notification-actor {
        font-size: 16px !important;
        font-weight: 600 !important;
    }
    
    .notification-time {
        font-size: 14px !important;
    }
    
    .notification-message {
        font-size: 15px !important;
        line-height: 1.5 !important;
        margin: 8px 0 !important;
        word-break: normal !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
    
    .notification-link {
        padding: 8px 16px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
    
    .notification-empty {
        padding: 40px 20px;
        text-align: center;
        font-size: 16px;
    }
    
    /* 手機版載入中狀態 */
    .notification-loading {
        padding: 40px 20px !important;
        min-height: 200px !important;
    }
    
    .loading-spinner {
        width: 32px !important;
        height: 32px !important;
        border-width: 2px !important;
    }
    
    .notification-loading p {
        font-size: 14px !important;
        margin-top: 12px !important;
    }
    
    /* 手機版錯誤狀態 */
    .notification-error {
        padding: 40px 20px !important;
        min-height: 200px !important;
    }
    
    .notification-error i {
        font-size: 36px !important;
        margin-bottom: 12px !important;
    }
    
    .notification-error p {
        font-size: 14px !important;
        margin: 0 0 16px 0 !important;
    }
    
    .retry-btn {
        padding: 10px 20px !important;
        font-size: 13px !important;
    }
}

/* 統一按鈕樣式 */
.theme-toggle, .logout-btn, .admin-toggle, .notification-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    min-width: 36px !important;
    min-height: 36px !important;
    /* 確保 hover 效果正常工作 */
    position: relative !important;
    z-index: 1 !important;
}

.theme-toggle:hover, .logout-btn:hover, .admin-toggle:hover, .notification-toggle:hover {
    background: var(--accent) !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

.admin-dropdown {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.admin-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 10002;
    margin-top: 4px;
}

.admin-menu.show {
    display: block;
}

.admin-item {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
    font-size: 14px;
}

.admin-item:last-child {
    border-bottom: none;
}

    .admin-item:hover {
        background: var(--accent);
        color: white;
    }

/* 強制暗黑模式下管理員選單樣式 */
[data-theme="dark"] .admin-menu {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .admin-item {
    color: #f1f5f9 !important;
    border-bottom-color: #334155 !important;
}

[data-theme="dark"] .admin-item:hover {
    background: #334155 !important;
    color: #60a5fa !important;
}

/* 系統偏好暗黑模式下的管理員選單樣式 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .admin-menu {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9 !important;
    }
    
    :root:not([data-theme="light"]) .admin-item {
        color: #f1f5f9 !important;
        border-bottom-color: #334155 !important;
    }
    
    :root:not([data-theme="light"]) .admin-item:hover {
        background: #334155 !important;
        color: #60a5fa !important;
    }
}
    
    /* 漢堡選單按鈕（預設隱藏） */
    .mobile-menu-toggle {
        display: none;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        color: var(--text);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--accent);
        color: white;
    }
    
    .mobile-menu-toggle svg {
        width: 24px;
        height: 24px;
    }
    
    /* 行動選單 */
    .mobile-menu {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--card);
        z-index: 10000;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .mobile-menu.show {
        transform: translateX(0);
    }
    
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid var(--border);
        background: var(--bg);
        position: sticky;
        top: 0;
        z-index: 10002;
    }
    
    .mobile-user-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .mobile-user-name {
        font-weight: 600;
        color: var(--text);
        font-size: 16px;
    }
    
    .mobile-user-username {
        color: var(--text-muted);
        font-size: 14px;
    }
    
    .mobile-menu-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        color: var(--text);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-close:hover {
        background: var(--accent);
        color: white;
    }
    
    .mobile-menu-close svg {
        width: 24px;
        height: 24px;
    }
    
    .mobile-menu-content {
        padding: 20px;
    }
    
    .mobile-nav-item {
        display: block;
        padding: 16px 20px;
        text-decoration: none;
        color: var(--text);
        border-radius: 8px;
        margin-bottom: 8px;
        transition: all 0.3s ease;
        font-size: 16px;
        font-weight: 500;
    }
    
    .mobile-nav-item:hover {
        background: var(--accent);
        color: white;
        transform: translateX(8px);
    }
    
    .mobile-nav-item.active {
        background: var(--accent);
        color: white;
    }
    
    .mobile-menu-divider {
        height: 1px;
        background: var(--border);
        margin: 20px 0;
    }
    
    .mobile-logout {
        color: var(--danger);
        border: 1px solid var(--danger);
    }
    
    .mobile-logout:hover {
        background: var(--danger);
        color: white;
    }

/* 通用按鈕樣式 */
.btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
    background: var(--text-muted);
    color: white !important;
    border-color: var(--text-muted);
}

.btn-secondary:hover {
    background: var(--text-muted-hover, #94a3b8);
    border-color: var(--text-muted-hover, #94a3b8);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover, #dc2626);
    border-color: var(--danger-hover, #dc2626);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-default {
    background: var(--card);
    color: var(--text) !important;
    border-color: var(--border);
}

.btn-default:hover {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
}

/* 現代化通知系統樣式 */
.notification-container {
    position: fixed;
    top: 120px;
    right: 20px;
    z-index: 100000 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.hide {
    transform: translateX(100%);
    opacity: 0;
}

.notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
}

.notification.success::before {
    background: #10b981;
}

.notification.error::before {
    background: #ef4444;
}

.notification.warning::before {
    background: #f59e0b;
}

.notification.info::before {
    background: #3b82f6;
}

.notification-content {
    display: block;
    width: 100%;
}

.notification-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.notification-icon svg {
    width: 100%;
    height: 100%;
}

.notification-message {
    flex: 1;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.notification-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.notification-close:hover {
    background: var(--border);
    color: var(--text);
}

.notification-close svg {
    width: 14px;
    height: 14px;
}

/* 確認對話框樣式 */
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: auto;
}

/* 當確認對話框嵌入在 dialog 內部時，仍需覆蓋其內容層 */
dialog .confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.confirm-dialog-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.confirm-dialog {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.confirm-dialog-overlay.show .confirm-dialog {
    transform: scale(1);
}

.confirm-dialog-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.confirm-dialog-icon {
    width: 24px;
    height: 24px;
    color: #f59e0b;
}

.confirm-dialog-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.confirm-dialog-message {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.confirm-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-dialog-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    user-select: none;
}

.confirm-dialog-btn:hover {
    background: var(--border);
}

.confirm-dialog-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.confirm-dialog-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.confirm-dialog-btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.confirm-dialog-btn.danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .notification-container {
        top: 80px !important;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .notification {
        padding: 14px 16px;
    }
}
/* 確保按鈕圖示在大螢幕下有正確尺寸 */
.theme-toggle svg, .logout-btn svg, .admin-toggle svg, .notification-toggle svg {
    width: 18px !important;
    height: 18px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    flex-shrink: 0 !important;
    min-width: 18px !important;
    min-height: 18px !important;
}

/* 導航響應式設計 */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 10px;
    }
    
    .brand-text {
        display: none !important;
    }
    
    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
        flex-shrink: 1;
        min-width: 0;
    }
    
    /* 確保功能按鈕在小螢幕下能正確縮小 */
    .nav-menu {
        flex-shrink: 1;
        min-width: 0;
        overflow: visible;
    }
}

@media (max-width: 600px) {
    /* 隱藏導航選單 */
    .nav-menu {
        display: none !important;
    }
    
    /* 手機版層狀選單樣式 */
    .mobile-menu-group {
        border-bottom: 1px solid var(--border-light);
    }
    
    .mobile-menu-group:last-child {
        border-bottom: none;
    }
    
    .mobile-menu-group-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: var(--bg);
        color: var(--text);
        font-weight: 500;
        cursor: pointer;
        transition: background 0.2s ease;
        user-select: none;
    }
    
    .mobile-menu-group-header:hover {
        background: var(--bg-hover);
    }
    
    .mobile-submenu-arrow {
        font-size: 14px;
        transition: transform 0.3s ease;
    }
    
    .mobile-submenu-arrow.rotated {
        transform: rotate(180deg);
    }
    
    .mobile-menu-submenu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        background: var(--card);
    }
    
    .mobile-menu-submenu.show {
        max-height: 500px;
    }
    
    .mobile-menu-submenu .mobile-nav-item {
        padding-left: 40px;
        border-bottom: 1px solid var(--border-light);
    }
    
    .mobile-menu-submenu .mobile-nav-item:last-child {
        border-bottom: none;
    }
    
    /* 隱藏用戶資訊和部分工具按鈕 */
    .user-info,
    .admin-dropdown,
    .logout-btn {
        display: none !important;
    }
    
    /* 保留主題切換按鈕 */
    .theme-toggle {
        display: flex !important;
        width: 40px !important;
        height: 40px !important;
        margin-left: auto;
        margin-right: 12px;
    }
    
    .theme-toggle svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* 顯示漢堡選單按鈕 */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* 讓商標靠左對齊 */
    .logo {
        margin-right: auto;
    }
    
    /* 調整導航容器佈局 */
    .nav-container {
        justify-content: flex-start;
        gap: 0;
    }
    
    /* 確保 nav-tools 靠右對齊 */
    .nav-tools {
        min-width: 4px !important;
        margin-left: auto;
        justify-content: flex-end;
    }
}

@media (max-width: 720px) {
    .nav-tools {
        gap: 4px;
        min-width: 120px;
        justify-content: space-between;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    
    .theme-toggle, .logout-btn, .admin-toggle, .language-toggle, .notification-toggle {
        width: 34px !important;
        height: 34px !important;
        flex: 0 0 34px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 34px !important;
        min-height: 34px !important;
    }
    
    .theme-toggle svg, .logout-btn svg, .admin-toggle svg, .language-toggle svg, .notification-toggle svg {
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        min-height: 16px !important;
    }
    
    /* 進一步縮小功能按鈕 */
    .nav-link {
        padding: 5px 8px;
        font-size: 12px;
    }
}

@media (max-width: 560px) {
    /* 緊縮右上角三個按鈕的佈局 */
    .nav-tools {
        gap: 2px;
        min-width: 100px;
        justify-content: space-between;
    }
    
    .theme-toggle, .logout-btn, .admin-toggle, .language-toggle, .notification-toggle {
        width: 30px !important;
        height: 30px !important;
        flex: 0 0 30px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 30px !important;
        min-height: 30px !important;
    }
    
    .theme-toggle svg, .logout-btn svg, .admin-toggle svg, .language-toggle svg, .notification-toggle svg {
        width: 14px !important;
        height: 14px !important;
        min-width: 14px !important;
        min-height: 14px !important;
    }
    
    /* 進一步縮小功能按鈕 */
    .nav-link {
        padding: 4px 6px;
        font-size: 11px;
        margin: 0 1px;
    }
    
    /* 確保導航容器有足夠空間 */
    .nav-container {
        padding: 0 5px;
    }
}

@media (max-width: 480px) {
    .nav-tools {
        gap: 2px;
        min-width: 90px;
        justify-content: space-between;
    }
    
    .theme-toggle, .logout-btn, .admin-toggle, .language-toggle, .notification-toggle {
        width: 28px !important;
        height: 28px !important;
        flex: 0 0 28px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }
    
    .theme-toggle svg, .logout-btn svg, .admin-toggle svg, .language-toggle svg, .notification-toggle svg {
        width: 13px !important;
        height: 13px !important;
        min-width: 13px !important;
        min-height: 13px !important;
    }
    
    /* 最小尺寸的功能按鈕 */
    .nav-link {
        padding: 3px 5px;
        font-size: 10px;
        margin: 0;
    }
    
    /* 確保導航選單不會與工具列重疊 */
    .nav-menu {
        margin-right: 10px;
    }
}

/* ===== 介面按鈕樣式 ===== */

/* 權限管理介面按鈕 - 使用更高特異性避免全局樣式覆蓋 */
.permissions-interface button.btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.permissions-interface button.btn-primary {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.permissions-interface button.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.permissions-interface button.btn-secondary {
    background: var(--text-muted);
    color: white !important;
    border-color: var(--text-muted);
}

.permissions-interface button.btn-secondary:hover {
    background: var(--text-muted-hover, #94a3b8);
    border-color: var(--text-muted-hover, #94a3b8);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.permissions-interface button.btn-danger {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
}

.permissions-interface button.btn-danger:hover {
    background: var(--danger-hover, #dc2626);
    border-color: var(--danger-hover, #dc2626);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.permissions-interface button.btn-default {
    background: var(--card);
    color: var(--text) !important;
    border-color: var(--border);
}

.permissions-interface button.btn-default:hover {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.permissions-interface button.btn:hover {
    transform: translateY(-1px);
}

/* 員工管理介面按鈕 - 使用更高特異性避免全局樣式覆蓋 */
.employees-interface button.btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.employees-interface button.btn-primary {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.employees-interface button.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.employees-interface button.btn-secondary {
    background: var(--text-muted);
    color: white !important;
    border-color: var(--text-muted);
}

.employees-interface button.btn-secondary:hover {
    background: var(--text-muted-hover, #94a3b8);
    border-color: var(--text-muted-hover, #94a3b8);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.employees-interface button.btn-danger {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
}

.employees-interface button.btn-danger:hover {
    background: var(--danger-hover, #dc2626);
    border-color: var(--danger-hover, #dc2626);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 69, 0.2);
}

.employees-interface button.btn-edit {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.employees-interface button.btn-edit:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.employees-interface button.btn-delete {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
}

.employees-interface button.btn-delete:hover {
    background: var(--danger-hover, #dc2626);
    border-color: var(--danger-hover, #dc2626);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 69, 0.2);
}

.employees-interface button.btn:hover {
    transform: translateY(-1px);
}

/* 生物辨識管理介面按鈕 - 使用更高特異性避免全局樣式覆蓋 */
.biometric-interface button.btn {
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.biometric-interface button.btn-primary {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.biometric-interface button.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.biometric-interface button.btn-secondary {
    background: var(--text-muted);
    color: white !important;
    border-color: var(--text-muted);
}

.biometric-interface button.btn-secondary:hover {
    background: var(--text-muted-hover, #94a3b8);
    border-color: var(--text-muted-hover, #94a3b8);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.2);
}

.biometric-interface button.btn-danger {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
}

.biometric-interface button.btn-danger:hover {
    background: var(--danger-hover, #dc2626);
    border-color: var(--danger-hover, #dc2626);
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 69, 0.2);
}

.biometric-interface button.btn:hover {
    transform: translateY(-1px);
}

/* ===== 首頁樣式 ===== */

/* 歡迎區塊 */
.welcome-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.welcome-section h2 {
    color: var(--text);
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.welcome-section p {
    color: var(--text-muted);
    margin: 0;
    font-size: 1.1rem;
}

/* 系統統計區塊 */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--accent);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    line-height: 1;
}

.stat-label {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .welcome-section {
        padding: 20px;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .stats-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .welcome-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .welcome-section h2 {
        font-size: 1.3rem;
    }
    
    .welcome-section p {
        font-size: 1rem;
    }
}

/* 語言選擇器樣式 */
.language-selector {
    position: relative;
    margin-right: 0px;
}

.language-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.language-toggle:hover {
    background: var(--accent) !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

.language-toggle:hover svg {
    color: white !important;
}

.language-toggle svg {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.language-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s ease;
    position: relative;
}

.language-item:hover {
    background-color: var(--hover-bg);
}

.language-item:first-child {
    border-radius: 8px 8px 0 0;
}

.language-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* 強制暗黑模式下語言選擇器樣式 */
[data-theme="dark"] .language-dropdown {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .language-item {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .language-item:hover {
    background: #334155 !important;
    color: #60a5fa !important;
}

/* 系統偏好暗黑模式下的語言選擇器樣式 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .language-dropdown {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9 !important;
    }
    
    :root:not([data-theme="light"]) .language-item {
        color: #f1f5f9 !important;
    }
    
    :root:not([data-theme="light"]) .language-item:hover {
        background: #334155 !important;
        color: #60a5fa !important;
    }
}

.language-item:only-child {
    border-radius: 8px;
}



.language-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.language-check {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 16px;
}

/* 響應式語言選擇器 */
@media (max-width: 768px) {
    .language-selector {
        margin-right: 4px;
    }
    
    .language-toggle {
        width: 36px;
        height: 36px;
    }
    
    .language-toggle:hover {
        background: var(--accent) !important;
        color: white !important;
        transform: translateY(-1px) !important;
    }
    
    .language-toggle:hover svg {
        color: white !important;
    }
    
    .language-toggle svg {
        width: 18px;
        height: 18px;
    }
    
    .language-dropdown {
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .language-toggle {
        width: 32px;
        height: 32px;
    }
    
    .language-toggle:hover {
        background: var(--accent) !important;
        color: white !important;
        transform: translateY(-1px) !important;
    }
    
    .language-toggle:hover svg {
        color: white !important;
    }
    
    .language-toggle svg {
        width: 16px;
        height: 16px;
    }
    
    .language-dropdown {
        min-width: 160px;
    }
    
    .language-item {
        padding: 10px 12px;
    }
    

    
    .language-name {
        font-size: 13px;
    }
}
/* === 官網設定樣式 === */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    margin: 0;
    padding: 0;
}

/* 隱藏預設的勾選框 */
.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* 自定義勾選框樣式 */
.checkbox-label input[type="checkbox"] + span {
    position: relative;
    color: var(--text);
    line-height: 1.5;
    padding-left: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox-label input[type="checkbox"] + span::before {
    content: '';
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    transition: var(--transition);
    position: relative;
}

.checkbox-label input[type="checkbox"] + span::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 10px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: var(--transition);
}

/* 勾選框懸停效果 */
.checkbox-label:hover input[type="checkbox"] + span::before {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* 勾選狀態 */
.checkbox-label input[type="checkbox"]:checked + span::before {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked + span::after {
    opacity: 1;
}

/* 聚焦狀態 */
.checkbox-label input[type="checkbox"]:focus + span::before {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.full-width {
    grid-column: 1 / -1;
}

.feature-tags-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-input-group {
    display: flex;
    gap: 8px;
    width: 100%;
    min-width: 0; /* 防止 flex 容器超出父容器 */
    max-width: 100%; /* 確保不超出父容器寬度 */
    box-sizing: border-box;
}

.feature-input-group input {
    flex: 1;
    min-width: 0; /* 防止 flex 項目超出容器 */
    max-width: 100%; /* 確保不超出容器寬度 */
    box-sizing: border-box;
}

.feature-input-group button {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    white-space: nowrap; /* 防止按鈕文字換行 */
}

.feature-input-group button:hover {
    background: var(--accent-hover);
}

/* 響應式設計：窄螢幕優化 */
@media (max-width: 768px) {
    .feature-input-group {
        gap: 6px; /* 減少間距以節省空間 */
    }
    
    .feature-input-group input {
        min-width: 0;
        /* 保持 flex: 1，但確保不超出容器 */
    }
    
    .feature-input-group button {
        padding: 8px 12px; /* 稍微減少按鈕內邊距 */
        font-size: 14px; /* 確保文字大小合適 */
        white-space: nowrap; /* 防止按鈕文字換行 */
    }
}

/* 極窄螢幕優化 - 垂直排列 */
@media (max-width: 480px) {
    .feature-input-group {
        flex-direction: column; /* 改為垂直排列 */
        gap: 8px;
    }
    
    .feature-input-group input {
        width: 100%; /* 輸入框佔滿寬度 */
        min-width: 0;
    }
    
    .feature-input-group button {
        width: 100%; /* 按鈕也佔滿寬度 */
        padding: 10px 16px; /* 增加按鈕高度以便點擊 */
        font-size: 14px;
    }
}

.feature-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.feature-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 0.9em;
    color: var(--text-primary);
}

.feature-tag .remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition-fast);
}

.feature-tag .remove-btn:hover {
    background: var(--error-color);
    color: white;
}

/* === 官網商品順序調整樣式 === */
.website-sort-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

#website-sort-modal {
    max-width: 800px;
    width: 90vw;
    max-height: 80vh;
}

.sort-instructions {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border-left: 4px solid var(--accent);
}

.sort-instructions p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.website-products-sortable {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.sortable-product-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    cursor: grab;
    transition: var(--transition);
    user-select: none;
}

.sortable-product-item:last-child {
    border-bottom: none;
}

.sortable-product-item:hover {
    background: var(--bg-hover);
}

.sortable-product-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.product-drag-handle {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    cursor: grab;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.product-drag-handle:hover {
    background: var(--bg-secondary);
    color: var(--accent);
}

.product-cover {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-cover .no-image {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-code {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.product-name {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-sort-order {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
    background: var(--accent-light);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.sort-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 大型模態框樣式 */
.large-modal {
    max-width: 900px;
    width: 95vw;
    max-height: 85vh;
    padding: 0;
}

.large-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.large-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
}

.large-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: var(--transition);
}

.large-modal .modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.large-modal .modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 80px);
}

/* 檔案上傳區域樣式 */
.file-upload-area, .file-upload-section .file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin: 10px 0;
    transition: border-color 0.3s ease;
}

.file-upload-area:hover, .file-upload-section .file-upload-area:hover {
    border-color: var(--primary-color);
}

.file-upload-area input[type="file"], .file-upload-section input[type="file"] {
    display: none;
}

.upload-label {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.upload-label:hover {
    background: var(--primary-hover);
}

/* 編輯模式檔案列表 */
.file-upload-section {
    margin: 15px 0;
}

.file-list .file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 5px 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.file-item .file-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-color);
}

.file-item .file-actions {
    display: flex;
    gap: 5px;
}

.file-item .file-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.file-item .file-actions .btn-download:hover {
    background: var(--success-color);
    color: white;
}

.file-item .file-actions .btn-delete:hover {
    background: var(--error-color);
    color: white;
}

/* 供應商提示文字樣式 */
.no-vendors {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
    text-align: center;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* 編輯專用區塊邊距調整 */
#product-edit-only-sections {
    padding: 0 20px 20px 20px;
}

/* 產品備註區塊樣式 */
.notes-container {
    width: 100%;
}

.notes-description {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-style: italic;
}

.notes-container textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
}

/* 產品資料列印功能樣式 */
.print-actions {
    margin-top: 20px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.print-actions .btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.print-actions .btn i {
    font-size: 18px;
}

/* 列印模態框樣式 */
#print-print-modal {
    max-width: 1200px;
    width: 95vw;
    max-height: 90vh;
}

.print-search-section,
.print-queue-section,
.print-options-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.print-search-section h4,
.print-queue-section h4,
.print-options-section h4 {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.search-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-controls input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.search-controls input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-fast);
}

.search-result-item:hover {
    background: var(--hover-bg);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-right: 12px;
    border: 1px solid var(--border);
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-info h5 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-actions {
    display: flex;
    gap: 8px;
}

.search-result-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.print-queue-controls {
    margin-bottom: 16px;
    text-align: right;
}

.print-queue-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
}

.print-queue-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-fast);
}

.print-queue-item:hover {
    background: var(--hover-bg);
}

.print-queue-item:last-child {
    border-bottom: none;
}

.print-queue-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-right: 12px;
    border: 1px solid var(--border);
}

.print-queue-info {
    flex: 1;
    min-width: 0;
}

.print-queue-info h6 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.print-queue-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.print-queue-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.print-queue-actions .btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.quantity-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quantity-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.quantity-input {
    width: 60px;
    padding: 4px 6px !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-align: center;
    background: var(--input-bg);
    color: var(--text);
}

/* 手機響應式優化 */
@media (max-width: 768px) {
    .print-queue-item {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 12px;
    }
    
    .print-queue-item > *:not(.print-queue-thumbnail) {
        width: 100%;
    }
    
    .print-queue-thumbnail {
        width: 80px !important;
        height: 80px !important;
        margin: 0 auto 8px !important;
        margin-right: auto !important;
        margin-left: auto !important;
        align-self: center;
        flex-shrink: 0;
    }
    
    .print-queue-info {
        text-align: center;
        min-width: 0;
    }
    
    .print-queue-info .print-queue-name {
        font-size: 14px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-word;
        line-height: 1.4;
        margin-bottom: 6px;
        max-height: none;
    }
    
    .print-queue-info .print-queue-code {
        font-size: 12px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-all;
        margin-bottom: 8px;
    }
    
    .print-queue-actions {
        flex-direction: row;
        justify-content: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .quantity-input-group {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }
    
    .quantity-label {
        font-size: 13px;
    }
    
    .quantity-input {
        width: 70px;
        font-size: 14px;
        padding: 6px 8px !important;
    }
    
    .print-queue-remove-btn {
        flex: 1;
        min-width: 100px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

.print-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.option-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.output-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.radio-option:hover {
    background: var(--hover-bg);
}

.radio-option input[type="radio"] {
    margin: 0;
    accent-color: var(--primary-color);
}

.radio-option span {
    font-size: 14px;
    color: var(--text-primary);
}

.print-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

.print-actions .btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.print-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.print-actions .btn i {
    font-size: 18px;
}

/* 列印樣式 - 直接套用，不使用 @media print */
.print-catalog {
    font-family: 'Noto Sans TC', Arial, sans-serif !important;
    line-height: 1.3 !important;
    color: #000 !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 12px !important;
}

.print-catalog .catalog-header {
    text-align: center;
    margin-bottom: 8px !important;
    padding-bottom: 4px !important;
    border-bottom: 1px solid #333 !important;
}

.print-catalog .catalog-title {
    font-size: 16px !important;
    font-weight: bold;
    margin-bottom: 2px !important;
}

.print-catalog .catalog-subtitle {
    font-size: 12px !important;
    color: #666;
}

.print-catalog .product-item {
    page-break-inside: avoid;
    margin-bottom: 4px !important;
    padding: 4px !important;
    border: 1px solid #ddd !important;
    border-radius: 2px;
    font-size: 10px !important;
}

.print-catalog .product-header {
    margin-bottom: 2px !important;
}
.print-catalog .product-photos {
    display: flex !important;
    flex-wrap: wrap !important; /* 照片太多時自動換行 */
    gap: 4px !important;
    margin-bottom: 4px !important;
}

.print-catalog .product-photo {
    height: 70px !important;   /* 中等可閱讀高度 */
    width: auto !important;    /* 等比例寬度 */
    max-width: 24% !important; /* 單行最多四張，避免過寬 */
    object-fit: cover !important;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.print-catalog .product-info {
    flex: 1;
}

.print-catalog .product-code {
    font-size: 10px !important;
    font-weight: bold;
    color: #333;
    margin-bottom: 1px !important;
}

.print-catalog .product-name {
    font-size: 9px !important;
    color: #555;
    margin-bottom: 1px !important;
}

.print-catalog .product-specs {
    font-size: 8px !important;
    color: #666;
    margin-bottom: 1px !important;
}

.print-catalog .product-description {
    font-size: 8px !important;
    color: #333;
    line-height: 1.1 !important;
    margin-bottom: 1px !important;
    text-align: justify;
}

.print-catalog .product-features {
    font-size: 8px !important;
    color: #333;
    font-weight: 500;
    margin-bottom: 1px !important;
}

.print-catalog .product-description p {
    margin: 0 0 1px 0 !important;
}

.print-catalog .product-description p:last-child {
    margin-bottom: 0 !important;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .print-options-grid {
        grid-template-columns: 1fr;
    }
    
    .search-controls {
        flex-direction: column;
    }
    
    .print-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .print-actions .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* 全選功能樣式 */
.search-results-header {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.search-results-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.select-all-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
}

.select-all-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--card-bg);
    transition: all 0.2s ease;
}

.search-result-item:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
}

.search-result-checkbox {
    flex-shrink: 0;
}

.search-result-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.search-result-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-info h5 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.search-result-info p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.4;
}

.search-result-actions {
    flex-shrink: 0;
}

.search-results-list {
    max-height: 400px;
    overflow-y: auto;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .search-results-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .search-result-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .search-result-checkbox {
        order: 1;
    }
    
    .search-result-thumbnail {
        order: 2;
        align-self: center;
    }
    
    .search-result-info {
        order: 3;
    }
    
    .search-result-actions {
        order: 4;
        align-self: center;
    }
}

/* 檔案預覽導航樣式 */
.viewer-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 60px;
    position: relative;
    z-index: 100000;
    flex-shrink: 0;
    gap: 2rem; /* 增加欄位間距 */
}

.viewer-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    position: relative;
    z-index: 100001;
    justify-content: center;
    grid-column: 2;
}

.viewer-close {
    color: white;
    background: rgba(239, 68, 68, 0.8);
    border: 2px solid white;
    border-radius: 50%;
    padding: 12px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    flex-shrink: 0;
    grid-column: 3;
    justify-self: end;
    margin-right: 1rem; /* 增加右邊距，避免貼邊 */
}

.viewer-nav button {
    color: white;
    background: rgba(0, 123, 255, 0.8);
    border: 2px solid white;
    border-radius: 50%;
    padding: 12px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    position: relative;
    z-index: 100002;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: 48px; /* 確保最小寬度 */
}

.viewer-nav button:hover {
    background: rgba(0, 123, 255, 1);
    transform: scale(1.1);
}

.viewer-nav button:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
    transform: none;
}

.viewer-nav span {
    color: white;
    font-size: 18px;
    font-weight: 500;
    min-width: 120px;
    text-align: center;
}

.viewer-close:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

/* 檔案預覽視窗布局 */
.viewer-overlay {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
}

.viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.viewer-content img,
.viewer-content iframe {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 專案事項樣式 */
.project-code {
    background: var(--bg-muted);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: monospace;
}

.project-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.project-title strong {
    color: var(--text);
    font-weight: 500;
}

.project-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.4;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    display: inline-block;
}

.status-not_started {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.status-in_progress {
    background: #cce5ff;
    color: #0066cc;
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-cancelled {
    background: #f8d7da;
    color: #721c24;
}

.priority-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    display: inline-block;
}

.priority-low {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.priority-medium {
    background: #fff3cd;
    color: #856404;
}

.priority-high {
    background: #f8d7da;
    color: #721c24;
}

.priority-urgent {
    background: #f5c6cb;
    color: #721c24;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.progress {
    flex: 1;
    height: 6px;
    background: var(--bg-muted);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    min-width: 35px;
    text-align: right;
}

.project-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-stats i {
    margin-right: 0.25rem;
    margin-left: 0.5rem;
}

.project-stats i:first-child {
    margin-left: 0;
}

/* 專案卡片網格佈局 */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

/* 專案卡片樣式 */
.project-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.project-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* 專案卡片標題區域 */
.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.project-title-section {
    flex: 1;
    min-width: 0;
}

.project-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    word-wrap: break-word;
}

.project-code {
    background: var(--bg-muted);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
}

.project-status-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
    flex-shrink: 0;
}

/* 專案描述 */
.project-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    word-wrap: break-word;
}

/* 進度區域 */
.project-progress-section {
    margin-bottom: 1rem;
}

.progress-container {
    margin-bottom: 0.75rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.1rem;
}

.progress-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.progress-percentage {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
}

.progress {
    height: 8px;
    background: var(--bg-muted);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.project-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-item i {
    font-size: 0.75rem;
    color: var(--accent);
}

/* 專案資訊區域 */
.project-info-section {
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.info-item i {
    font-size: 0.875rem;
    color: var(--accent);
    width: 16px;
    text-align: center;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: fit-content;
}

.info-value {
    font-size: 0.875rem;
    color: var(--text);
    font-weight: 500;
    word-wrap: break-word;
    min-width: 0;
}

/* 操作按鈕區域 */
.project-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: fit-content;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.action-btn.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.action-btn.secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.action-btn.secondary:hover {
    background: var(--bg-muted);
    border-color: var(--accent);
}

.action-btn.danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.action-btn.danger:hover {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
}

.action-btn i {
    font-size: 0.875rem;
}

/* 狀態和優先級徽章樣式 */
.status-badge, .priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.status-badge.status-not_started {
    background: #e5e7eb;
    color: #6b7280;
}

.status-badge.status-in_progress {
    background: #dbeafe;
    color: #2563eb;
}

.status-badge.status-completed {
    background: #d1fae5;
    color: #059669;
}

.status-badge.status-cancelled {
    background: #fee2e2;
    color: #dc2626;
}

.priority-badge {
    background: var(--bg-muted);
    color: var(--text-muted);
}

.priority-badge.priority-urgent {
    background: #fef2f2;
    color: #dc2626;
}

.priority-badge.priority-high {
    background: #fef3c7;
    color: #d97706;
}

.priority-badge.priority-medium {
    background: #dbeafe;
    color: #2563eb;
}

.priority-badge.priority-low {
    background: #f3f4f6;
    color: #6b7280;
}

/* 指派員工列表樣式 - 橫向佈局 */
.assigned-employees-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.employee-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-muted);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.employee-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.employee-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.employee-initial {
    font-size: 0.875rem;
    font-weight: 600;
}

.employee-info {
    flex: 1;
    min-width: 0;
}

.employee-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.employee-department {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 員工數量樣式 */
.employee-count {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

/* 空狀態樣式 - 已移至下方統一管理 */

.role-badge {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    display: inline-block;
}

.badge {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* 專案詳情頁面佈局 */
.project-content {
    margin-top: 0px;
    padding-left: 24px;
    padding-right: 24px;
}

/* 手機版調整 */
@media (max-width: 768px) {
    .project-content {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* 專案標題區域 */
.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.project-title h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.project-code {
    display: inline-block;
    background: var(--bg-muted);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.project-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.project-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    white-space: nowrap;
}

.project-actions .btn.primary {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}

.project-actions .btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.project-actions .btn.secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.project-actions .btn.secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 確保所有卡片都有統一的邊距 */
.project-content .card {
    margin-bottom: 1.5rem;
}

.project-content .card:last-child {
    margin-bottom: 0;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .project-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .project-actions {
        justify-content: flex-start;
    }
    
    .project-actions .btn {
        flex: 1;
        justify-content: center;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .right-column {
        gap: 1rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .project-card {
        padding: 1rem;
    }
    
    .project-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .project-status-section {
        flex-direction: row;
        align-items: center;
        width: 100%;
        justify-content: space-between;
    }
    
    .info-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .project-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .action-btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    /* 員工卡片響應式調整 */
    .assigned-employees-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 0.5rem;
    }
    
    .employee-item {
        padding: 0.75rem;
    }
    
    .employee-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
        margin-right: 0.5rem;
    }
    
    .employee-name {
        font-size: 0.8rem;
    }
    
    .employee-department {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .project-actions {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
    }
    
    /* 小螢幕員工卡片調整 */
    .assigned-employees-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.5rem;
    }
    
    .employee-item {
        padding: 0.5rem;
    }
    
    .employee-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
        margin-right: 0.5rem;
    }
    
    .employee-name {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }
    
    .employee-department {
        font-size: 0.65rem;
    }
    
    .role-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 4px;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon.danger:hover {
    background: #f8d7da;
    border-color: #dc3545;
    color: #dc3545;
}

.workflow-step {
    margin-bottom: 0.5rem;
}

.workflow-step .input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.workflow-step .input-group input {
    flex: 1;
}

/* 響應式設計 */
@media (max-width: 1200px) {
}

@media (max-width: 768px) {
    .search-inputs {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-actions button {
        width: 100%;
    }
    
    .search-filter-container {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .search-input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-input-wrapper {
        min-width: 0;
    }
    
    .status-filter {
        min-width: 0;
        width: 100%;
    }
    
    .project-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .vote-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .vote-actions button {
        width: 100%;
    }
    
    .project-keywords {
        gap: 4px;
    }
    
    .keyword-tag {
        font-size: 11px;
        padding: 3px 6px;
    }

    .progress-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .progress {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .btn-icon {
        width: 28px;
        height: 28px;
    }
    
    .project-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .project-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .meta-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .workflow-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .file-actions {
        align-self: flex-end;
    }
    
    .vote-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .vote-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .table-wrapper {
        overflow-x: auto;
    }
    
    .project-stats {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* 專案詳情頁面樣式 */
.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.project-title {
    flex: 1;
}

.project-header .project-title h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text);
    font-size: 1.75rem;
}

.project-header .project-code {
    background: var(--bg-muted);
    color: var(--text-muted);
    padding: 0.3rem 0px;
    border-radius: 4px;
    font-size: 1.4rem;
    font-family: monospace;
}

.project-actions {
    flex-shrink: 0;
    margin-left: 1rem;
}

.project-meta {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-bottom: 1.5rem;
}

.meta-row {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.meta-row .meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.meta-row .meta-item i {
    color: var(--accent);
    width: 16px;
}

.project-description {
    margin-bottom: 1.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.project-description h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.project-description p {
    padding: 0px 10px;
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.project-progress h4 {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
}


/* 工作流程樣式 */
.workflow-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-muted);
    transition: var(--transition);
    position: relative;
}

.workflow-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}


.workflow-item.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: scale(1.02);
}

.workflow-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.drag-handle {
    flex-shrink: 0;
    width: 20px;
    height: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    padding: 4px 2px;
    margin-top: 0.25rem;
    margin-right: 0.75rem;
    position: relative;
    transition: all 0.2s ease;
}

/* iOS 風格的三條橫線 */
.drag-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 14px;
    background: linear-gradient(
        to bottom,
        var(--text-muted) 0%,
        var(--text-muted) 15%,
        transparent 15%,
        transparent 35%,
        var(--text-muted) 35%,
        var(--text-muted) 50%,
        transparent 50%,
        transparent 70%,
        var(--text-muted) 70%,
        var(--text-muted) 85%,
        transparent 85%,
        transparent 100%
    );
    background-size: 100% 3px;
    background-repeat: no-repeat;
    background-position: 0 0, 0 5px, 0 10px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

/* 懸停效果 */
.drag-handle:hover::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* 點擊效果 */
.drag-handle:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.drag-handle:active::before {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.8;
}

/* 拖動時的視覺效果 */
.workflow-item.dragging {
    opacity: 0.6;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.workflow-item.dragging .drag-handle::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* 拖動目標區域效果 */
.workflow-item.drag-over {
    border: 2px dashed var(--accent);
    background: var(--accent-light);
    transform: scale(1.01);
}

.workflow-item.drag-target {
    position: relative;
}

.workflow-item.drag-target::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: rgba(var(--accent-rgb), 0.1);
    pointer-events: none;
    z-index: 1;
}

/* 暗黑模式下的調整 */
@media (prefers-color-scheme: dark) {
    .drag-handle::before {
        background: linear-gradient(
            to bottom,
            var(--text-muted) 0%,
            var(--text-muted) 15%,
            transparent 15%,
            transparent 35%,
            var(--text-muted) 35%,
            var(--text-muted) 50%,
            transparent 50%,
            transparent 70%,
            var(--text-muted) 70%,
            var(--text-muted) 85%,
            transparent 85%,
            transparent 100%
        );
        opacity: 0.7;
    }
    
    .drag-handle:hover::before {
        opacity: 1;
    }
}

/* 移除原本的圖示樣式 */
.drag-handle i {
    display: none;
}

.workflow-checkbox {
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.workflow-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-left: 1rem;
}

/* 確保在小螢幕上編輯按鈕仍然可見 */
@media (max-width: 768px) {
    .workflow-actions {
        margin-left: 0;
        padding-left: 0;
        margin-top: 0.5rem;
        justify-content: flex-end;
    }
}
.btn-edit-step {
    background: var(--accent) !important;
    border: 1px solid var(--accent) !important;
    color: white !important;
    cursor: pointer;
    padding: 8px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    position: relative;
    z-index: 10;
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-edit-step svg {
    width: 14px;
    height: 14px;
    color: inherit;
    transition: all 0.2s ease;
}

.btn-edit-step:hover {
    background: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-edit-step:hover svg {
    transform: scale(1.1);
}

.btn-edit-step:active {
    transform: scale(0.95);
}

/* 專案關鍵字樣式 */
.project-keywords {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.project-keywords h4 {
    margin-bottom: 0.75rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.keywords-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.keyword-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: default;
    position: relative;
}

.keyword-tag:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 根據權重調整關鍵字樣式 */
.keyword-tag[data-weight="1"] {
    opacity: 0.7;
    font-size: 0.8rem;
}

.keyword-tag[data-weight="2"] {
    opacity: 0.8;
    font-size: 0.85rem;
}

.keyword-tag[data-weight="3"] {
    opacity: 0.9;
    font-size: 0.9rem;
}

.keyword-tag[data-weight="4"] {
    opacity: 1;
    font-size: 0.95rem;
    font-weight: 600;
}

.keyword-tag[data-weight="5"] {
    opacity: 1;
    font-size: 1rem;
    font-weight: 700;
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.keyword-tag[data-weight="5"]:hover {
    background: var(--accent);
    color: white;
}

/* 模態介面按鈕佈局 */
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.modal-footer-delete {
    margin-right: auto;
}

.modal-footer-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-btn.danger {
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
}

.modal-btn.danger:hover {
    background: var(--danger-dark, #c82333);
    border-color: var(--danger-dark, #c82333);
}

.modal-btn.danger:active {
    background: var(--danger-dark, #bd2130);
    border-color: var(--danger-dark, #bd2130);
}

/* 響應式設計 - 小螢幕時按鈕垂直排列 */
@media (max-width: 480px) {
    .modal-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .modal-footer-delete {
        margin-right: 0;
        order: 3; /* 刪除按鈕放在最後 */
    }
    
    .modal-footer-right {
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
        order: 1; /* 取消和儲存按鈕放在前面 */
    }
}

/* 專案檔案上傳區域 */
.project-file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
    margin-bottom: 1rem;
}

.project-file-upload-area:hover {
    border-color: var(--accent);
    background: var(--hover-bg);
}

.project-file-upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent);
    opacity: 0.1;
    transform: scale(1.02);
}

.project-file-upload-area.paste-success {
    background: var(--success);
    opacity: 0.1;
    border-color: var(--success);
    transform: scale(1.02);
    animation: pasteSuccess 0.6s ease-out;
}

@keyframes pasteSuccess {
    0% {
        transform: scale(1);
        opacity: 0.1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.2;
    }
    100% {
        transform: scale(1.02);
        opacity: 0.1;
    }
}

.project-file-upload-area .upload-content {
    pointer-events: none;
}

.project-file-upload-area .upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
    pointer-events: none;
}

.project-file-upload-area .upload-text p {
    margin: 0.5rem 0;
    color: var(--text-color);
    font-size: 1rem;
    pointer-events: none;
}

.project-file-upload-area .upload-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

/* 檔案排序控制器 */
.file-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-sort-controls label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
}

.file-sort-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 150px;
}

/* 專案檔案列表 */
.project-files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-file-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    transition: all 0.2s ease;
}

.project-file-item:hover {
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.project-file-item .file-thumbnail {
    width: 48px;
    height: 48px;
    margin-right: 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
    cursor: pointer;
}

.project-file-item .file-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* PDF 圖示樣式 */
.project-file-item .pdf-icon {
    width: 100%;
    height: 100%;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.7rem;
    border-radius: 6px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-file-item .pdf-icon:hover {
    background: #c82333;
    transform: scale(1.05);
}

/* 檔案圖示回退樣式 */
.project-file-item .file-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.project-file-item .file-type-icon {
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.project-file-item .file-type-icon:hover {
    transform: scale(1.1);
}

.project-file-item .file-info {
    flex: 1;
    min-width: 0;
}

.project-file-item .file-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-style: italic;
    word-break: break-word;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.project-file-item .file-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.project-file-item .file-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.project-file-item .file-meta span {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.project-file-item .file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 上傳進度條 */
.upload-progress {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.upload-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-light, #e9ecef);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.upload-progress .progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.upload-progress .progress-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .project-file-item .file-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .project-file-item .file-actions {
        flex-direction: column;
    }
    
    .file-sort-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .file-sort-select {
        width: 100%;
    }
}

/* 自定義刪除確認對話框 */
.confirm-delete-modal {
    z-index: 12000; /* 比編輯模態框更高的層級 */
    position: absolute;
}

/* 已完成專案的特殊樣式 */
.project-completed {
    position: relative;
}

.project-completed::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-badge.status-completed {
    background: var(--success) !important;
    color: white !important;
    animation: completedPulse 2s ease-in-out;
}

@keyframes completedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .keywords-container {
        gap: 0.375rem;
    }
    
    .keyword-tag {
        padding: 0.2rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* 移除重複的樣式定義 */

.workflow-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.workflow-details {
    flex: 1;
    min-width: 0;
}

.workflow-title label {
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 新增步驟模態框樣式 */
.modal-header .modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.modal-header .modal-title i {
    color: var(--accent);
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-label i {
    color: var(--accent);
    width: 16px;
    text-align: center;
}

.form-control {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--bg);
    color: var(--text);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
    outline: none;
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.modal-footer .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-footer .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.modal-footer .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.modal-footer .btn-secondary {
    background: var(--bg-muted);
    border-color: var(--border);
    color: var(--text);
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* 載入狀態 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fa-spinner.fa-spin {
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.workflow-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.workflow-completed {
    margin-top: 0.5rem;
}

/* 檔案項目樣式 */
.file-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: var(--card);
    transition: var(--transition);
}

.file-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.file-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--bg-muted);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 投票項目樣式 */
.vote-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--card);
    transition: var(--transition);
}

.vote-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.vote-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.vote-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.vote-actions {
    display: flex;
    gap: 0.5rem;
}

/* 活動記錄樣式 */
.activity-container {
    position: relative;
}

.activity-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    margin-right: -8px;
}

/* 自定義滾動條樣式 */
.activity-list::-webkit-scrollbar {
    width: 6px;
}

.activity-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.activity-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox 滾動條樣式 */
.activity-list {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background-color: var(--bg-secondary);
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.activity-icon {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: 0.5rem;
    transition: transform 0.2s ease;
}

.activity-item:hover .activity-icon {
    transform: scale(1.2);
}

.activity-content {
    flex: 1;
    min-width: 0; /* 防止文字溢出 */
}

.activity-description {
    color: var(--text);
    margin-bottom: 0.25rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.activity-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.activity-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.activity-empty p {
    margin: 0;
    font-size: 0.9rem;
}

.activity-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-count .badge {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .activity-list {
        max-height: 300px;
    }
    
    .activity-item {
        padding: 0.5rem 0;
    }
    
    .activity-description {
        font-size: 0.9rem;
    }
    
    .activity-meta {
        font-size: 0.7rem;
    }
    
    .activity-count .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

@media (max-width: 480px) {
    .activity-list {
        max-height: 250px;
    }
    
    .activity-item {
        gap: 0.75rem;
    }
    
    .activity-icon {
        width: 6px;
        height: 6px;
    }
}

/* 投票選項樣式 */
.vote-option {
    margin-bottom: 0.5rem;
}

.vote-option .input-group {
    margin-bottom: 0;
}

/* 表單幫助文字樣式 */
.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* 必填欄位標記樣式 */
.required {
    color: #dc3545;
    font-weight: 500;
}

/* 表單欄位組樣式 */
fieldset {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin: 0;
}

legend {
    font-weight: 500;
    color: var(--text);
    padding: 0 0.5rem;
    font-size: 0.875rem;
}

/* 表單錯誤樣式 */
input.error,
select.error,
textarea.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

input.error:focus,
select.error:focus,
textarea.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.error-message {
    color: #dc3545;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

/* 載入狀態樣式 */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button:disabled:hover {
    background-color: var(--accent);
    color: white;
}

/* 表單動作樣式 */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
}

/* 專業表單樣式 */
.project-form {
    padding: 0;
}

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    position: relative;
}

.form-section:last-of-type {
    margin-bottom: 0;
}

.form-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent);
    position: relative;
}

.form-section-title::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--accent);
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-label-help {
    display: block;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    font-size: 0.875rem;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.select-wrapper {
    position: relative;
}

.select-wrapper .form-select {
    appearance: none;
    padding-right: 2.5rem;
}

.select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.date-wrapper {
    position: relative;
}

.date-wrapper .form-input {
    padding-right: 2.5rem;
}

.date-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.required {
    color: var(--danger);
    font-weight: 600;
    margin-left: 0.25rem;
}

/* 員工選擇樣式 */
.employee-selection {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    background: var(--bg-muted);
    transition: var(--transition);
}

.employee-selection:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.employee-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.selection-controls {
    display: flex;
    gap: 0.75rem;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.selection-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.selection-count span:first-child {
    color: var(--accent);
    font-weight: 600;
}

.employee-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.employee-checkbox {
    display: block;
    cursor: pointer;
    transition: var(--transition);
}

.employee-checkbox-input {
    display: none;
}

.employee-checkbox-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    transition: var(--transition);
    position: relative;
}

.employee-checkbox:hover .employee-checkbox-content {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.employee-checkbox-input:checked + .employee-checkbox-content {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
}

.employee-checkbox-input:checked + .employee-checkbox-content::before {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.employee-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    flex-shrink: 0;
}

.employee-initial {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
}

.employee-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.employee-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.employee-department {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 表單動作按鈕樣式 */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-muted);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.form-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    font-size: 0.875rem;
}

.form-actions .btn i {
    font-size: 0.875rem;
}

.form-actions .btn.primary {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}

.form-actions .btn.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.form-actions .btn.secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.form-actions .btn.secondary:hover {
    background: var(--bg-muted);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
    .form-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .employee-checkboxes {
        grid-template-columns: 1fr;
        max-height: 300px;
    }
    
    .employee-selection-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .selection-controls {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .project-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .meta-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .workflow-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .file-actions {
        align-self: flex-end;
    }
}

/* ===== 載入提示和空狀態樣式 ===== */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--card);
    border-radius: var(--radius);
    z-index: 10;
    opacity: 0.95;
    min-height: 300px;
    padding: 2rem;
}

/* 全螢幕商品列表載入覆蓋層 */
.product-list-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    z-index: 9999;
    gap: 1rem;
}

/* 商品編輯模態框內的載入指示器 */
.product-modal-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    z-index: 1000;
    gap: 1rem;
    border-radius: var(--radius);
}

.product-modal-loading .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.product-modal-loading .loading-text {
    font-size: 1.125rem;
    color: var(--text);
    font-weight: 500;
}

.product-list-loading-overlay .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.product-list-loading-overlay .loading-text {
    font-size: 1.125rem;
    color: var(--text);
    font-weight: 500;
}

/* 類別選擇載入提示 */
.category-select-container {
    position: relative;
}

.category-loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 100;
    gap: 0.5rem;
    opacity: 0.95;
}

.category-loading-indicator .loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.category-loading-indicator .loading-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* 載入提示中的載入動畫樣式 */
.loading-indicator .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-indicator .loading-text {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* 表格內的 empty-state 使用絕對定位 */
.table-wrapper .empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--card);
    border-radius: var(--radius);
    z-index: 10;
    border: 2px dashed var(--border);
    min-height: 300px;
}

/* 一般 empty-state 使用相對定位 */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    background: var(--card);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    position: relative;
}

.empty-state i {
    display: block;
    margin-bottom: 1rem;
    opacity: 0.6;
    font-size: 3rem;
    color: var(--text-muted);
}

.empty-state p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.empty-state small {
    font-size: 0.875rem;
    opacity: 0.8;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* empty-icon 樣式已整合到 .empty-state i 中 */

/* empty-text 樣式已整合到 .empty-state p 中 */

/* empty-hint 樣式已整合到 .empty-state small 中 */

/* 暗黑模式下的載入提示樣式 */
[data-theme="dark"] .loading-indicator {
    background: #1e293b;
    border: 1px solid #334155;
}

[data-theme="dark"] .loading-indicator .loading-spinner {
    border-color: #334155;
    border-top-color: #60a5fa;
}

[data-theme="dark"] .loading-indicator .loading-text {
    color: #94a3b8;
}

/* 暗黑模式下的全螢幕載入覆蓋層 */
[data-theme="dark"] .product-list-loading-overlay {
    background: rgba(30, 41, 59, 0.95);
}

[data-theme="dark"] .product-list-loading-overlay .loading-spinner {
    border-color: #334155;
    border-top-color: #60a5fa;
}

[data-theme="dark"] .product-list-loading-overlay .loading-text {
    color: #94a3b8;
}

/* 暗黑模式下的商品編輯模態框載入指示器 */
[data-theme="dark"] .product-modal-loading {
    background: rgba(30, 41, 59, 0.95);
}

[data-theme="dark"] .product-modal-loading .loading-spinner {
    border-color: #334155;
    border-top-color: #60a5fa;
}

[data-theme="dark"] .product-modal-loading .loading-text {
    color: #94a3b8;
}

[data-theme="dark"] .loading-spinner {
    border-color: #334155;
    border-top-color: #60a5fa;
}
/* 暗黑模式下的類別載入提示 */
[data-theme="dark"] .category-loading-indicator {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .category-loading-indicator .loading-text {
    color: #94a3b8;
}

[data-theme="dark"] .empty-state {
    background: #1e293b;
    border-color: #334155;
}

/* 系統偏好暗黑模式下的載入提示樣式 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .loading-indicator {
        background: #1e293b;
        border: 1px solid #334155;
    }
    
    :root:not([data-theme="light"]) .loading-spinner {
        border-color: #334155;
        border-top-color: #60a5fa;
    }
    
    :root:not([data-theme="light"]) .product-list-loading-overlay {
        background: rgba(30, 41, 59, 0.95);
    }
    
    :root:not([data-theme="light"]) .product-list-loading-overlay .loading-spinner {
        border-color: #334155;
        border-top-color: #60a5fa;
    }
    
    :root:not([data-theme="light"]) .product-list-loading-overlay .loading-text {
        color: #94a3b8;
    }
    
    :root:not([data-theme="light"]) .product-modal-loading {
        background: rgba(30, 41, 59, 0.95);
    }
    
    :root:not([data-theme="light"]) .product-modal-loading .loading-spinner {
        border-color: #334155;
        border-top-color: #60a5fa;
    }
    
    :root:not([data-theme="light"]) .product-modal-loading .loading-text {
        color: #94a3b8;
    }
    
    :root:not([data-theme="light"]) .empty-state {
        background: #1e293b;
        border-color: #334155;
    }
}

/* ===== 暗黑模式下 select 元素強制樣式修復 ===== */
/* 解決跨瀏覽器相容性問題：確保暗黑模式下 select 和 option 元素正確顯示 */

/* 強制暗黑模式下 select 元素樣式 */
[data-theme="dark"] select {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] select option {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

/* 系統偏好暗黑模式下的 select 元素樣式 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) select {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9 !important;
    }
    
    :root:not([data-theme="light"]) select option {
        background: #1e293b !important;
        color: #f1f5f9 !important;
    }
}

/* 額外的瀏覽器特定修復 */
@supports (-webkit-appearance: none) {
    [data-theme="dark"] select {
        -webkit-appearance: none;
        appearance: none;
        background: #1e293b !important;
        color: #f1f5f9 !important;
    }
}

/* Firefox 特定修復 */
@-moz-document url-prefix() {
    [data-theme="dark"] select {
        background: #1e293b !important;
        color: #f1f5f9 !important;
    }
    
    [data-theme="dark"] select option {
        background: #1e293b !important;
        color: #f1f5f9 !important;
    }
}

/* QR Code 樣式 */
.qr-code-container {
  display: inline-block;
  text-align: center;
  vertical-align: top;
  margin: 0px;
  position: relative;
}

.qr-code {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 6px;
  box-shadow: var(--shadow);
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* QR Code 內部包裝器 - 提供白色邊距 */
.qr-code > div {
  display: inline-block;
  padding: 8px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 確保 QR Code 圖片有適當的邊距 */
.qr-code img {
  display: block;
  margin: 0 auto;
}

.qr-code-url {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  word-break: break-all;
  max-width: 120px;
  line-height: 1.2;
  text-align: center;
  font-family: monospace;
  font-weight: bold;
}

/* 專案 QR Code 樣式 */
.project-qr {
  border-color: var(--accent);
}

/* 商品 QR Code 樣式 */
.product-qr {
  border-color: var(--success);
}

/* 新品開發 QR Code 樣式 */
.development-qr {
  border-color: var(--warning);
}

/* 響應式設計 */
@media (max-width: 768px) {
  .qr-code-container {
    margin-left: 8px;
    margin-top: 8px;
  }
  
  .qr-code {
    width: 80px;
    height: 80px;
  }
  
  .qr-code-url {
    font-size: 9px;
    max-width: 80px;
  }
}

/* 列印時隱藏 QR Code */
@media print {
  .qr-code-container {
    display: none !important;
  }
}


/* GLB 縮圖載入指示器樣式 */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10;
  animation: pulse 1.5s ease-in-out infinite;
}

/* 明亮模式下的 GLB 縮圖載入指示器樣式 */
[data-theme="light"] .loading-indicator {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
}

/* 暗黑模式下的 GLB 縮圖載入指示器樣式 */
[data-theme="dark"] .loading-indicator {
  background: rgba(30, 41, 59, 0.9);
  color: #f1f5f9;
  border: 1px solid #334155;
}

/* 系統偏好暗黑模式下的 GLB 縮圖載入指示器樣式 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .loading-indicator {
    background: rgba(30, 41, 59, 0.9);
    color: #f1f5f9;
    border: 1px solid #334155;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.thumb {
  position: relative;
  display: inline-block;
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
}

.thumb .loading-indicator {
  display: none;
}

.thumb.loading .loading-indicator {
  display: block;
}

.thumb.loading img {
  opacity: 0.5;
}

/* ============================================================================
   推播通知模態框 - 推播啟用按鈕樣式
   ============================================================================ */

/* 標題容器 */
.notification-modal-title-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

/* 推播切換按鈕 */
.notification-push-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    position: relative;
    flex-shrink: 0;
}

/* 未訂閱狀態 - 藍色加號 */
.notification-push-toggle.disabled {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.notification-push-toggle.disabled:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 已訂閱狀態 - 綠色鈴鐺 */
.notification-push-toggle.enabled {
    background: #22c55e;
    color: white;
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
}

.notification-push-toggle.enabled:hover {
    background: #16a34a;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(34, 197, 94, 0.4);
}

/* 權限被拒絕 - 紅色斜線鈴鐺 */
.notification-push-toggle.denied {
    background: #ef4444;
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.notification-push-toggle.denied:hover {
    background: #dc2626;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
}

/* 載入狀態 */
.notification-push-toggle.loading {
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* 錯誤狀態 */
.notification-push-toggle.error {
    background: #f59e0b;
    color: white;
    animation: shake 0.5s ease-in-out;
}

/* 不支援狀態 */
.notification-push-toggle:not(.disabled):not(.enabled):not(.denied):not(.loading):not(.error) {
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* 小載入動畫 */
.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 搖晃動畫 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* 旋轉動畫 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 響應式設計 */
@media (max-width: 480px) {
    .notification-push-toggle {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .notification-modal-title-container {
        gap: 0.5rem;
    }
}

/* 暗黑模式適配 */
[data-theme="dark"] .notification-push-toggle.disabled {
    background: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .notification-push-toggle.disabled:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .notification-push-toggle.loading {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* 工具提示樣式 */
.notification-push-toggle[title] {
    position: relative;
}

.notification-push-toggle[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 0.5rem;
}

.notification-push-toggle[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--bg-primary);
    margin-bottom: 0.25rem;
}

/* ========================================
   材質工藝區塊樣式
   ======================================== */

/* 材質工藝區塊容器 */
.materials-techniques-section {
    margin-bottom: 1.5rem;
}

/* 材質工藝區塊專用樣式 - 使用更具體的選擇器 */
.modal-section:has([data-i18n="products.materials_techniques"]) .selected-items-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem !important;
}

/* 材質工藝說明文字 */
.modal-section:has([data-i18n="products.materials_techniques"]) .materials-techniques-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.375rem;
    border-left: 3px solid var(--accent);
}

/* 材質工藝區塊專用已選項目樣式 */
.modal-section:has([data-i18n="products.materials_techniques"]) .selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selected-item:hover {
    background: var(--hover-bg);
    border-color: var(--accent);
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selected-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.modal-section:has([data-i18n="products.materials_techniques"]) .item-code {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: monospace;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .item-order {
    font-weight: 600;
    color: var(--accent);
    min-width: 1.5rem;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .item-notes {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    border-left: 2px solid var(--accent);
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selected-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* 材質工藝區塊專用選擇容器 */
.modal-section:has([data-i18n="products.materials_techniques"]) .material-selection-container,
.modal-section:has([data-i18n="products.materials_techniques"]) .technique-selection-container {
    margin-bottom: 0.5rem !important;
}

/* 選擇框與管理按鈕的組合佈局 */
.modal-section:has([data-i18n="products.materials_techniques"]) .selection-with-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selection-with-action .form-control {
    flex: 1;
    width: auto !important; /* 覆蓋全域的 width: 100% */
    background: var(--input-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selection-with-action .management-btn {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color) !important;
    background: var(--input-bg) !important;
    color: var(--text-muted) !important;
    transition: all 0.2s ease;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .selection-with-action .management-btn:hover {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}

/* 材質工藝區塊專用標籤樣式 */
.modal-section:has([data-i18n="products.materials_techniques"]) .form-label {
    display: block;
    margin-bottom: 0.25rem !important; /* 減少標籤與內容間距 */
    font-weight: 500;
    color: var(--text-primary);
}

/* 材質工藝區塊輸入框樣式 */
.modal-section:has([data-i18n="products.materials_techniques"]) .form-control:focus {
    background: var(--input-bg) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1) !important;
}

.modal-section:has([data-i18n="products.materials_techniques"]) .form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.7;
}

/* 加工備註輸入框專用樣式 */
.modal-section:has([data-i18n="products.materials_techniques"]) #other-processing-notes {
    background: var(--card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.modal-section:has([data-i18n="products.materials_techniques"]) #other-processing-notes:focus {
    background: var(--card) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1) !important;
}

/* 材質工藝管理模態框 */
.large-modal {
    max-width: 800px;
    width: 90vw;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

/* 項目列表 */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.item-card:hover {
    background: var(--hover-bg);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.item-info {
    flex: 1;
}

.item-info .item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.item-details {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.item-category {
    background: var(--accent-bg);
    color: var(--accent);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

/* 表單網格調整 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: start;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .modal-section:has([data-i18n="products.materials_techniques"]) .selected-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .modal-section:has([data-i18n="products.materials_techniques"]) .selected-item-content {
        justify-content: space-between;
    }
    
    .modal-section:has([data-i18n="products.materials_techniques"]) .selected-item-actions {
        justify-content: flex-end;
    }
    
    .modal-section:has([data-i18n="products.materials_techniques"]) .selection-with-action {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .modal-section:has([data-i18n="products.materials_techniques"]) .management-btn {
        align-self: flex-end;
        width: auto;
        height: auto;
        padding: 0.25rem 0.75rem;
    }
    
    .item-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .item-actions {
        justify-content: flex-end;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* 暗黑模式調整 */
[data-theme="dark"] .modal-section:has([data-i18n="products.materials_techniques"]) .selected-item {
    background: var(--bg-secondary-dark);
    border-color: var(--border-color-dark);
}

[data-theme="dark"] .modal-section:has([data-i18n="products.materials_techniques"]) .selected-item:hover {
    background: var(--hover-bg-dark);
    border-color: var(--accent-dark);
}

/* 聯絡人Modal樣式 - 簡單實現，不阻擋其他元素 */
.contact-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200000;
}

.contact-modal-content {
    background: var(--card);
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 200001;
    pointer-events: auto;
}

/* 編輯Modal樣式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-overlay .modal-content {
    background: var(--card);
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-overlay .modal-content h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.modal-overlay .modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.modal-overlay .form-group {
    margin-bottom: 1rem;
}

.modal-overlay .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-overlay .form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

.modal-overlay .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.modal-overlay .form-control[readonly] {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* 暗黑模式編輯Modal */
[data-theme="dark"] .modal-overlay .modal-content {
    background: var(--card-dark);
    border: 1px solid var(--border-color-dark);
}

[data-theme="dark"] .modal-overlay .form-control {
    background: var(--input-bg-dark);
    border-color: var(--border-color-dark);
    color: var(--text-primary-dark);
}

[data-theme="dark"] .modal-overlay .form-control[readonly] {
    background: var(--bg-secondary-dark);
    color: var(--text-muted-dark);
}

[data-theme="dark"] .item-card {
    background: var(--card-bg-dark);
    border-color: var(--border-color-dark);
}

[data-theme="dark"] .item-card:hover {
    background: var(--hover-bg-dark);
    border-color: var(--accent-dark);
}

[data-theme="dark"] .item-category {
    background: var(--accent-bg-dark);
    color: var(--accent-dark);
}