/* 企業級庫存管理系統專業核心樣式表 (現代頂級 SaaS 工作台風格) */
:root {
  --primary: #0f766e;
  --primary-dark: #0a2d30;
  --primary-hover: #115e59;
  --primary-light: #f0fdfa;
  --secondary: #0284c7;
  --accent: #14b8a6;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --sidebar-bg: #0b3a3d;
  --sidebar-hover: #134e4a;
  --sidebar-active: #042f2e;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #99f6e4;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* 頂部導航列 */
.navbar {
  background: linear-gradient(135deg, #0b3a3d 0%, #062326 100%);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-badge {
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-link {
  color: #cbd5e1;
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.15);
}

.nav-link.highlight {
  background-color: #22c55e;
  color: #ffffff;
  font-weight: 600;
}
.nav-link.highlight:hover {
  background-color: #16a34a;
}

/* 主版面佈局 */
.container {
  max-width: 1320px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
}

/* 儀表板關鍵指標卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.icon-blue { background: #dbeafe; color: #1d4ed8; }
.icon-green { background: #dcfce7; color: #15803d; }
.icon-amber { background: #fef3c7; color: #b45309; }
.icon-red { background: #fee2e2; color: #b91c1c; }
.icon-purple { background: #f3e8ff; color: #7e22ce; }

/* 區塊卡片 */
.card {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafbfc;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.25rem;
}

/* 按鈕樣式 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #15803d;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: #f1f5f9;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* 篩選與工具列 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  max-width: 500px;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
  background-color: #ffffff;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 表格樣式 (專業商用風格) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th {
  background-color: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:hover td {
  background-color: #f8fafc;
}

/* 膠囊徽章 */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1;
}

.badge-in { background-color: #dcfce7; color: #15803d; }
.badge-out { background-color: #fee2e2; color: #b91c1c; }
.badge-adjust { background-color: #fef3c7; color: #b45309; }
.badge-alert { background-color: #fef2f2; color: #ef4444; border: 1px solid #fca5a5; }
.badge-normal { background-color: #e0f2fe; color: #0369a1; }

/* 彈窗樣式 (Modal) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: #fafbfc;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* 分頁控制器 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 標籤列印樣式 */
@media print {
  body * {
    visibility: hidden;
  }
  .print-area, .print-area * {
    visibility: visible;
  }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}

/* ======================================================================
   現代頂級 SaaS 庫存工作台專屬樣式體系 (Modern SaaS Stock Workbench)
   ====================================================================== */

/* 1. 全螢幕工作台外殼 */
.saas-layout {
  display: flex;
  min-height: 100vh;
  background-color: #f8fafc;
  color: #0f172a;
}

/* 2. 左側深墨綠導航側邊欄 */
.saas-sidebar {
  width: 240px;
  background-color: #0b3a3d;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #092c2e;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.saas-sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.saas-logo-cube {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(20, 184, 166, 0.3);
  color: #ffffff;
  font-size: 1.4rem;
}

.saas-brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.saas-brand-subtitle {
  font-size: 0.72rem;
  color: #99f6e4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.saas-nav-list {
  list-style: none;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.saas-nav-item a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: #ccfbf1;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.saas-nav-item a:hover {
  background-color: #134e4a;
  color: #ffffff;
}

.saas-nav-item.active a {
  background-color: #134e4a;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.saas-nav-icon {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
}

.saas-sidebar-footer {
  padding: 1rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.saas-sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  color: #99f6e4;
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.15s;
}

.saas-sidebar-footer a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* 3. 主工作區與右側面板 (雙欄 Grid) */
.saas-main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1650px;
  width: 100%;
}

.saas-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 450px);
  gap: 1.5rem;
  align-items: start;
}

/* 4. 白色卡片封裝器 */
.saas-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  overflow: hidden;
}

/* 5. 中間商品清冊頂部工具列 */
.stock-header-bar {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stock-title-wrap h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.stock-title-wrap p {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.stock-filter-bar {
  padding: 0.85rem 1.5rem;
  background-color: #fafbfc;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input-wrap span {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.95rem;
  pointer-events: none;
}

.modern-search-input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.3rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modern-search-input:focus {
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.modern-select {
  padding: 0.55rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.modern-select:focus {
  border-color: #0d9488;
}

/* 6. 現代卡片清單表格 (還原圖片視覺) */
.modern-table {
  width: 100%;
  border-collapse: collapse;
}

.modern-table th {
  padding: 0.85rem 1.25rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.modern-table td {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  vertical-align: middle;
}

.stock-table-row {
  cursor: pointer;
  transition: background-color 0.15s;
}

.stock-table-row:hover {
  background-color: #f8fafc;
}

.stock-table-row.selected {
  background-color: #f0fdfa;
  box-shadow: inset 3px 0 0 #0d9488;
}

.item-thumb-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.item-thumb-box {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
}

.item-name-wrap {
  display: flex;
  flex-direction: column;
}

.item-title-text {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.92rem;
}

.item-desc-text {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.sku-pill {
  font-family: monospace;
  font-size: 0.8rem;
  background: #f1f5f9;
  color: #334155;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

/* 7. 庫存狀態指示膠囊 (In stock / Low stock / Out of stock) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-in-stock {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.status-in-stock .status-dot {
  background-color: #10b981;
}

.status-low-stock {
  background-color: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.status-low-stock .status-dot {
  background-color: #f59e0b;
}

.status-out-stock {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.status-out-stock .status-dot {
  background-color: #ef4444;
}

.row-arrow {
  color: #cbd5e1;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: right;
}

/* 8. 右側工作卡片：選中商品詳情 + 4 格 KPI */
.detail-header {
  padding: 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-sku-sub {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.2rem;
}

.detail-sku-sub span {
  color: #0d9488;
  font-weight: 600;
}

.kpi-four-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  padding: 1.25rem;
  background-color: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.kpi-box {
  background: #f8fafc;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #f1f5f9;
}

.kpi-label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.kpi-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.kpi-num.highlight-teal {
  color: #0d9488;
}

/* 9. 最近出入庫異動清單 */
.recent-move-wrap {
  padding: 1.25rem;
}

.recent-move-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
}

.recent-move-title a {
  font-size: 0.78rem;
  color: #0d9488;
  text-decoration: none;
  font-weight: 600;
}

.mini-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.mini-log-table th {
  padding: 0.45rem 0.5rem;
  text-align: left;
  color: #94a3b8;
  font-weight: 500;
  border-bottom: 1px solid #f1f5f9;
}

.mini-log-table td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid #f8fafc;
  color: #334155;
}

.btn-adjust-main {
  width: 100%;
  margin-top: 1rem;
  background-color: #0d5f62;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.15s;
}

.btn-adjust-main:hover {
  background-color: #08484a;
}

/* 10. 下方：庫存審核調整面板 (Review Adjustment) */
.review-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.review-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: #f0fdfa;
  color: #0d9488;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.stepper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 1.25rem;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  background-color: #ffffff;
}

.step-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.step-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.step-val.adj-val {
  color: #dc2626;
}

.step-val.adj-val.positive {
  color: #16a34a;
}

.review-form-wrap {
  padding: 1.25rem;
}

.review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-cancel {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-confirm {
  background: #0d5f62;
  border: 1px solid #0d5f62;
  color: #ffffff;
  padding: 0.5rem 1.15rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-confirm:hover {
  background: #08484a;
}

/* 響應式佈局支援 */
@media (max-width: 1200px) {
  .saas-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .saas-layout {
    flex-direction: column;
  }
  .saas-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .saas-main {
    padding: 1rem;
  }
  .kpi-four-grid {
    grid-template-columns: 1fr 1fr;
  }
}

