/* ══════════════════════════════
   上鎧鋼鐵 廠務工單系統 — 共用樣式
   視覺依據：上鎧鋼鐵 CIS 3.0 (2026-07)
   ※ 色彩／字體變數統一定義在 tokens.css
   ══════════════════════════════ */

@import url('tokens.css');

/* ── Reset ── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;            /* CIS 內文基準 1x = 16px */
  letter-spacing: var(--track-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
/* CIS 標題：Semibold + 寬字距。字級依工具型介面密度收斂，
   保留 CIS 的階層比例，不套用品牌主視覺的 64px */
h1, h2, h3 { color: var(--ink); font-weight: 600; letter-spacing: var(--track-title); }

/* ── Header ── */
header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
header .brand img {
  height: 30px;
  width: auto;
  flex-shrink: 0;
}
header .brand-text {
  border-left: 2px solid var(--border);
  padding-left: 10px;
  line-height: 1.2;
  min-width: 0;
}
header .brand-text .title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header .brand-text .sub {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 漢堡下拉選單 ── */
.menu-toggle {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  min-height: 36px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--bg); }
.dropdown-menu {
  display: none;
  position: fixed;
  top: 56px;
  right: 8px;
  background: #fff;
  border-radius: 12px;
  min-width: 170px;
  z-index: 999;
  padding: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  animation: menuIn .15s ease;
}
.dropdown-menu.show { display: block; }
@keyframes menuIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
}
.dropdown-menu a:hover { background: var(--bg); }
.dropdown-menu a.nav-active { color: var(--brand); background: var(--brand-soft); }
.dropdown-menu .menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.dropdown-menu a.menu-logout { color: var(--muted); }

/* ── Container ── */
.container {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
}

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.02);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
}

/* ── Buttons ── */
button {
  appearance: none;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: transform .08s, opacity .15s, background .15s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-text); color: #fff; box-shadow: 0 2px 6px rgba(240,29,15,.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f7f7f9; }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 2px 6px rgba(46,160,67,.25); }
.btn-danger { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-danger:hover:not(:disabled) { background: var(--brand-soft); }
.btn-block { width: 100%; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ── Inputs ── */
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
input[type=text], input[type=password], input[type=date], textarea, select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240,29,15,.12);
}
textarea { min-height: 70px; resize: vertical; }

/* ── Badge ── */
.badge {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge.ok { background: var(--success); color: #fff; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28,28,30,.95);
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  display: none;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#toast.show { display: block; }
#toast.error { background: var(--brand); }
#toast.success { background: var(--success); }

/* ── Table 通用 ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  text-align: left;
  padding: 10px 8px;
  background: #fafafc;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
tr:hover { background: #fafafc; }

/* ── 分隔線 ── */
.or-divider {
  display: flex;
  align-items: center;
  margin: 14px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.or-divider::before, .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.or-divider::before { margin-right: 12px; }
.or-divider::after { margin-left: 12px; }

/* ── 必填標籤 ── */
.required {
  background: var(--brand);
  color: #fff;
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: .5px;
  font-weight: 700;
}

/* ── RWD ── */
@media (max-width: 480px) {
  header .brand img { height: 26px; }
  header .brand-text { padding-left: 8px; }
  header .brand-text .title { font-size: 12px; }
}
