/* THIRA layout — โครงหน้าแอป (sidebar + topbar + เนื้อหา) */

.app-shell { display: flex; min-height: 100vh; }

/* ── sidebar ── */
.sidebar {
  width: 264px; flex: 0 0 auto;
  background: var(--s); border-right: 1px solid var(--l);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 18px; height: 88px;
  border-bottom: 1px solid var(--l2); flex: 0 0 auto;
}
.sidebar-head .name { font-family: var(--font-brand); font-weight: 500; font-size: 19px; letter-spacing: .16em; line-height: 1; }
.sidebar-head .sub  { font-size: 10.5px; color: var(--i4); margin-top: 4px; }
.sidebar nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 11px;
  color: var(--i2); font-size: 13.5px; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item .ms { color: #A29B8E; font-size: 21px; }
.nav-item:hover { background: var(--s2); color: var(--i); }
.nav-item.active { background: var(--s2); color: var(--i); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3.5px; height: 20px; border-radius: 0 4px 4px 0; background: var(--bt);
}
.nav-item.active .ms { color: var(--i); font-variation-settings: 'FILL' 1, 'wght' 500; }
.sidebar-user {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; border-top: 1px solid var(--l2); flex: 0 0 auto;
}
.sidebar-user .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #3A322A, #241F1A);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  color: var(--ac); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex: 0 0 auto;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .nm { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .rl { font-size: 11px; color: var(--i4); }
.icon-btn { border: none; background: transparent; color: var(--i5); padding: 4px; border-radius: 8px; }
.icon-btn:hover { color: var(--i2); background: var(--s2); }

/* ── ฝั่งเนื้อหา ── */
.app-main { flex: 1 1 0%; min-width: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px; min-height: 76px;
  background: var(--tb); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--l);
}
.topbar h1 { font-size: 22px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .subtitle { font-size: 12px; color: var(--i4); margin-top: 2px; }
.topbar .spacer { flex: 1; }

/* ปุ่ม/ช่องค้นหาบน topbar (แบบต้นแบบ) */
.searchbox {
  display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 15px; width: 250px;
  background: var(--s); border: 1px solid var(--l); border-radius: 12px;
}
.searchbox input { border: none; background: transparent; font-size: 13.5px;
  color: var(--i); width: 100%; font-family: var(--font); }
.searchbox input:focus { outline: none; }
.tb-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--l); background: var(--s);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.tb-btn .ms { color: var(--i2); font-size: 21px; }
.tb-btn:hover { border-color: var(--ac-border); }
.tb-dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px;
  border-radius: 50%; background: #C0533B; border: 1.5px solid var(--s); }
.btn-neworder {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px;
  border: none; border-radius: 12px; background: var(--bt); color: var(--bi);
  font-size: 13.5px; font-weight: 600; text-decoration: none; flex: 0 0 auto;
  box-shadow: 0 6px 18px -10px rgba(42,36,30,.4);
}
.btn-neworder:hover { background: var(--bh); }
.btn-neworder .ms { color: var(--ac); font-size: 20px; }
@media (max-width: 1100px) { .searchbox { width: 170px; } }
@media (max-width: 900px) { .searchbox { display: none; }
  .btn-neworder span:last-child { display: none; } }

/* แผงลอย (ผลค้นหา / แจ้งเตือน) */
.float-panel {
  position: fixed; top: 80px; right: 24px; z-index: 70;
  width: min(340px, calc(100vw - 24px)); max-height: 440px; overflow-y: auto;
  background: var(--s); border: 1px solid var(--l); border-radius: 14px;
  box-shadow: 0 30px 70px -20px rgba(20,15,8,.4); padding: 8px;
}
.float-panel .p-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 10px; border: none; background: transparent;
  text-align: left; font-size: 13px; color: var(--i); cursor: pointer;
}
.float-panel .p-row:hover { background: var(--s2); }
.page { padding: 26px; width: 100%; max-width: 1280px; margin: 0 auto; }

/* ── ย่อ sidebar เป็นแถบไอคอน (rail) — เฉพาะจอใหญ่ ── */
.collapse-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--l); background: var(--s); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.collapse-btn .ms { font-size: 20px; color: var(--i2); transition: transform .25s; }
@media (min-width: 821px) {
  .sidebar.rail { width: 78px; }
  .sidebar.rail .sidebar-head { justify-content: center; padding: 22px 8px 18px; }
  .sidebar.rail .sidebar-head > div:last-child { display: none; }
  .sidebar.rail .nav-item { justify-content: center; padding: 10px 0; }
  .sidebar.rail .nav-item span:last-child { display: none; }
  .sidebar.rail .sidebar-user { flex-direction: column; gap: 8px; padding: 12px 8px; }
  .sidebar.rail .sidebar-user .who { display: none; }
}

/* ── มือถือ ── */
.menu-btn { display: none; }
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; width: 270px;
    transform: translateX(-110%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 24px 70px -20px rgba(35,28,20,.45);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; padding: 0 10px !important; height: 40px; }
  .collapse-btn { display: none; }              /* ปุ่มย่อเมนูใช้เฉพาะจอใหญ่ */
  .topbar { padding: 10px 12px; gap: 8px; min-height: 62px; position: sticky; }
  .topbar h1 { font-size: 17px; }
  .topbar .subtitle { display: none; }
  .tb-btn { width: 38px; height: 38px; }
  .btn-neworder { height: 38px; padding: 0 12px; }
  .page { padding: 14px; }
  .float-panel { right: 10px; left: 10px; width: auto; top: 64px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px 16px !important; }
  .stat .value { font-size: 21px !important; }
  .cat-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 14px 8px; }
  .modal { padding: 18px 14px; }
  .page { padding: 10px; }
}
.overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(35,28,20,.34); backdrop-filter: blur(2px);
}

/* หน้า login (ไม่มี sidebar) */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 36px 34px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; text-align: center; }

/* ── ชั้นขัดเกลา (โครงหน้า) ── */

/* topbar: กระจกเข้มขึ้น อ่านชัดตอนเลื่อน */
.topbar { backdrop-filter: blur(16px) saturate(1.35); }

/* เมนูข้าง: ไอคอน hover มีสี + เปลี่ยนสถานะนุ่ม */
.nav-item .ms { transition: color .15s; }
.nav-item:hover .ms { color: var(--i2); }

/* หน้า login: แสงทองอาบสองมุมจอ หายใจช้าๆ + การ์ดหรูมีเส้นทอง ทยอยลอยเข้า */
.login-wrap { position: relative; isolation: isolate; }
.login-wrap::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(720px 400px at 14% 6%, color-mix(in srgb, var(--ac) 13%, transparent), transparent 70%),
    radial-gradient(640px 380px at 90% 94%, color-mix(in srgb, var(--ac) 10%, transparent), transparent 70%);
  animation: glowBreath 7s ease-in-out infinite alternate;
}
@keyframes glowBreath { from { opacity: .65; } to { opacity: 1; } }
.login-card {
  position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(35,28,20,.04), 0 48px 100px -44px rgba(35,28,20,.32);
  animation: loginIn .55s var(--ease) backwards;
}
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent 8%, var(--ac) 50%, transparent 92%);
  opacity: .85;
}
.login-head > *, .login-card form > * { animation: loginIn .55s var(--ease) backwards; }
.login-head > *:nth-child(1) { animation-delay: .05s; }
.login-head > *:nth-child(2) { animation-delay: .12s; }
.login-card form > * { animation-delay: .2s; }
@keyframes loginIn { from { opacity: 0; transform: translateY(14px); } }

/* แผงลอย (ค้นหา/แจ้งเตือน): เลื่อนลงนุ่มลึกขึ้น */
.float-panel { animation: fpIn .24s var(--ease); transform-origin: top right; }
@keyframes fpIn { from { opacity: 0; transform: translateY(-10px) scale(.985); } }
.theme-fab {
  position: fixed; top: 18px; right: 18px; z-index: 70;
  width: 42px; height: 42px; border-radius: 11px;
  border: 1px solid var(--l); background: var(--s); font-size: 17px;
}

/* ── จอใหญ่ / 2K / 4K: ขยายพื้นที่ใช้งาน + สเกลทั้ง UI ให้พอดีตา ── */
@media (min-width: 1700px) {
  .page, .shop-wrap { max-width: 1560px; }
  .searchbox { width: 320px; }
}
@media (min-width: 2100px) {          /* 4K ตั้ง scale 150% หรือจอ 2K/WQHD */
  body { zoom: 1.15; }
  .page, .shop-wrap { max-width: 1680px; }
}
@media (min-width: 2800px) {          /* 4K scale 100-125% */
  body { zoom: 1.45; }
  .page, .shop-wrap { max-width: 1760px; }
}
@media (min-width: 3600px) {          /* 4K native 100% */
  body { zoom: 1.75; }
}
