/* ===================== 3鑫五金百貨管理系統 - 主題樣式 ===================== */
:root {
  --primary-color: #1E2A3A;
  --primary-light: #2E3E54;
  --accent-gold: #F5A623;
  --accent-yellow: #FFC107;

  --bg-light: #F5F6FA;
  --bg-card: #FFFFFF;
  --bg-grey: #F0F2F5;

  --repair-color: #4A90D9;
  --quotation-color: #7ED321;
  --purchase-color: #9B59B6;
  --price-list-color: #E67E22;
  --inventory-color: #1ABC9C;
  --procurement-color: #E74C3C;

  --status-yellow: #FFC107;
  --status-green: #27AE60;
  --status-red: #E74C3C;
  --status-grey: #95A5A6;

  --text-primary: #1E2A3A;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --text-white: #FFFFFF;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg-light);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button {
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
button:focus { outline: none; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-light);
  position: relative;
  padding-bottom: 24px;
}

/* ---------- App Bar ---------- */
.app-bar {
  background: var(--primary-color);
  color: var(--text-white);
  display: flex;
  align-items: center;
  padding: 14px 8px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-bar .app-bar-back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: #fff;
  flex-shrink: 0;
}
.app-bar .app-bar-back:active { background: rgba(255,255,255,0.15); }
.app-bar-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-bar-action {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: #fff;
  flex-shrink: 0;
}
.app-bar-action:active { background: rgba(255,255,255,0.15); }
.app-bar-spacer { width: 40px; flex-shrink: 0; }

/* ---------- Home Header ---------- */
.home-header {
  background: var(--primary-color);
  padding: 18px 20px 14px 20px;
}
.home-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.home-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.home-header-bar {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  background: var(--accent-gold);
}
.home-header-text .line1 {
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
}
.home-header-text .line2 {
  color: #CBD5E1;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 2px;
}
.home-header-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  border: none;
}
.home-header-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #90A4C0;
  font-size: 12px;
  margin-top: 14px;
}
.home-header-divider {
  height: 2px;
  background: rgba(245, 166, 35, 0.5);
  margin-top: 12px;
  border-radius: 2px;
}

/* ---------- Module Grid ---------- */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px 16px 8px 16px;
}
.module-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 1 / 1.05;
  display: block;
  --mcolor: #4A90D9;
  box-shadow: 0 4px 12px 2px color-mix(in srgb, var(--mcolor) 12%, transparent);
}
.module-card .corner-triangle {
  position: absolute;
  top: 0; left: 0;
  width: 48px; height: 48px;
  background: color-mix(in srgb, var(--mcolor) 80%, transparent);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  border-radius: 18px 0 0 0;
}
.module-card .corner-circle {
  position: absolute;
  bottom: -16px; right: -16px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--mcolor) 6%, transparent);
}
.module-card-content {
  position: relative;
  padding: 18px 16px 14px 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.module-icon-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--mcolor) 10%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: var(--mcolor);
  font-size: 24px;
}
.module-card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 8px;
}
.module-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.module-subtitle { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.module-arrow {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--mcolor);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* ---------- Cards / Sections ---------- */
.section-pad { padding: 16px; }
.card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.list-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 12px;
  padding: 14px 14px 14px 12px;
  border-left: 4px solid var(--status-grey);
  display: block;
}
.list-card .row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.list-card .product-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.list-card .sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12.5px;
}
.list-card .warning-bar {
  margin-top: 8px;
  background: rgba(231, 76, 60, 0.1);
  color: var(--status-red);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.list-card .low-stock-bar {
  margin-top: 8px;
  background: rgba(255, 193, 7, 0.15);
  color: #B7791B;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
}
.list-card .critical-stock-bar {
  margin-top: 8px;
  background: rgba(231, 76, 60, 0.12);
  color: var(--status-red);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  font-weight: 600;
}

/* ---------- Search Bar ---------- */
.search-bar-wrap { padding: 12px 16px 4px 16px; }
.search-bar {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
}
.search-bar input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--text-primary);
}
.search-bar i.fa-magnifying-glass { color: var(--text-light); }
.search-bar .clear-btn { color: var(--text-light); display: none; }

/* ---------- Tabs ---------- */
.tab-bar {
  display: flex;
  background: var(--primary-color);
}
.tab-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.tab-item:focus { outline: none; }
.tab-item.active { color: #fff; border-bottom-color: var(--accent-gold); background: rgba(255,255,255,0.06); }

/* ---------- Status Badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: calc(100% - 32px);
  display: flex;
  justify-content: flex-end;
}
.fab-btn {
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Form ---------- */
.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 10px 0;
}
.form-section-title .bar {
  width: 4px; height: 18px; border-radius: 2px;
}
.form-section-title span { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.field-label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; display:block; font-weight: 500;}
.input-field, .textarea-field, select.input-field {
  width: 100%;
  background: var(--bg-grey);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
}
.input-field:focus, .textarea-field:focus, select.input-field:focus {
  border-color: var(--primary-color);
  border-width: 2px;
  background: #fff;
}
.textarea-field { min-height: 80px; resize: vertical; }
.field-group { margin-bottom: 14px; }

.save-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  margin-top: 24px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.save-btn:active { filter: brightness(0.92); }

/* ---------- Date Selector ---------- */
.date-selector {
  position: relative;
  background: var(--bg-grey);
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  font-size: 14px;
}
.date-selector input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
}

/* ---------- Quantity Control ---------- */
.qty-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qty-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.qty-minus { background: var(--status-red); }
.qty-plus { background: var(--status-green); }
.qty-value {
  min-width: 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  background: var(--bg-grey);
  border-radius: 8px;
  padding: 8px 10px;
}

/* ---------- Photo Upload ---------- */
.photo-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;}
.photo-thumb {
  width: 80px; height: 80px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  border: 2px solid #d1d5db;
  background: #eee;
}
.photo-thumb.photo-new { border-color: var(--accent-gold); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .remove-btn {
  position: absolute;
  top: 2px; right: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--status-red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  border: none;
}
.photo-add-btn {
  width: 80px; height: 80px;
  border-radius: 10px;
  background: var(--bg-grey);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-light);
  gap: 4px;
  border: none;
  font-size: 11px;
}
.photo-add-btn i { font-size: 20px; }

/* ---------- Supplier Selector ---------- */
.supplier-select-box {
  background: var(--bg-grey);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #E5E7EB;
}
.supplier-select-box .value-text { font-size: 14px; font-weight: 600; }
.supplier-select-box .placeholder { color: var(--text-light); font-weight: 400; }

/* ---------- Bottom Sheet / Modal ---------- */
.overlay-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay-mask.center-modal { align-items: center; padding: 20px; }
.bottom-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 40px; height: 5px;
  background: #d1d5db;
  border-radius: 3px;
  margin: 10px auto 6px auto;
}
.sheet-body { overflow-y: auto; padding: 8px 16px 20px 16px; }
.sheet-title { font-size: 15px; font-weight: 700; text-align: center; padding: 4px 0 10px 0; color: var(--text-primary); }
.sheet-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid #F0F2F5;
}
.sheet-avatar {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--repair-color);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.sheet-list-item .main-text { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.sheet-list-item .sub-text { font-size: 11.5px; color: var(--text-light); }

.center-dialog {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 340px;
  padding: 20px;
  animation: popIn 0.15s ease-out;
}
@keyframes popIn { from { transform: scale(0.92); opacity:0;} to { transform: scale(1); opacity: 1;} }
.center-dialog .dialog-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 14px;}
.center-dialog .dialog-content { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 18px; line-height: 1.6;}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
}
.dialog-btn.cancel { background: transparent; color: var(--text-secondary); }
.dialog-btn.confirm { background: var(--primary-color); color: #fff; }
.dialog-btn.danger { background: var(--status-red); color: #fff; }

/* ---------- Status action buttons ---------- */
.status-btn-row { display: flex; gap: 8px; margin-top: 10px; }
.status-btn {
  flex: 1;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  border: 1.5px solid transparent;
  transition: all 0.2s;
}
.status-info-bar {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 30px;
  text-align: center;
}
.empty-state i { font-size: 72px; margin-bottom: 16px; }
.empty-state .title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px;}
.empty-state .subtitle { font-size: 13px; color: var(--text-secondary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-color);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* misc */
.loading-spin { text-align: center; padding: 40px; color: var(--text-light); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.supplier-avatar-sm {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: var(--repair-color);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.icon-btn { border: none; background: transparent; color: var(--text-secondary); width: 36px; height: 36px; display:flex; align-items:center; justify-content:center; border-radius: 8px;}
.icon-btn:active { background: var(--bg-grey); }

#barcode-reader { width: 100%; border-radius: 12px; overflow: hidden; }
