/* ============================================================
   排班管理系統 - 全站樣式
   字型：Noto Sans TC（繁體中文最佳化）+ DM Mono（數字）
   主色：深藍側邊欄 + 青色強調
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS 變數 ─────────────────────────────────────────────── */
:root {
  --navy:        #1e293b;
  --navy-hover:  #2d3f55;
  --navy-border: #334155;
  --cyan:        #0891b2;
  --cyan-dark:   #0e7490;
  --cyan-light:  #e0f7fa;
  --bg:          #f0f4f8;
  --card:        #ffffff;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --transition:  .2s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 23px; scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-dark); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── 版面框架 ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── 側邊欄 ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--navy-border);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.sidebar-brand .logo {
  width: 34px; height: 34px;
  background: var(--cyan);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.sidebar-brand .brand-text {
  color: #f1f5f9;
  font-weight: 700;
  font-size: .85rem;
  line-height: 1.3;
}
.sidebar-brand .brand-sub {
  color: #94a3b8;
  font-size: .72rem;
  font-weight: 400;
}

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-section {
  padding: .5rem 1rem .2rem;
  color: #64748b;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem 1rem;
  color: #cbd5e1;
  font-size: .85rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--navy-hover);
  color: #f1f5f9;
}
.nav-item.active {
  background: rgba(8,145,178,.15);
  color: var(--cyan);
  border-left-color: var(--cyan);
  font-weight: 600;
}
.nav-item .icon { font-size: 1rem; width: 1.2rem; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--navy-border);
}
.sidebar-user {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--navy-hover); }
.sidebar-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--cyan);
  display: grid; place-items: center;
  color: #fff; font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-name { color: #f1f5f9; font-size: .82rem; font-weight: 600; }
.sidebar-user .user-role { color: #94a3b8; font-size: .7rem; }

/* ── 主內容區 ────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── 頂部欄 ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
.topbar-toggle {
  display: none;
  background: none; border: none;
  cursor: pointer; color: var(--text-muted); font-size: 1.3rem;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-company {
  background: var(--cyan-light);
  color: var(--cyan-dark);
  padding: .25rem .7rem;
  border-radius: 20px;
  font-size: .78rem; font-weight: 600;
}

/* ── 頁面內容 ────────────────────────────────────────────── */
.content { padding: 1.5rem; flex: 1; }

/* ── 頁面標題 ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-title { font-size: 1.3rem; font-weight: 700; }
.page-title small { display: block; font-size: .78rem; color: var(--text-muted); font-weight: 400; margin-top: .1rem; }

/* ── 卡片 ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  flex-wrap: wrap;
}
.card-title { font-size: .95rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafafa;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── 統計卡片 ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.cyan  { background: #e0f7fa; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.amber { background: #fef3c7; }
.stat-icon.rose  { background: #ffe4e6; }
.stat-icon.blue  { background: #dbeafe; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ── 按鈕 ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 7px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--cyan); color: #fff; }
.btn-primary:hover { background: var(--cyan-dark); color: #fff; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; border-radius: 5px; }
.btn-xs { padding: .2rem .5rem; font-size: .72rem; border-radius: 4px; }
.btn-outline {
  background: transparent; border: 1.5px solid var(--cyan);
  color: var(--cyan);
}
.btn-outline:hover { background: var(--cyan); color: #fff; }

/* ── 表格 ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
  white-space: nowrap;
}
table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #f8fafc; }
.td-actions { display: flex; gap: .3rem; flex-wrap: wrap; }

/* ── 表單 ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.form-label .req { color: var(--danger); }
.form-control {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--card);
  color: var(--text);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; flex-wrap: wrap; }

/* ── 徽章 ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-cyan    { background: var(--cyan-light); color: var(--cyan-dark); }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-amber   { background: #fef3c7; color: #92400e; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-navy    { background: #e2e8f0; color: var(--navy); }
.badge-blue    { background: #dbeafe; color: #1e40af; }

/* ── Flash 訊息 ──────────────────────────────────────────── */
.flash {
  padding: .8rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: .87rem;
  font-weight: 500;
  display: flex; align-items: center; gap: .6rem;
}
.flash-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.flash-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.flash-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }
.flash-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }

/* ── 搜尋列 ──────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.search-bar .form-control { flex: 1; min-width: 180px; }

/* ── 排班格 ──────────────────────────────────────────────── */
.schedule-grid { overflow-x: auto; }
.schedule-table { border-collapse: separate; border-spacing: 2px; min-width: 900px; }
.schedule-table th {
  background: #f8fafc;
  padding: .5rem .4rem;
  font-size: .72rem;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-muted);
}
.schedule-table th.today-col { background: var(--cyan-light); color: var(--cyan-dark); }
.schedule-table td {
  padding: .3rem .2rem;
  text-align: center;
  font-size: .75rem;
  border: none; border-bottom: none;
  min-width: 50px;
}
.schedule-table td.emp-name {
  text-align: left;
  padding: .4rem .75rem;
  white-space: nowrap;
  font-weight: 600;
  font-size: .8rem;
  background: #f8fafc;
  border-right: 2px solid var(--border);
  position: sticky; left: 0;
  min-width: 100px;
}
.shift-cell {
  display: block;
  padding: .22rem .3rem;
  border-radius: 5px;
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.shift-cell:hover { opacity: .8; }
.shift-empty {
  display: block; padding: .22rem .3rem;
  border-radius: 5px;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: .7rem;
}
.shift-holiday {
  background: #f1f5f9; color: #94a3b8;
}

/* ── 分頁 ────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: .4rem;
  flex-wrap: wrap; margin-top: 1rem;
}
.pagination a, .pagination span {
  padding: .35rem .65rem;
  border-radius: 6px;
  font-size: .82rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--card);
  transition: all var(--transition);
  text-decoration: none;
}
.pagination a:hover { background: var(--cyan); color: #fff; border-color: var(--cyan); }
.pagination span.current { background: var(--cyan); color: #fff; border-color: var(--cyan); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200; display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--text-muted); }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── 顏色點 ──────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: .35rem;
}

/* ── 輔助 ────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .8rem; }
.text-center  { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }
.d-none { display: none; }
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

/* ── 手機版 RWD ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

  .topbar-toggle { display: block; }

  .content { padding: 1rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .form-grid { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-company { display: none; }
}

/* ── 登入頁 ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1f35 0%, #1e293b 50%, #0c4a6e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(8,145,178,.15) 0%, transparent 70%);
  top: -100px; right: -100px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(8,145,178,.1) 0%, transparent 70%);
  bottom: -100px; left: -50px;
  pointer-events: none;
}
.login-card {
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 400px;
  position: relative; z-index: 1;
  animation: slideUp .4s ease;
}
.login-logo {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.75rem;
}
.login-logo .logo-icon {
  width: 44px; height: 44px;
  background: var(--cyan);
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.4rem;
}
.login-logo .logo-text { color: #fff; }
.login-logo .logo-name { font-size: 1.1rem; font-weight: 700; }
.login-logo .logo-sub  { font-size: .75rem; color: #94a3b8; }
.login-card h2 { color: #f1f5f9; font-size: 1.4rem; font-weight: 700; margin-bottom: .4rem; }
.login-card .sub { color: #94a3b8; font-size: .85rem; margin-bottom: 1.75rem; }
.login-card .form-label { color: #94a3b8; }
.login-card .form-control {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
  color: #f1f5f9;
}
.login-card .form-control::placeholder { color: #475569; }
.login-card .form-control:focus { border-color: var(--cyan); background: rgba(255,255,255,.1); }
.login-btn {
  width: 100%; padding: .7rem;
  background: var(--cyan); color: #fff;
  border: none; border-radius: 8px;
  font-size: .95rem; font-weight: 700;
  cursor: pointer; margin-top: 1rem;
  transition: background var(--transition);
}
.login-btn:hover { background: var(--cyan-dark); }
.login-hint { color: #64748b; font-size: .75rem; text-align: center; margin-top: 1rem; }
