/* Organic — design-system tokens and component classes. This file is the source of truth for the system's look; retune it here and see readme.md. */
@import url('https://fonts.googleapis.com/css2?family=Caprasimo:wght@400&family=Figtree:wght@400;600;700&display=swap');

:root {
  --color-bg: #f5ead8;
  --color-surface: #ebddc5;
  --color-text: #201e1d;
  --color-accent: #c67139;
  --color-accent-2: #7a8a5e;
  --color-divider: color-mix(in srgb, #201e1d 16%, transparent);

  /* Tonal ramps — generated in OKLCH on one shared lightness scale, so the
     same step of any role matches the others in visual value. */
  --color-neutral-100: #f9f4ed;
  --color-neutral-200: #eee7db;
  --color-neutral-300: #dcd3c4;
  --color-neutral-400: #c0b6a5;
  --color-neutral-500: #a19786;
  --color-neutral-600: #82796a;
  --color-neutral-700: #645c50;
  --color-neutral-800: #474238;
  --color-neutral-900: #2e2b25;

  --color-accent-100: #fff2eb;
  --color-accent-200: #ffe1d0;
  --color-accent-300: #ffc6a5;
  --color-accent-400: #f6a06b;
  --color-accent-500: #d67f48;
  --color-accent-600: #b2622d;
  --color-accent-700: #8c491a;
  --color-accent-800: #643312;
  --color-accent-900: #402310;

  --color-accent-2-100: #f0fae1;
  --color-accent-2-200: #e1eecc;
  --color-accent-2-300: #ccdbb2;
  --color-accent-2-400: #aebf92;
  --color-accent-2-500: #8fa073;
  --color-accent-2-600: #728157;
  --color-accent-2-700: #56633f;
  --color-accent-2-800: #3d472b;
  --color-accent-2-900: #272e1b;

  --font-heading: "Caprasimo", system-ui, sans-serif;
  --font-heading-weight: 400;
  --font-body: "Figtree", system-ui, sans-serif;

  --space-1: 4.4px;
  --space-2: 8.8px;
  --space-3: 13.2px;
  --space-4: 17.6px;
  --space-6: 26.4px;
  --space-8: 35.2px;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 28px;

  /* Elevation — derived from the ground: soft ink-tinted shadows on a
     light theme, a hairline edge + ambient darkness on a dark one. */
  --shadow-sm: 0 1px 2px color-mix(in srgb, #2e2b25 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2e2b25 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2e2b25 22%, transparent);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: var(--font-heading-weight); }

.washed{filter:saturate(0.6) contrast(0.85) brightness(1.1) opacity(0.94)}

/* ══════════════════════════════════════════════════════════════════════════
   Components — built with the tokens above. Plain CSS
   on plain HTML: no JavaScript, no build step. Each class is documented in
   readme.md and demonstrated in foundations/ and components/.
   ══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.55; font-weight: 400; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; }
h2 { font-size: 32px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; }
h6 { letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
figure { margin: 0; }
figcaption {
  font-size: 11px; margin-top: var(--space-1);
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — rules — */
.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: var(--color-divider);
}

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text); /* matches the .input's 14px —
     the pair sits side by side in sign-up rows */
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* — forms — */
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.radio .dot {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--color-divider);
}
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot {
  border-color: var(--color-accent); background: var(--color-accent);
  box-shadow: inset 0 0 0 4px var(--color-bg);
}
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.seg {
  display: inline-flex; overflow: hidden;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: var(--color-bg); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }

/* — cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 17px; line-height: 1.2;
}
.card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.card-meta {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px;
  border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-accent-2 { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* — navigation — */
.nav {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: none;
}
.nav-brand {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 18px; margin-right: auto;
}
.nav a { color: inherit; text-decoration: none; font-size: 14px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--color-accent); }

/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 1px solid var(--color-divider);
}
.table td {
  padding: var(--space-2);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

/* — dialog — */
.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}
.dialog {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg);
}
.dialog-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 20px;
}
.dialog-body { font-size: 14px; opacity: 0.85; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* — rounded frame: everything softens, small controls go pill — */
.card, .dialog { border-radius: calc(var(--radius-lg) * 1.15); }
.btn, .tag, .seg, .input { border-radius: 999px; }
.input { padding-inline: 14px; }

/* ══ JHC app-specific styles (ported from the design prototype) ══ */
:root{
  --status-pending-bg: oklch(93% 0.05 95);
  --status-pending-text: oklch(38% 0.09 75);
  --status-ordered-bg: oklch(92% 0.03 240);
  --status-ordered-text: oklch(38% 0.07 240);
  --status-rejected-bg: oklch(91% 0.045 25);
  --status-rejected-text: oklch(38% 0.12 25);
}
body{margin:0}
button,select,input,textarea{font-family:var(--font-body)}
a{color:var(--color-accent);text-decoration:none}
a:hover{color:var(--color-accent-600)}
/* Links pasted inside free text — blue, so they read as links rather than UI accent */
a.jhc-link{color:#1a6fd4;text-decoration:underline}
a.jhc-link:hover{color:#12539f}
/* "มีข้อมูลใหม่" indicator dot */
.jhc-dot{display:inline-block;width:10px;height:10px;border-radius:999px;background:#e03131;flex:none;box-shadow:0 0 0 2px var(--color-surface)}
/* Product page: name in the clean body font instead of the display face;
   code/keyword lines grow on wide screens, phones keep the compact size */
.jhc-product-title{font-family:var(--font-body);font-weight:700}
.jhc-product-meta{font-size:14px;opacity:0.75}
@media (min-width:900px){
  .jhc-product-meta{font-size:17px}
}
/* Status tag on list cards: phone keeps the compact size, wide screens get a bigger one */
.jhc-status-tag{padding:8px 16px;font-weight:600;white-space:nowrap}
@media (min-width:900px){
  .jhc-status-tag{font-size:15px;padding:10px 24px;border-radius:var(--radius-md)}
}
::placeholder{color:color-mix(in srgb, var(--color-text) 40%, transparent)}
.jhc-mono{font-family:ui-monospace,Menlo,monospace}
.jhc-nav-item{cursor:pointer;padding:10px 14px;border-radius:var(--radius-md);margin-bottom:4px;font-size:14px;font-weight:500}
.jhc-nav-item:hover{background:var(--color-accent-100)}
.jhc-nav-item.active{background:var(--color-accent);color:var(--color-bg);font-weight:700}
.jhc-nav-item.active:hover{background:var(--color-accent)}
.jhc-quote-card:hover{background:var(--color-neutral-300) !important;box-shadow:var(--shadow-md)}
/* Nearly-rectangular row (the design system rounds .card heavily) — the
   flatter shape leaves room for a larger picture. */
.jhc-quote-card{padding:8px 12px;border-radius:10px !important}
.jhc-card-thumb{width:80px;height:80px;flex:none;border-radius:6px;object-fit:cover}
.jhc-card-title{font-size:19px;font-weight:700;line-height:1.3;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.jhc-card-code{font-size:14px;opacity:0.55;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* Bigger rows, letters and pictures on tablets and PCs… */
@media (min-width: 1024px){
  .jhc-quote-card{padding:10px var(--space-4)}
  .jhc-card-thumb{width:104px;height:104px}
  .jhc-card-title{font-size:22px}
  .jhc-card-code{font-size:15px;margin-top:4px}
}
/* …and slightly smaller letters on narrow phones. */
@media (max-width: 480px){
  .jhc-card-thumb{width:64px;height:64px}
  .jhc-card-title{font-size:16px}
  .jhc-card-code{font-size:12px}
}
.jhc-thumb{border-radius:var(--radius-sm);background:repeating-linear-gradient(45deg,var(--color-bg),var(--color-bg) 5px,var(--color-neutral-300) 5px,var(--color-neutral-300) 10px);display:flex;align-items:center;justify-content:center;font:700 10px ui-monospace,Menlo,monospace;color:var(--color-neutral-600);flex:none;overflow:hidden;padding:4px;text-align:center;word-break:break-all}
.jhc-no-spin::-webkit-outer-spin-button,.jhc-no-spin::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.jhc-no-spin{-moz-appearance:textfield}
.jhc-danger-btn{background:var(--status-rejected-text);border-color:var(--status-rejected-text);color:var(--color-bg)}
.jhc-danger-btn:hover{background:color-mix(in oklch, var(--status-rejected-text) 85%, black);border-color:color-mix(in oklch, var(--status-rejected-text) 85%, black)}

/* — app shell: slim rail + slide-out drawer menu (all screen sizes) — */
.jhc-shell{display:flex;height:100vh;height:100dvh;width:100%;overflow:hidden;background:var(--color-bg);color:var(--color-text)}

/* The always-visible slim zone; pressing anywhere on it opens the menu.
   Accent-coloured so it reads as a control, with the icon centred vertically. */
.jhc-rail{width:48px;flex:none;background:var(--color-accent);display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;user-select:none}
.jhc-rail:hover{background:var(--color-accent-600)}
.jhc-rail:active{background:var(--color-accent-700)}
.jhc-rail-burger{width:36px;height:36px;border:none;background:none;cursor:pointer;color:var(--color-bg);display:flex;align-items:center;justify-content:center;border-radius:var(--radius-sm)}

/* Dimmed background behind the open drawer; press it to close. */
.jhc-drawer-backdrop{position:fixed;inset:0;background:color-mix(in srgb, var(--color-neutral-900) 45%, transparent);z-index:70;opacity:0;pointer-events:none;transition:opacity 0.18s}
.jhc-drawer-backdrop.open{opacity:1;pointer-events:auto}

/* The menu itself slides in from the left over the content. */
.jhc-sidebar{position:fixed;top:0;bottom:0;left:0;z-index:71;width:min(272px,85vw);background:var(--color-surface);border-right:1px solid var(--color-divider);display:flex;flex-direction:column;padding:var(--space-4) var(--space-3);overflow-y:auto;transform:translateX(-105%);transition:transform 0.18s ease-out;box-shadow:var(--shadow-lg)}
.jhc-sidebar.open{transform:translateX(0)}
.jhc-drawer-close{position:absolute;top:10px;right:10px}
.jhc-brand-title{font-family:var(--font-heading);font-size:21px;margin-bottom:2px}
.jhc-brand-sub{font-size:12px;opacity:0.6;margin-bottom:var(--space-6)}
.jhc-sidebar-footer{margin-top:auto;padding-top:var(--space-4);border-top:1px solid var(--color-divider)}
.jhc-user-name{font-size:13px;font-weight:600;margin-bottom:2px}
.jhc-user-role{font-size:11px;opacity:0.55;margin-bottom:12px}
.jhc-logout{width:100%;font-size:13px}

.jhc-main{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative;min-width:0}
.jhc-topbar{padding:var(--space-4) var(--space-6);border-bottom:1px solid var(--color-divider);flex:none}
.jhc-topbar h1{font-size:25px;margin:0}
#jhc-scroll{flex:1;overflow-y:auto;padding:var(--space-6)}
.jhc-offer-add-row{display:flex;gap:8px;margin-top:4px;flex-wrap:wrap}

/* Image rows stay on ONE line and scroll sideways instead of wrapping. */
.jhc-img-strip{display:flex;gap:10px;overflow-x:auto;flex-wrap:nowrap;padding-bottom:6px;-webkit-overflow-scrolling:touch}
.jhc-img-strip > *{flex:none}
.jhc-img-strip::-webkit-scrollbar{height:6px}
.jhc-img-strip::-webkit-scrollbar-thumb{background:var(--color-neutral-400);border-radius:999px}
.jhc-img-strip::-webkit-scrollbar-track{background:transparent}

/* — list toolbar: search + Excel + add on one line, filter chips on the next — */
.jhc-toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:var(--space-3)}
.jhc-chip-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:var(--space-4)}
.jhc-chip{cursor:pointer;padding:7px 16px;border-radius:999px;font-size:13px;white-space:nowrap;user-select:none}
@media (max-width: 480px){
  .jhc-chip{padding:5px 11px;font-size:12px}
  .jhc-chip-row{gap:6px}
  .jhc-toolbar .btn{font-size:12px;padding:6px 12px}
  .jhc-toolbar .btn-icon{width:33px;height:33px;padding:0}
  .jhc-toolbar .input{min-height:33px;font-size:13px}
}

/* Section headers (เสนอราคา, รายละเอียดสินค้า, การสั่งซื้อ, ข้อความเพิ่มเติม,
   สถานะ, …): larger and in ink colour instead of the small orange caps. */
.card-kicker{font-size:15px;color:var(--color-text);font-weight:700;letter-spacing:0.04em}
.field > label{font-size:14px;color:var(--color-text)}

/* Textarea that grows with its content instead of scrolling inside itself. */
.jhc-autogrow{overflow:hidden;resize:none}

/* Product-page action bar (back / edit / delete): pinned while scrolling so
   แก้ไข is always reachable without going back to the top. */
/* top compensates the scroll container's padding so the bar pins flush. */
.jhc-detail-topbar{position:sticky;top:calc(-1 * var(--space-6));z-index:12;display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);margin:calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-4);padding:10px var(--space-6);background:var(--color-bg)}
@media (max-width: 760px){
  .jhc-detail-topbar{top:calc(-1 * var(--space-3));margin:calc(-1 * var(--space-3)) calc(-1 * var(--space-3)) var(--space-4);padding:8px var(--space-3)}
}

/* Floating back-to-top arrow, shown after scrolling down a while. */
.jhc-scrolltop{position:absolute;bottom:20px;right:20px;width:42px;height:42px;border-radius:999px;border:none;background:var(--color-accent);color:var(--color-bg);box-shadow:var(--shadow-md);cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:40}
.jhc-scrolltop:hover{background:var(--color-accent-600)}

/* Loading indicator for auto-load-on-scroll. */
.jhc-spinner{width:18px;height:18px;flex:none;border:3px solid var(--color-neutral-300);border-top-color:var(--color-accent);border-radius:50%;animation:jhc-spin 0.8s linear infinite}
@keyframes jhc-spin{to{transform:rotate(360deg)}}

/* Phones: tighter spacing; the rail/drawer already leaves the width free. */
@media (max-width: 760px){
  .jhc-rail{width:42px}
  .jhc-topbar{padding:10px var(--space-3)}
  .jhc-topbar h1{font-size:19px}
  #jhc-scroll{padding:var(--space-3)}
  h2{font-size:24px}
}

/* — จัดการผู้ใช้ table —
   Usernames may be a short handle ("B") or a full e-mail address. Password and
   ระดับ hold short, predictable values, so the spare width goes to the first two
   columns. `overflow-wrap:anywhere` is the "invisible boundary": content wraps
   onto a new line only when it would otherwise overflow into the next column. */
.jhc-user-table{table-layout:fixed;width:100%;min-width:520px}
.jhc-user-table th,.jhc-user-table td{overflow-wrap:anywhere;vertical-align:middle}
.jhc-user-table th:nth-child(1),.jhc-user-table td:nth-child(1){width:30%}
.jhc-user-table th:nth-child(2),.jhc-user-table td:nth-child(2){width:21%}
.jhc-user-table th:nth-child(3),.jhc-user-table td:nth-child(3){width:19%}
.jhc-user-table th:nth-child(4),.jhc-user-table td:nth-child(4){width:13%}
.jhc-user-table th:nth-child(5),.jhc-user-table td:nth-child(5){width:17%}
/* keeps the table readable on a phone rather than crushing every column */
.jhc-table-scroll{overflow-x:auto}
