/* 永豐順肉品 — 共用設計系統 */

:root {
  --primary: #C0392B;
  --primary-dark: #962d22;
  --primary-light: #fdecea;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #2563eb;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);

  --header-h: 64px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ────────────  排版輔助  ──────────── */
.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { display: flex; gap: 12px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ────────────  按鈕  ──────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s, box-shadow .15s;
  font-family: inherit;
}
.btn:hover:not(:disabled) { background: var(--primary-dark); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-block { width: 100%; }
.btn-lg { height: 52px; font-size: 17px; padding: 0 24px; }
.btn-sm { height: 34px; font-size: 13px; padding: 0 12px; border-radius: var(--radius-sm); }

.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #f3f4f6; }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

.btn-danger { background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

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

/* ────────────  表單  ──────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 500; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.field .err { font-size: 13px; color: var(--danger); }
.input, .select, .textarea {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px;
  background: white;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.textarea { height: auto; padding: 10px 14px; min-height: 80px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.input.error { border-color: var(--danger); }

/* ────────────  卡片  ──────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card-lg { padding: 28px 32px; }

/* ────────────  Toggle 開關  ──────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background .2s;
  cursor: pointer;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(20px); }
.toggle input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* ────────────  徽章  ──────────── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-muted { background: #f3f4f6; color: #6b7280; }

/* ────────────  表格  ──────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.table th {
  background: #f9fafb;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }

/* ────────────  Toast  ──────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 18px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  border-left: 4px solid var(--primary);
  pointer-events: auto;
  animation: toast-in .25s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ────────────  Loading  ──────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
#loading-overlay.show { display: flex; }
.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-inline {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}

/* ────────────  Modal  ──────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ────────────  響應式  ──────────── */
@media (max-width: 720px) {
  .card { padding: 16px; }
  .card-lg { padding: 20px; }
  .table th, .table td { padding: 10px 8px; font-size: 13px; }
  .modal-body { padding: 16px; }
}
