/* Fixit 2569 — styles */
:root {
  --fx-blue: #1f4e9c;
  --fx-blue-dark: #15376f;
  --fx-orange: #f08a24;
  --fx-orange-soft: #fff3e6;
  --fx-bg: #f4f6fa;
  --fx-text: #1d2433;
  --fx-muted: #5d6677;
  --fx-border: #e3e7ef;
  /* ชุดสีกราฟ (validated categorical slots 1–4) */
  --s-moto: #2a78d6;
  --s-agri: #eb6834;
  --s-appl: #1baf7a;
  --s-elec: #eda100;
  --s-people: #4a3aa7;
  --bs-primary: #1f4e9c;
  --bs-primary-rgb: 31, 78, 156;
  --bs-link-color: #1f4e9c;
  --bs-link-color-rgb: 31, 78, 156;
}
html, body { background: var(--fx-bg); color: var(--fx-text); }
body { font-family: 'Sarabun', system-ui, sans-serif; font-size: 16px; }
h1, h2, h3, h4, h5, .fx-heading { font-family: 'Prompt', 'Sarabun', sans-serif; }

.btn-primary { --bs-btn-bg: var(--fx-blue); --bs-btn-border-color: var(--fx-blue); --bs-btn-hover-bg: var(--fx-blue-dark); --bs-btn-hover-border-color: var(--fx-blue-dark); --bs-btn-active-bg: var(--fx-blue-dark); }
.btn-orange { --bs-btn-color: #fff; --bs-btn-bg: var(--fx-orange); --bs-btn-border-color: var(--fx-orange); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #d9761a; --bs-btn-hover-border-color: #d9761a; --bs-btn-active-bg: #c96c15; --bs-btn-active-color:#fff; }
.text-orange { color: #c96c15 !important; }
.form-control:focus, .form-select:focus { border-color: #7aa0dc; box-shadow: 0 0 0 .2rem rgba(31,78,156,.15); }

/* ---------- Login ---------- */
.fx-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(circle at 15% 10%, rgba(240,138,36,.25), transparent 40%),
              linear-gradient(135deg, #15376f 0%, #1f4e9c 60%, #2a63bf 100%);
}
.fx-login-card { width: 100%; max-width: 420px; border: 0; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.fx-login-logos { display: flex; justify-content: center; align-items: center; gap: 18px; }
.fx-login-logos img { height: 84px; width: auto; }

/* ---------- Top bar ---------- */
.fx-topbar { background: linear-gradient(90deg, var(--fx-blue-dark), var(--fx-blue)); color: #fff; position: sticky; top: 0; z-index: 1030; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.fx-topbar .navbar-brand { color: #fff; display: flex; align-items: center; gap: 10px; font-family: 'Prompt', sans-serif; font-weight: 600; line-height: 1.1; }
.fx-topbar .navbar-brand img { height: 40px; }
.fx-topbar .navbar-brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .85; font-family: 'Sarabun', sans-serif; }
.fx-topbar .nav-link { color: rgba(255,255,255,.85); border-radius: 10px; padding: .5rem .85rem !important; }
.fx-topbar .nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.fx-topbar .nav-link.active { color: #fff; background: var(--fx-orange); }
.fx-topbar .navbar-toggler { border-color: rgba(255,255,255,.4); }
.fx-topbar .navbar-toggler-icon { filter: invert(1); }
.fx-user-chip { background: rgba(255,255,255,.12); border-radius: 999px; padding: .3rem .8rem; color: #fff; font-size: .9rem; }
.fx-role { font-size: .72rem; background: var(--fx-orange); color: #fff; border-radius: 999px; padding: .1rem .5rem; margin-left: .35rem; }

main.fx-main { padding: 20px 0 48px; }
.fx-page-title { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.fx-page-title h2 { font-size: 1.35rem; margin: 0; font-weight: 600; }
.fx-card { background: #fff; border: 1px solid var(--fx-border); border-radius: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.fx-card-h { padding: 14px 18px; border-bottom: 1px solid var(--fx-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fx-card-h h5 { margin: 0; font-size: 1.02rem; font-weight: 600; }
.fx-card-b { padding: 18px; }

/* ---------- Dashboard ---------- */
.fx-hero { background: linear-gradient(120deg, var(--fx-blue-dark), var(--fx-blue)); color: #fff; border-radius: 20px; padding: 20px 22px; position: relative; overflow: hidden; }
.fx-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(240,138,36,.35); }
.fx-hero-logos { display: flex; gap: 12px; align-items: center; position: relative; z-index: 1; }
.fx-hero-logos img { height: 64px; background: #fff; border-radius: 14px; padding: 4px; }
.fx-hero h1 { font-size: 1.45rem; margin: 0; font-weight: 600; }
.fx-hero p { margin: 2px 0 0; opacity: .9; }
.fx-hero .fx-badge-date { display: inline-block; background: var(--fx-orange); color: #fff; border-radius: 999px; padding: .2rem .8rem; font-size: .85rem; margin-top: 6px; }

.fx-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.fx-chip { border: 1px solid var(--fx-border); background: #fff; color: var(--fx-text); border-radius: 999px; padding: .35rem .9rem; white-space: nowrap; font-size: .92rem; }
.fx-chip.active { background: var(--fx-blue); border-color: var(--fx-blue); color: #fff; }

.fx-kpi { background: #fff; border: 1px solid var(--fx-border); border-radius: 16px; padding: 16px 18px; height: 100%; }
.fx-kpi .lbl { color: var(--fx-muted); font-size: .92rem; display: flex; align-items: center; gap: 6px; }
.fx-kpi .val { font-family: 'Prompt', sans-serif; font-size: 2rem; font-weight: 600; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.fx-kpi .unit { font-size: .95rem; color: var(--fx-muted); font-weight: 400; margin-left: 4px; }
.fx-kpi.big { border: 0; color: #fff; }
.fx-kpi.big .lbl, .fx-kpi.big .unit { color: rgba(255,255,255,.88); }
.fx-kpi.big .val { font-size: 2.6rem; }
.fx-kpi.k-people { background: linear-gradient(135deg, #f08a24, #e06d10); }
.fx-kpi.k-repair { background: linear-gradient(135deg, #2a63bf, #1f4e9c); }
.fx-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.fx-cat-ico { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; flex: none; }
.fx-kpi .bar { height: 6px; border-radius: 4px; background: #eef1f6; margin-top: 10px; overflow: hidden; }
.fx-kpi .bar span { display: block; height: 100%; border-radius: 4px; }

.fx-chart-box { position: relative; height: 320px; }
.fx-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--fx-muted); }
.fx-legend span { display: inline-flex; align-items: center; gap: 6px; }

.fx-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fx-gallery a { position: relative; display: block; border-radius: 12px; overflow: hidden; aspect-ratio: 4/3; background: #e9edf3; }
.fx-gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.fx-gallery a:hover img { transform: scale(1.04); }
.fx-gallery .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: .75rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); }

.table-fx { font-size: .95rem; }
.table-fx th { color: var(--fx-muted); font-weight: 600; white-space: nowrap; background: #f8f9fc; }
.table-fx td, .table-fx th { vertical-align: middle; }
.table-fx td.num, .table-fx th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-fx tfoot td { font-weight: 700; background: var(--fx-orange-soft); }

/* ---------- Entry form ---------- */
.fx-stepper { display: flex; align-items: stretch; }
.fx-stepper .btn { width: 48px; font-size: 1.25rem; line-height: 1; }
.fx-stepper input { text-align: center; font-size: 1.35rem; font-weight: 600; font-family: 'Prompt', sans-serif; }
.fx-field-card { border: 1px solid var(--fx-border); border-radius: 14px; padding: 12px; background: #fff; height: 100%; }
.fx-field-card label { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.fx-field-card.people { background: var(--fx-orange-soft); border-color: #f6cfa4; }
.fx-drop { border: 2px dashed #b9c6dc; border-radius: 14px; padding: 18px; text-align: center; background: #f8faff; cursor: pointer; }
.fx-drop:hover { border-color: var(--fx-blue); }
.fx-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.fx-previews .p { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.fx-previews img { width: 100%; height: 100%; object-fit: cover; }
.fx-previews .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; line-height: 1; }
.fx-today { background: linear-gradient(135deg, #fff, var(--fx-orange-soft)); }
.fx-today .n { font-family: 'Prompt', sans-serif; font-size: 1.4rem; font-weight: 600; }

.fx-thumbs { display: flex; gap: 4px; }
.fx-thumbs img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; }

/* ---------- misc ---------- */
.fx-loading { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 2000; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; }
.fx-loading.show { display: flex; }
.toast-container { z-index: 2100; }
.fx-empty { text-align: center; color: var(--fx-muted); padding: 36px 12px; }
.fx-empty i { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .5; }
.fx-footer { text-align: center; color: var(--fx-muted); font-size: .85rem; padding: 18px 0 28px; }
.fx-live { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--fx-muted); }
.fx-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #1baf7a; box-shadow: 0 0 0 0 rgba(27,175,122,.6); animation: fxpulse 2s infinite; }
@keyframes fxpulse { 0% { box-shadow: 0 0 0 0 rgba(27,175,122,.6); } 70% { box-shadow: 0 0 0 8px rgba(27,175,122,0); } 100% { box-shadow: 0 0 0 0 rgba(27,175,122,0); } }

@media (max-width: 576px) {
  .fx-kpi .val { font-size: 1.6rem; }
  .fx-kpi.big .val { font-size: 2.1rem; }
  .fx-hero h1 { font-size: 1.15rem; }
  .fx-hero-logos img { height: 48px; }
  .fx-chart-box { height: 280px; }
  .fx-card-b { padding: 14px; }
}

/* ---------- refinements ---------- */
.fx-topbar .nav-link { white-space: nowrap; }
.fx-topbar .navbar-brand { margin-right: .5rem; }
.fx-hero::after { background: rgba(255,255,255,.07); }
.table-fx td:nth-child(2) { min-width: 150px; }
.fx-stepper input::-webkit-outer-spin-button, .fx-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fx-stepper input[type=number] { -moz-appearance: textfield; appearance: textfield; }
@media (min-width: 992px) and (max-width: 1399px) {
  .fx-topbar .nav-link { padding: .5rem .6rem !important; font-size: .95rem; }
  .fx-topbar .navbar-brand small { display: none; }
}
