/* ======================================================================
   app.css — ธีม "Logistics Blueprint" (light / technical)
   accent: teal · fonts: Anuphan + JetBrains Mono
   ทับ Bootstrap 5.3 ด้วย CSS variables + override เฉพาะจุด
   *** คงชื่อคลาสเดิมทุกตัว (sidebar__*, stat, content ฯลฯ) ***
   ====================================================================== */

:root {
  --accent: #0e7c86; /* teal */
  --accent-600: #0a626b;
  --accent-700: #074e55;
  --accent-soft: #e6f2f3; /* tint อ่อน */
  --accent-line: #bfe0e2;

  --bg: #eef2f4; /* พื้นนอกการ์ด */
  --grid: #e2e8ea; /* เส้นบลูพรินต์ */
  --card: #ffffff;
  --line: #e2e7ea;
  --line-soft: #eef1f3;
  --ink: #14202b; /* ข้อความหลัก */
  --ink-2: #2b3947;
  --muted: #66798a;

  --side: #ffffff; /* sidebar สว่าง */
  --side-tint: #f6f8f9;

  --sans: "Anuphan", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --radius: 11px;
  --radius-sm: 8px;
  --sidebar-w: 244px;

  /* ---- map accent เข้า Bootstrap ---- */
  --bs-primary: var(--accent);
  --bs-primary-rgb: 14, 124, 134;
  --bs-link-color-rgb: 10, 98, 107;
  --bs-link-hover-color-rgb: 7, 78, 85;
  --bs-primary-bg-subtle: #e3f1f2;
  --bs-primary-border-subtle: #bfe0e2;
  --bs-primary-text-emphasis: #0a626b;
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-border-radius: var(--radius-sm);
}

* {
  box-sizing: border-box;
}

/* ย่อสเกลรวมทั้งระบบ (Bootstrap = 16px → 14px ทำให้ rem ทุกค่าหดตามสัดส่วน) */
html {
  font-size: 14px;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  margin: 0;
  letter-spacing: 0.1px;
  background-color: var(--bg);
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--side);
  border-right: 1px solid var(--line);
  color: var(--ink-2);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.22s ease;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.05rem 1.15rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.sidebar__brand .dot {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--mono);
  box-shadow: 0 2px 6px rgba(14, 124, 134, 0.35);
}
.sidebar__nav {
  padding: 0.6rem 0.55rem;
  overflow-y: auto;
  flex: 1;
}
.sidebar__label {
  font-size: 0.64rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #97a6b4;
  padding: 0.85rem 0.7rem 0.3rem;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin-bottom: 1px;
  transition:
    background 0.12s,
    color 0.12s;
}
.sidebar__link:hover {
  background: var(--side-tint);
  color: var(--ink);
}
.sidebar__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-700);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar__link.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.sidebar__link .ic {
  width: 18px;
  text-align: center;
  opacity: 0.8;
}
.sidebar__link.is-active .ic {
  opacity: 1;
}

.sidebar__foot {
  border-top: 1px solid var(--line);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  background: var(--side-tint);
}
.sidebar__user {
  color: var(--ink);
  font-weight: 600;
}
.sidebar__role {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  color: var(--accent-600);
  letter-spacing: 0.08em;
}

/* ---------- content ---------- */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}
.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-main {
  padding: 1.6rem;
}
.app-content {
  max-width: 1320px;
  margin: 0 auto;
  animation: fadeUp 0.32s ease both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 38, 0.4);
  z-index: 1035;
}

/* ---------- typography ---------- */
h1,
h2,
h3,
.h4,
.h5 {
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
code,
.num,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
}
code {
  color: var(--accent-600);
  background: var(--accent-soft);
  padding: 0.05rem 0.3rem;
  border-radius: 5px;
}
table code {
  background: transparent;
  padding: 0;
}
a {
  color: var(--accent-600);
  text-decoration: none;
}
a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- cards ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 32, 43, 0.04);
  background: var(--card);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  padding: 0.7rem 0.9rem;
}

/* ---------- tables (compact / editorial) ---------- */
.table {
  --bs-table-hover-bg: var(--accent-soft);
  --bs-table-bg: transparent;
  margin-bottom: 0;
  font-size: 0.86rem;
  color: var(--ink-2);
}
.table > thead th {
  font-size: 0.66rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table > tbody td {
  border-color: var(--line-soft);
  vertical-align: middle;
  padding: 0.5rem 0.6rem;
}
.table.table-sm > tbody td,
.table.table-sm > thead th {
  padding: 0.38rem 0.5rem;
}
.table-light,
.table > :not(caption) > * > .table-light,
thead.table-light th {
  --bs-table-bg: #f4f7f8;
  background: #f4f7f8;
}
.table-hover > tbody > tr {
  transition: background 0.1s;
}

/* ---------- buttons ---------- */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.btn-sm {
  border-radius: 7px;
}
.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-600);
  --bs-btn-hover-border-color: var(--accent-600);
  --bs-btn-active-bg: var(--accent-700);
  --bs-btn-active-border-color: var(--accent-700);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
  --bs-btn-disabled-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--accent-600);
  --bs-btn-border-color: var(--accent-line);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--accent-600);
  --bs-btn-active-border-color: var(--accent-600);
}
.btn-success {
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
}

/* ---------- forms ---------- */
.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: #d4dbe0;
  color: var(--ink);
}
.form-control-sm,
.form-select-sm {
  border-radius: 7px;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.18rem rgba(14, 124, 134, 0.16);
}
.form-label {
  font-weight: 500;
  font-size: 0.86rem;
  margin-bottom: 0.25rem;
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ---------- badges ---------- */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 6px;
  padding: 0.32em 0.55em;
}
.text-bg-primary {
  background-color: var(--accent) !important;
  color: #fff !important;
}

/* ---------- nav-tabs (Job Hub) ---------- */
.nav-tabs {
  border-bottom: 1px solid var(--line);
  gap: 0.1rem;
}
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-weight: 500;
  padding: 0.55rem 0.9rem;
}
.nav-tabs .nav-link:hover {
  color: var(--ink);
  border-bottom-color: var(--line);
  isolation: auto;
}
.nav-tabs .nav-link.active {
  color: var(--accent-700);
  background: transparent;
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- stat cards ---------- */
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  height: 100%;
  box-shadow: 0 1px 2px rgba(20, 32, 43, 0.04);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.7;
}
.stat__label {
  color: var(--muted);
  font-size: 0.8rem;
}
.stat__value {
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  margin-top: 0.3rem;
  color: var(--ink);
}
.stat__value.is-alert {
  color: var(--accent-600);
}
.stat__hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ---------- misc ---------- */
.alert {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
hr {
  color: var(--line);
  opacity: 1;
}

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(15, 28, 38, 0.15);
  }
  .layout.is-open .sidebar {
    transform: translateX(0);
  }
  .layout.is-open .backdrop {
    display: block;
  }
  .content {
    margin-left: 0;
  }
  .topbar {
    display: flex;
  }
  .app-main {
    padding: 0.9rem;
  }
}
