/* ============ 醫院後勤智慧管理系統 · 樣式 ============ */
:root {
  --primary: #1e6fba;
  --primary-dark: #16538c;
  --primary-light: #e8f1fa;
  --sidebar-bg: #123a5f;
  --sidebar-text: #cfe3f5;
  --sidebar-active: #1e6fba;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #24303c;
  --text-light: #6b7a8a;
  --border: #dfe6ee;
  --green: #1e9e5a;
  --green-bg: #e6f6ee;
  --yellow: #d99a06;
  --yellow-bg: #fdf3dc;
  --red: #d64545;
  --red-bg: #fdeaea;
  --blue: #1e6fba;
  --blue-bg: #e8f1fa;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(18, 58, 95, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
code { background: #f0f3f7; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ============ 按鈕 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b93a3a; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(18,58,95,.08); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-icon { position: relative; padding: 8px 10px; font-size: 18px; }
.btn-block { width: 100%; }

/* ============ 登入頁 ============ */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0e2f4e 0%, #1e6fba 60%, #3a94d8 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center;
}
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; color: var(--primary-dark); margin-bottom: 4px; }
.login-sub { color: var(--text-light); font-size: 13px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
  font-family: inherit; text-align: center; letter-spacing: 2px;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.login-error { color: var(--red); font-size: 13px; }
.login-hint { margin-top: 16px; color: var(--text-light); font-size: 13px; }
.login-foot { margin-top: 20px; color: #a8b4c0; font-size: 12px; }

/* ============ 主框架 ============ */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 30; transition: transform .2s;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo-icon { font-size: 30px; }
.sidebar-logo-title { font-weight: 700; color: #fff; font-size: 15px; }
.sidebar-logo-sub { font-size: 11px; opacity: .7; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group { padding: 14px 16px 6px; font-size: 11px; letter-spacing: 1px; opacity: .55; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: var(--sidebar-text);
  font-size: 14px; cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #6fc3ff; font-weight: 600; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .nav-item { padding: 8px 10px; }
.sidebar-foot .btn-ghost { color: var(--sidebar-text); justify-content: flex-start; }

.main { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 10px 20px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 17px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-clock { color: var(--text-light); font-variant-numeric: tabular-nums; font-size: 13px; }
.topbar-user { color: var(--text-light); font-size: 13px; }
.notif-badge {
  position: absolute; top: 0; right: 0; background: var(--red); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; line-height: 16px;
  padding: 0 4px; font-weight: 700;
}
.content { padding: 20px; flex: 1; }

.sidebar-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .topbar-clock, .topbar-user { display: none; }
  .content { padding: 12px; }
}

/* ============ 卡片 ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title .sub { font-size: 12px; color: var(--text-light); font-weight: 400; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ============ KPI 卡片 ============ */
.kpi { padding: 16px 18px; }
.kpi .kpi-label { color: var(--text-light); font-size: 12px; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.kpi.green { background: var(--green-bg); border-left: 4px solid var(--green); }
.kpi.blue { background: var(--blue-bg); border-left: 4px solid var(--blue); }
.kpi.yellow { background: var(--yellow-bg); border-left: 4px solid var(--yellow); }
.kpi.red { background: var(--red-bg); border-left: 4px solid var(--red); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-light); font-size: 12px; font-weight: 600; background: #f8fafc; }
tr:hover td { background: #f8fafc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: 6px; }

/* ============ 徽章 / 燈號 ============ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: #eef1f5; color: var(--text-light); }
.light { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.light.green { background: var(--green); }
.light.yellow { background: var(--yellow); }
.light.red { background: var(--red); }
.light.gray { background: #c3ccd6; }

/* ============ 表單 ============ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-light); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.field .hint { font-size: 12px; color: var(--text-light); }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,25,40,.45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: #fff; border-radius: 14px; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 16px 50px rgba(0,0,0,.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; border-radius: 14px 14px 0 0; }
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: #fff; border-radius: 0 0 14px 14px; }

/* ============ Toast ============ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast {
  background: #fff; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
  padding: 12px 16px; display: flex; gap: 10px; align-items: flex-start; animation: slideIn .25s ease;
  border-left: 4px solid var(--blue); font-size: 13.5px;
}
.toast.green { border-left-color: var(--green); }
.toast.yellow { border-left-color: var(--yellow); }
.toast.red { border-left-color: var(--red); }
.toast .t-icon { font-size: 18px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ 通知抽屜 ============ */
.drawer-overlay { position: fixed; inset: 0; background: rgba(10,25,40,.35); z-index: 70; }
.notif-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 92vw; background: #fff;
  z-index: 80; box-shadow: -6px 0 30px rgba(0,0,0,.15); display: flex; flex-direction: column;
  animation: slideLeft .2s ease;
}
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.notif-list { flex: 1; overflow-y: auto; padding: 10px 14px; }
.notif-item { padding: 12px; border-radius: 10px; border-left: 4px solid var(--blue); background: #f8fafc; margin-bottom: 8px; }
.notif-item.red { border-left-color: var(--red); background: var(--red-bg); }
.notif-item.yellow { border-left-color: var(--yellow); background: var(--yellow-bg); }
.notif-item.green { border-left-color: var(--green); background: var(--green-bg); }
.notif-item .n-title { font-weight: 700; font-size: 13.5px; }
.notif-item .n-body { font-size: 12.5px; color: var(--text-light); margin-top: 2px; }
.notif-item .n-time { font-size: 11px; color: #a8b4c0; margin-top: 4px; }
.notif-empty { color: var(--text-light); text-align: center; padding: 40px 0; font-size: 13px; }

/* ============ 儀表板 ============ */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.qa-btn {
  flex: 1 1 150px; padding: 14px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: center; font-family: inherit; font-size: 13px;
  transition: all .15s;
}
.qa-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.qa-btn .qa-icon { display: block; font-size: 22px; margin-bottom: 4px; }
.alert-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.alert-row.red { background: var(--red-bg); }
.alert-row.yellow { background: var(--yellow-bg); }
.alert-row .alert-msg { flex: 1; }
.alert-row .alert-time { color: var(--text-light); font-size: 12px; }

/* ============ 其他 ============ */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; font-family: inherit; width: 220px;
}
.toolbar .search input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.stat-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-pill { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.page-desc { color: var(--text-light); font-size: 13px; margin-bottom: 14px; }
.empty-state { text-align: center; padding: 40px 0; color: var(--text-light); }
.timeline { border-left: 3px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline-item { position: relative; padding: 0 0 16px 6px; }
.timeline-item::before {
  content: ""; position: absolute; left: -25px; top: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--border);
}
.timeline-item.done::before { background: var(--green); }
.timeline-item.current::before { background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-bg); }
.timeline-item .t-time { font-size: 11.5px; color: var(--text-light); }
.timeline-item .t-title { font-weight: 600; }
.timeline-item .t-by { font-size: 12px; color: var(--text-light); }
.progress { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 4px; }
