/* ============================================================
   鹽酥紀 ERP v2 — 主樣式
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', '微軟正黑體', 'PingFang TC', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f4f5f7;
  min-height: 100vh;
  display: flex;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 13px; }

/* ── 佈局 ─────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; width: 100%; }

/* Sidebar */
#sidebar {
  width: 200px;
  min-height: 100vh;
  background: #1e2634;
  color: #c9d0db;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 20px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #2e3a4e;
  letter-spacing: 0.5px;
}

.sidebar-logo small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: #7a8599;
  margin-top: 2px;
}

.nav-section {
  padding: 12px 0 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: #5a6580;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: #9aa3b2;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.nav-item:hover { background: #26304a; color: #e0e5ef; }
.nav-item.active {
  background: #1a2a45;
  color: #fff;
  border-left-color: #4f8ef7;
  font-weight: 600;
}

/* Main */
#main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#top-bar {
  height: 50px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 13px;
  color: #6b7280;
  gap: 8px;
}

#page-root {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ── Page ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  margin-top: 4px;
}

.breadcrumb {
  font-size: 12px;
  color: #9ca3af;
}

.breadcrumb a { color: #4f8ef7; }
.breadcrumb a:hover { text-decoration: underline; }

.header-actions { display: flex; gap: 8px; align-items: center; }

.page-error {
  background: #fff1f1;
  color: #b91c1c;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #fecaca;
}

/* ── Section Cards ────────────────────────────────────────── */
.section-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-card-warn {
  border-color: #fcd34d;
  background: #fffbeb;
}

.section-card-disabled {
  border-color: #e5e7eb;
  background: #fafafa;
  opacity: 0.8;
}

/* Empty state（D 區 placeholder） */
.empty-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
}

.empty-state-icon {
  font-size: 20px;
  flex-shrink: 0;
  opacity: 0.45;
}

.empty-state-text {
  font-size: 13px;
  color: #9ca3af;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f3f4f6;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f3f4f6;
}

.section-header-row .section-title { margin: 0; padding: 0; border: 0; }

/* ── Form ─────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px;
}

.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field-full { grid-column: 1 / -1; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.form-label.required::after {
  content: ' *';
  color: #ef4444;
}

.form-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #111;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: #4f8ef7;
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

textarea.form-input {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.form-hint {
  font-size: 12px;
  color: #9ca3af;
  padding: 8px 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 16px;
  height: 36px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: #4f8ef7;
  color: #fff;
  border-color: #4f8ef7;
}
.btn-primary:hover { background: #3b7de8; border-color: #3b7de8; }

.btn-ghost {
  background: transparent;
  color: #374151;
  border-color: #d1d5db;
}
.btn-ghost:hover { background: #f9fafb; }

.btn-danger-ghost {
  background: transparent;
  color: #ef4444;
  border-color: #fca5a5;
}
.btn-danger-ghost:hover { background: #fff1f1; }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* ── Table ────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9fafb; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;   /* 絕對不換行 */
}

.badge-expired  { background: #f3e8ff; color: #7c3aed; }
.badge-expiring { background: #fff7ed; color: #ea580c; }
.badge-valid    { background: #ecfdf5; color: #059669; }
.badge-nodate   { background: #f3f4f6; color: #6b7280; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #111;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #9ca3af;
  line-height: 1;
  padding: 0;
}
.modal-close-btn:hover { color: #374151; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
}

/* ── Toast ────────────────────────────────────────────────── */
#ysk2-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#ysk2-toast.toast-show {
  opacity: 1;
  transform: translateY(0);
}

#ysk2-toast.toast-success { background: #059669; color: #fff; }
#ysk2-toast.toast-error   { background: #dc2626; color: #fff; }
#ysk2-toast.toast-info    { background: #2563eb; color: #fff; }

/* ── Dashboard ────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.stat-num {
  font-size: 36px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 13px;
  color: #6b7280;
}

.stat-warn .stat-num  { color: #ea580c; }
.stat-danger .stat-num { color: #dc2626; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 52px; }
  .sidebar-logo, .nav-section-label, .nav-item span { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field-full { grid-column: 1; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
