/* =========================================================
   HILLKOFF UI KIT — tokens, reset, shell, base components
   ========================================================= */

:root{
  --hk-bg: #0F0D0B;
  --hk-surface: #1B1714;
  --hk-surface-2: #241E19;
  --hk-border: #322A22;
  --hk-gold: #F2B705;
  --hk-gold-dim: #A6820B;
  --hk-text: #F3EFE7;
  --hk-text-dim: #B8AFA0;
  --hk-success: #4CAF6D;
  --hk-warn: #E5A93E;
  --hk-danger: #E5484D;

  --hk-font-display: 'Sora', sans-serif;
  --hk-font-body: 'Inter', sans-serif;
  --hk-font-mono: 'IBM Plex Mono', monospace;

  --hk-radius-sm: 6px;
  --hk-radius-md: 10px;
  --hk-radius-lg: 16px;

  --hk-sidebar-w: 264px;
  --hk-sidebar-w-collapsed: 76px;
  --hk-navbar-h: 64px;

  --hk-shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --hk-shadow-2: 0 8px 24px rgba(0,0,0,.45);
}

*, *::before, *::after{ box-sizing: border-box; }

/* คืนค่าการ Scroll ให้ Document ปกติเพื่อป้องกันปัญหาหน้าเว็บหดสเกล/เลื่อนไม่ได้ */
html, body{
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--hk-bg);
  color: var(--hk-text);
  font-family: var(--hk-font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5{ font-family: var(--hk-font-display); margin: 0 0 .4em; font-weight: 600; letter-spacing: -.01em; }
p{ margin: 0 0 .8em; color: var(--hk-text-dim); }
a{ color: inherit; text-decoration: none; }
ul{ list-style:none; margin:0; padding:0; }
button{ font-family: inherit; }
img{ max-width:100%; display:block; }
code, .mono{ font-family: var(--hk-font-mono); }

:focus-visible{
  outline: 2px solid var(--hk-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- App Layout Structure ---------- */
.hk-app{
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ---------- Sidebar (Sticky Sidebar Layout มาตรฐานที่เสถียรที่สุด) ---------- */
.hk-sidebar{
  width: var(--hk-sidebar-w);
  min-width: var(--hk-sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--hk-surface);
  border-right: 1px solid var(--hk-border);
  padding: 20px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 40;
  flex-shrink: 0;
  transition: width .18s ease, min-width .18s ease;
}

.hk-brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 4px 8px 10px;
}
.hk-brand__mark{
  width:34px; height:34px; border-radius: var(--hk-radius-sm);
  background: linear-gradient(145deg, var(--hk-gold), var(--hk-gold-dim));
  display:flex; align-items:center; justify-content:center;
  font-family: var(--hk-font-display); font-weight:700; color:#1B1509;
}
.hk-brand__name{ font-family: var(--hk-font-display); font-weight:700; font-size: 15px; }
.hk-brand__sub{ font-size: 11px; color: var(--hk-text-dim); letter-spacing: .04em; }

.hk-navgroup__label{
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--hk-text-dim); padding: 0 10px 8px;
}
.hk-navitem{
  display:flex; align-items:center; gap:10px;
  padding: 9px 10px; border-radius: var(--hk-radius-sm);
  color: var(--hk-text-dim); font-size: 14px; font-weight: 500;
  cursor:pointer; transition: background .15s, color .15s;
}
.hk-navitem:hover{ background: var(--hk-surface-2); color: var(--hk-text); }
.hk-navitem.is-active{ background: rgba(242,183,5,.12); color: var(--hk-gold); }
.hk-navitem__icon{ width:18px; height:18px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.hk-navitem__count{
  margin-left:auto; font-family: var(--hk-font-mono); font-size:11px; color: var(--hk-text-dim);
  background: var(--hk-surface-2); padding:1px 7px; border-radius: 999px;
}

.hk-sidebar__footer{ margin-top:auto; padding-top: 12px; border-top: 1px solid var(--hk-border); }
.hk-sidebar__toggle{
  display:none;
  position: fixed; top: 14px; left: 14px; z-index: 60;
  width:38px; height:38px; border-radius: var(--hk-radius-sm);
  background: var(--hk-surface); border:1px solid var(--hk-border); color: var(--hk-text);
  align-items:center; justify-content:center; cursor:pointer;
}

/* ---------- Sidebar collapse (desktop) ---------- */
.hk-sidebar__collapse{
  position: absolute; top: 74px; right: -13px; z-index: 45;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--hk-surface); border: 1px solid var(--hk-border); color: var(--hk-text-dim);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.hk-sidebar__collapse:hover{ color: var(--hk-gold); border-color: var(--hk-gold-dim); }
.hk-sidebar__collapse svg{ transition: transform .18s ease; }
.hk-sidebar.is-collapsed .hk-sidebar__collapse svg{ transform: rotate(180deg); }

.hk-sidebar.is-collapsed{ width: var(--hk-sidebar-w-collapsed); min-width: var(--hk-sidebar-w-collapsed); }
.hk-sidebar.is-collapsed .hk-brand{ justify-content: center; padding: 4px 0 10px; }
.hk-sidebar.is-collapsed .hk-brand__name,
.hk-sidebar.is-collapsed .hk-brand__sub,
.hk-sidebar.is-collapsed .hk-navgroup__label,
.hk-sidebar.is-collapsed .hk-navitem__count,
.hk-sidebar.is-collapsed .hk-navitem > span:not(.hk-navitem__icon),
.hk-sidebar.is-collapsed .hk-sidebar__footer{
  display: none;
}
.hk-sidebar.is-collapsed .hk-navitem{ justify-content: center; padding: 10px; }
.hk-sidebar.is-collapsed nav{ display:flex; flex-direction:column; align-items:center; }
.hk-sidebar.is-collapsed ul{ width:100%; }

/* Collapse button only makes sense once the desktop sidebar is visible;
   on mobile the hamburger + slide-out drawer (below) takes over instead. */
@media (max-width: 980px){
  .hk-sidebar__collapse{ display:none; }
}

/* ---------- Main Content Container (ขยายเต็มพื้นที่ที่เหลือและปรับขนาดตาม Viewport) ---------- */
.hk-main{
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Navbar ---------- */
.hk-navbar{
  height: var(--hk-navbar-h);
  border-bottom: 1px solid var(--hk-border);
  background: rgba(15,13,11,.85);
  backdrop-filter: blur(8px);
  display:flex; align-items:center; gap:16px;
  padding: 0 24px;
  position: sticky; top:0; z-index: 30;
  width: 100%;
}
.hk-search{
  flex:1; max-width: 460px;
  display:flex; align-items:center; gap:8px;
  background: var(--hk-surface); border:1px solid var(--hk-border);
  border-radius: var(--hk-radius-md); padding: 8px 12px;
}
.hk-search input{
  background:transparent; border:none; color: var(--hk-text); font-size:14px; flex:1; outline:none;
}
.hk-search input::placeholder{ color: var(--hk-text-dim); }
.hk-search__kbd{
  font-family: var(--hk-font-mono); font-size:11px; color: var(--hk-text-dim);
  border:1px solid var(--hk-border); border-radius:4px; padding:1px 6px;
}
.hk-navbar__spacer{ flex:1; }
.hk-avatar{
  width:36px; height:36px; border-radius:50%;
  background: var(--hk-surface-2); border:1px solid var(--hk-border);
  display:flex; align-items:center; justify-content:center;
  font-family: var(--hk-font-display); font-weight:600; font-size:13px; color: var(--hk-gold);
}

/* ---------- Content ---------- */
.hk-content{ 
  padding: 28px 32px 60px; 
  width: 100%;
  max-width: 100%; 
  min-width: 0; 
}
.hk-section-head{
  display:flex; align-items:flex-end; justify-content:space-between; gap:16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.hk-eyebrow{ color: var(--hk-gold); font-size: 12px; letter-spacing:.08em; text-transform:uppercase; margin-bottom:4px; }

/* ---------- Buttons ---------- */
.hk-btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius: var(--hk-radius-sm); border: 1px solid transparent;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.hk-btn:active{ transform: translateY(1px); }
.hk-btn--primary{ background: var(--hk-gold); color:#1B1509; }
.hk-btn--primary:hover{ background:#FFC61A; }
.hk-btn--ghost{ background: transparent; border-color: var(--hk-border); color: var(--hk-text); }
.hk-btn--ghost:hover{ border-color: var(--hk-gold); color: var(--hk-gold); }
.hk-btn--danger{ background: transparent; border-color: var(--hk-danger); color: var(--hk-danger); }
.hk-btn--sm{ padding:6px 12px; font-size:13px; }
.hk-btn:disabled{ opacity:.45; cursor:not-allowed; }
.hk-btn--block{ width:100%; }

/* ---------- Badges ---------- */
.hk-badge{
  display:inline-flex; align-items:center; gap:6px;
  padding: 3px 10px; border-radius:999px; font-size:12px; font-weight:600;
  background: var(--hk-surface-2); color: var(--hk-text-dim); border:1px solid var(--hk-border);
}
.hk-badge--gold{ background: rgba(242,183,5,.14); color: var(--hk-gold); border-color: rgba(242,183,5,.3); }
.hk-badge--new{ background: rgba(76,175,109,.15); color: var(--hk-success); border-color: rgba(76,175,109,.35); }

/* ---------- Cards ---------- */
.hk-card{
  background: var(--hk-surface); border:1px solid var(--hk-border);
  border-radius: var(--hk-radius-lg); overflow:hidden;
}
.hk-card--pad{ padding: 20px; }

/* ---------- Empty / loading ---------- */
.hk-empty{
  text-align:center; padding: 60px 20px; color: var(--hk-text-dim);
}
.hk-empty__icon{ font-size:36px; margin-bottom:10px; opacity:.6; }

.hk-skeleton{
  background: linear-gradient(90deg, var(--hk-surface) 25%, var(--hk-surface-2) 37%, var(--hk-surface) 63%);
  background-size: 400% 100%;
  animation: hk-shimmer 1.4s ease infinite;
  border-radius: var(--hk-radius-md);
}
@keyframes hk-shimmer{ 0%{background-position:100% 0} 100%{background-position:0 0} }

@keyframes hk-fade-in{ from{ opacity:0; transform: translateY(4px); } to{ opacity:1; transform:none; } }
.hk-fade-in{ animation: hk-fade-in .22s ease both; }

/* ---------- Toast ---------- */
.hk-toast{
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--hk-surface-2); border:1px solid var(--hk-border);
  color: var(--hk-text); padding: 12px 20px; border-radius: var(--hk-radius-md);
  box-shadow: var(--hk-shadow-2); font-size: 14px; opacity:0; pointer-events:none;
  transition: opacity .2s, transform .2s; z-index: 200; display:flex; align-items:center; gap:10px;
}
.hk-toast.is-visible{ opacity:1; transform: translateX(-50%) translateY(0); pointer-events:auto; }
.hk-toast__dot{ width:8px; height:8px; border-radius:50%; background: var(--hk-success); flex-shrink:0; }

/* ---------- Breadcrumb ---------- */
.hk-breadcrumb{ display:flex; align-items:center; gap:8px; font-size:13px; color: var(--hk-text-dim); margin-bottom:18px; flex-wrap:wrap; min-width: 0; }
.hk-breadcrumb a{ overflow-wrap: anywhere; }
.hk-breadcrumb a:hover{ color: var(--hk-gold); }
.hk-breadcrumb__sep{ opacity:.5; }

/* ---------- Responsive Standard Boundaries ---------- */
@media (max-width: 1180px){
  :root{ --hk-sidebar-w: 224px; }
}
@media (max-width: 980px){
  .hk-app{ flex-direction: column; }
  .hk-sidebar{
    position: fixed; left:0; top:0; height:100vh; width: 84vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .hk-sidebar.is-open{ transform: translateX(0); box-shadow: var(--hk-shadow-2); }
  .hk-sidebar__toggle{ display:flex; }
  .hk-navbar{ padding-left: 64px; }
  .hk-content{ padding: 22px 16px 50px; }
}
@media (max-width: 560px){
  .hk-search{ max-width: none; }
  .hk-search__kbd{ display:none; }
  .hk-breadcrumb{ font-size: 12px; gap: 6px; }
}

.hk-backdrop{
  position: fixed; inset:0; background: rgba(0,0,0,.55); z-index: 39; opacity:0; pointer-events:none; transition: opacity .2s;
}
.hk-backdrop.is-visible{ opacity:1; pointer-events:auto; }
