/* ==========================================================================
   PMS Industrial Supply — base.css (ไฟล์หลัก ใช้ทุกหน้า)
   1. ตัวแปรสี / ฟอนต์ / ระยะห่าง   2. Reset   3. Typography H1–H6, p, strong
   4. Layout & Section   5. ปุ่ม   6. ฟอร์ม   7. ส่วนที่ใช้ร่วมกันหลายหน้า   8. Utilities
   Header → header.css | Footer → footer.css | เฉพาะหน้า → home.css, product.css ...
   ========================================================================== */

/* 1. ตัวแปร ---------------------------------------------------------------- */
:root {
  /* พาเลต: น้ำเงินกรมท่าตามโลโก้ (#0a1d74) / ฟ้าอ่อน / เทาโทนเย็น */
  --black: #0f172a;      /* หัวข้อ / footer (ดำอมน้ำเงิน) */
  --charcoal: #1e293b;
  --brand: #1e3a8a;      /* สีเน้น: ปุ่ม แผงสี (ตัวอักษรขาวอ่านชัด ~10:1) */
  --brand-dark: #14296b;
  --brand-light: #8ea4dd; /* ไอคอน/เส้นบนพื้นเข้ม */
  --tint: #f1f4fa;       /* พื้นแผงสีฟ้าอ่อน */
  --tint-2: #e2e8f4;
  --gray-700: #4a5263;   /* ข้อความเนื้อหา */
  --gray-500: #6b7385;
  --gray-300: #cfd5df;
  --gray-200: #e3e7ee;
  --gray-150: #edf0f5;
  --gray-100: #f6f7fa;
  --white: #ffffff;

  /* สีตามหน้าที่ — เปลี่ยนที่นี่ที่เดียว */
  --color-bg: var(--white);
  --color-text: var(--gray-700);        /* <p> */
  --color-heading: var(--black);        /* H1–H5 */
  --color-strong: var(--black);         /* <strong> / <b> ตัวหนา */
  --color-link: var(--brand-dark);
  --color-accent: var(--brand);           /* H6 / eyebrow (#แท็ก) */
  --color-border: var(--gray-200);

  /* ฟอนต์: Lato (อังกฤษ) + Noto Sans Thai (ไทย) */
  --font-sans: "Lato", "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;

  /* ขนาดตัวอักษร (ย่อ/ขยายตามหน้าจออัตโนมัติ) */
  --fs-h1: clamp(2.375rem, 1.5rem + 3.6vw, 4.5rem);
  --fs-h2: clamp(1.75rem, 1.3rem + 1.8vw, 2.625rem);
  --fs-h3: clamp(1.375rem, 1.15rem + 0.9vw, 1.875rem);
  --fs-h4: clamp(1.25rem, 1.12rem + 0.5vw, 1.5rem);
  --fs-h5: 1.1875rem;
  --fs-h6: 0.9375rem;
  --fs-body: 1.0625rem;   /* 17px — ภาษาไทยอ่านสบาย */
  --fs-small: 0.9375rem;
  --fs-lead: 1.125rem;

  --lh-heading: 1.25;
  --lh-body: 1.75;

  /* ระยะห่าง / มุม / เงา */
  --container: 1240px;
  --gutter: clamp(1rem, 0.6rem + 1.8vw, 2rem);
  --section-y: clamp(3.5rem, 2.5rem + 4vw, 6rem);
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 28px;
  --shadow-sm: 0 1px 2px rgb(20 20 20 / 0.05);
  --shadow: 0 12px 32px -14px rgb(20 20 20 / 0.18);
  --shadow-lg: 0 24px 60px -20px rgb(20 20 20 / 0.35);
  --header-h: 72px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* 2. Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 32px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-bg);
  overflow-wrap: break-word; /* คำยาว เช่น อีเมล/URL ตัดขึ้นบรรทัดใหม่ ไม่ล้นจอ */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
ul[class], ol[class] { list-style: none; margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* 3. Typography — H1–H6, p, ตัวหนา ---------------------------------------- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin: 0 0 0.5em;
  font-family: var(--font-sans);
  font-weight: 500;
  line-height: var(--lh-heading);
  color: var(--color-heading);
  text-wrap: balance;
}
h1, .h1 { font-size: var(--fs-h1); letter-spacing: -0.015em; line-height: 1.15; }
h2, .h2 { font-size: var(--fs-h2); letter-spacing: -0.01em; }
h3, .h3 { font-size: var(--fs-h3); }
h4, .h4 { font-size: var(--fs-h4); }
h5, .h5 { font-size: var(--fs-h5); font-weight: 600; }
h6, .h6 { font-size: var(--fs-h6); font-weight: 600; color: var(--color-accent); }

p { margin: 0 0 1em; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--color-text); }
p:last-child { margin-bottom: 0; }
.lead { font-size: var(--fs-lead); }
small, .small { font-size: var(--fs-small); }

strong, b { font-weight: 700; color: var(--color-strong); }

a { color: var(--color-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; border-radius: 4px; }

/* พื้นหลังเข้ม/พื้นรูป: กลับสีตัวอักษรอัตโนมัติ */
.on-dark {
  --color-text: rgb(255 255 255 / 0.8);
  --color-heading: var(--white);
  --color-strong: var(--white);
  --color-link: var(--white);
  --color-accent: var(--tint-2);
}

/* ป้ายหัวข้อแบบ #แท็ก */
.eyebrow { display: inline-block; margin: 0 0 0.75rem; font-size: var(--fs-h6); font-weight: 500; color: var(--color-accent); }
.eyebrow::before { content: "#"; }

.phrase { display: inline-block; max-width: 100%; } /* วลีที่ไม่ควรถูกตัดกลาง (ใช้กับ phrases() ใน PHP) */

.prose ul { padding-left: 1.25rem; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }
.prose h2 { margin-top: 1.75em; }
.prose--narrow { max-width: 820px; }

/* 4. Layout & Section ------------------------------------------------------ */
.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(1.5rem, 1rem + 2vw, 2.5rem); }
.section--gray { background: var(--white); }

/* แผงสีฟ้าอ่อนมุมโค้ง (ใช้ครอบเนื้อหาในหลายส่วน) */
.panel-tint { padding: clamp(1.5rem, 1rem + 3vw, 3rem); background: var(--tint); border-radius: var(--radius-lg); }

/* หัว section: หัวข้อซ้าย / คำอธิบายขวา */
.section-head { max-width: 760px; margin-bottom: clamp(2rem, 1.5rem + 2vw, 3rem); }
.section-head--split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.25rem clamp(2rem, 4vw, 4rem);
  align-items: end;
  max-width: none;
}
.section-head--split h2 { margin: 0; }
.section-head__side { max-width: 400px; justify-self: end; padding-bottom: 0.35rem; }
.section-head__side p { font-size: 0.9375rem; line-height: 1.7; color: var(--gray-500); }
.section-head--row { max-width: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.section-head--row h2 { margin: 0; }

.card { background: var(--white); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: clamp(1.25rem, 1rem + 1.5vw, 2.25rem); }

.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; }

/* กล่องไอคอนสีขาวมุมโค้ง */
.icon-box { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 56px; height: 56px; color: var(--black); background: var(--white); border: 1px solid var(--color-border); border-radius: 14px; }
.icon-box .icon { width: 1.6rem; height: 1.6rem; stroke-width: 1.6; }

/* ปุ่มลูกศรวงกลมสีน้ำเงิน */
.round-arrow { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 46px; height: 46px; color: var(--white); background: var(--brand); border-radius: 50%; transition: background-color .25s, transform .25s var(--ease); }
.round-arrow .icon { width: 1.15rem; height: 1.15rem; transform: rotate(-45deg); }
a:hover .round-arrow, .round-arrow:hover { background: var(--brand-dark); transform: scale(1.06); }

/* ลายตู้คอนเทนเนอร์ — พื้นหลังสำรองเมื่อยังไม่มีรูปภาพ */
.container-pattern {
  --tone: var(--charcoal);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.08), rgb(0 0 0 / 0.18)),
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.07) 0 3px, transparent 3px 14px, rgb(0 0 0 / 0.14) 14px 17px, transparent 17px 28px),
    var(--tone);
}

/* 5. ปุ่ม (ทรงแคปซูล) ------------------------------------------------------ */
.btn {
  --btn-bg: var(--black);
  --btn-fg: var(--white);
  --btn-bd: var(--btn-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1.4rem;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1.5px solid var(--btn-bd);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:hover { color: var(--btn-fg); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .icon { width: 1.1em; height: 1.1em; }
.btn--primary:hover { --btn-bg: var(--charcoal); }
.btn--accent { --btn-bg: var(--brand); }
.btn--accent:hover { --btn-bg: var(--brand-dark); }
.btn--outline { --btn-bg: transparent; --btn-fg: var(--black); --btn-bd: var(--gray-300); }
.btn--outline:hover { --btn-bg: var(--black); --btn-fg: var(--white); --btn-bd: var(--black); }
.btn--light { --btn-bg: var(--white); --btn-fg: var(--black); }
.btn--light:hover { --btn-bg: var(--tint); --btn-fg: var(--black); }
.btn--ghost-light { --btn-bg: transparent; --btn-fg: var(--white); --btn-bd: rgb(255 255 255 / 0.7); }
.btn--ghost-light:hover { --btn-bg: var(--white); --btn-fg: var(--black); --btn-bd: var(--white); }
.btn--line { --btn-bg: #06c755; --btn-fg: var(--black); }
.btn--sm { min-height: 38px; padding: 0.35rem 1.1rem; font-size: 0.875rem; }
.btn--lg { min-height: 50px; padding: 0.75rem 1.7rem; font-size: 1rem; }
/* ไอคอนในวงกลม (เช่น ▶ Watch Video) */
.btn__dot { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: -0.5rem; color: var(--black); background: var(--white); border-radius: 50%; }
.btn__dot .icon { width: 0.8rem; height: 0.8rem; }

.link-arrow { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; font-weight: 600; color: var(--black); text-decoration: none; }
.link-arrow .icon { transition: transform .2s var(--ease); }
.link-arrow:hover .icon, a:hover > .link-arrow .icon { transform: translateX(4px); }

/* 6. ฟอร์ม ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label, .field__label { font-size: 0.875rem; font-weight: 600; color: var(--black); }
.field .req { color: var(--brand); }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 1rem;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:hover, .field textarea:hover { border-color: var(--gray-300); }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; background: var(--white); border-color: var(--brand); box-shadow: 0 0 0 4px rgb(30 58 138 / 0.16); }
.form-alert { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; padding: 1rem 1.15rem; border-radius: var(--radius-sm); text-align: left; }
.form-alert p { margin: 0; color: inherit; }
.form-alert strong { color: inherit; }
.form-alert--success { background: #e8f7ee; color: #14532d; border: 1px solid #a7e3bf; }
.form-alert--success .icon { color: #16a34a; }
.form-alert--error { background: #fdecec; color: #8a1c1c; border: 1px solid #f5b5b5; }

/* 7. ส่วนที่ใช้ร่วมกันหลายหน้า ------------------------------------------------ */
.skip-link { position: absolute; top: -100px; left: 1rem; z-index: 200; padding: 0.6rem 1rem; background: var(--black); color: var(--white); border-radius: var(--radius-sm); }
.skip-link:focus { top: 1rem; }

/* แบนเนอร์หัวหน้าเพจย่อย: กล่องมุมโค้งพื้นรูปมืด (แถบเมนูลอยทับด้านบน) */
.page-banner { padding: 12px 12px 0; }
.page-banner__box {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: clamp(320px, 18rem + 8vw, 440px);
  padding: calc(var(--header-h) + 3rem) 0 clamp(2rem, 1.5rem + 2vw, 3rem);
  overflow: hidden;
  color: var(--white);
  background: var(--black);
  border-radius: var(--radius-lg);
}
.page-banner__bg { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: center 18%; } /* รูป AI มีตัวหนังสือ PMS ที่ขอบล่าง → แสดงส่วนบนของรูป */
.page-banner__box::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgb(9 16 38 / 0.88) 0%, rgb(9 16 38 / 0.6) 55%, rgb(9 16 38 / 0.35) 100%); }
.page-banner__grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.25rem clamp(2rem, 5vw, 6rem); align-items: end; }
.page-banner__grid--stack { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
.page-banner h1 { margin: 0; }
.page-banner__intro { margin: 0; font-size: 0.9375rem; text-shadow: 0 1px 2px rgb(0 0 0 / 0.7), 0 0 18px rgb(0 0 0 / 0.55); }

.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin: 0 0 1.25rem; padding: 0; list-style: none; font-size: 0.875rem; }
.breadcrumb li { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--color-text); }
.breadcrumb a { color: var(--color-text); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-heading); text-decoration: underline; }
.breadcrumb .icon { width: 0.9rem; height: 0.9rem; opacity: 0.6; }
.breadcrumb [aria-current] { color: var(--color-heading); font-weight: 600; }

/* รูปที่กดดูขยายได้ (เปิดในหน้าต่าง lightbox ไม่ต้องเปิดแท็บใหม่) */
.zoomable { position: relative; display: block; overflow: hidden; border-radius: var(--radius); cursor: zoom-in; }
.zoomable img { border-radius: 0; }
.zoomable__badge { position: absolute; top: 0.75rem; right: 0.75rem; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: var(--black); background: rgb(255 255 255 / 0.92); border-radius: 50%; box-shadow: var(--shadow-sm); opacity: 0; transform: scale(.85); transition: opacity .25s var(--ease), transform .25s var(--ease); }
.zoomable__badge .icon { width: 1.1rem; height: 1.1rem; }
.zoomable:hover .zoomable__badge, .zoomable:focus-visible .zoomable__badge { opacity: 1; transform: none; }
@media (hover: none) { .zoomable__badge { opacity: 1; transform: none; width: 34px; height: 34px; } }

/* หน้าต่างดูรูปขยาย */
.lightbox { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: clamp(3.5rem, 2rem + 4vw, 5rem) clamp(0.75rem, 4vw, 5.5rem); color: var(--white); background: transparent; border: 0; overflow: hidden; }
.lightbox::backdrop { background: rgb(9 16 38 / 0.92); backdrop-filter: blur(4px); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox__figure { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; max-width: 100%; max-height: 100%; margin: 0; }
.lightbox__img { display: block; max-width: 100%; max-height: calc(100dvh - 9rem); width: auto; height: auto; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); user-select: none; touch-action: pan-y; }
.lightbox__caption { font-size: 0.9375rem; text-align: center; color: rgb(255 255 255 / 0.9); }
.lightbox__count { margin-left: 0.5rem; color: rgb(255 255 255 / 0.55); }
.lightbox__btn { position: absolute; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; color: var(--white); background: rgb(255 255 255 / 0.12); border: 1px solid rgb(255 255 255 / 0.2); border-radius: 50%; cursor: pointer; transition: background-color .2s; }
.lightbox__btn:hover { background: rgb(255 255 255 / 0.25); }
.lightbox__btn .icon { width: 1.4rem; height: 1.4rem; }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev, .lightbox__next { top: 50%; margin-top: -24px; }
.lightbox__prev { left: 1rem; }
.lightbox__prev .icon { transform: rotate(180deg); }
.lightbox__next { right: 1rem; }
.lightbox.is-single .lightbox__prev, .lightbox.is-single .lightbox__next, .lightbox.is-single .lightbox__count { display: none; }
@media (max-width: 575px) {
  /* มือถือ: ปุ่มเลื่อนรูปอยู่ด้านล่าง ไม่บังรูป */
  .lightbox__prev, .lightbox__next { top: auto; bottom: 1rem; margin-top: 0; }
  .lightbox__prev { left: calc(50% - 56px); }
  .lightbox__next { right: calc(50% - 56px); }
}
/* แถบชวนขอใบเสนอราคาท้ายหน้า: แผงสีฟ้าอ่อนมุมโค้ง จัดกึ่งกลาง */
.cta-band { padding-block: 0 var(--section-y); }
.cta-band__inner { padding: clamp(2.5rem, 2rem + 3vw, 4rem) clamp(1.5rem, 1rem + 3vw, 3rem); text-align: center; background: var(--tint); border-radius: var(--radius-lg); }
.cta-band__inner h2 { max-width: 680px; margin-inline: auto; }
.cta-band__inner p { max-width: 620px; margin-inline: auto; }
.cta-band__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 1.75rem; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 3rem 1.5rem; text-align: center; background: var(--tint); border-radius: var(--radius-lg); }
.empty-state .icon { width: 2.75rem; height: 2.75rem; padding: 0.6rem; color: var(--white); background: var(--brand); border-radius: 50%; }
.empty-state p { max-width: 560px; }

.badge { display: inline-block; padding: 0.25rem 0.9rem; font-size: 0.8125rem; font-weight: 600; color: var(--brand-dark); background: var(--tint); border-radius: 999px; text-decoration: none; }

/* 8. Utilities ------------------------------------------------------------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Responsive (ใช้ breakpoint ชุดเดียวกันทุกไฟล์: 1199 / 991 / 767 / 575 / 375) ---- */
@media (max-width: 991px) {
  .btn--sm { min-height: 44px; } /* ปุ่มเล็กบนจอสัมผัส: สูงอย่างน้อย 44px */
}
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  .section-head--split, .page-banner__grid { grid-template-columns: 1fr; align-items: start; }
  .section-head__side { justify-self: start; max-width: none; padding-bottom: 0; }
  .page-banner__box { min-height: 300px; padding-top: calc(var(--header-h) + 2.5rem); }
}
@media (max-width: 575px) {
  .cta-band__actions .btn { width: 100%; }
  .page-banner { padding: 8px 8px 0; }
  .page-banner__box { border-radius: var(--radius); }
  .panel-tint, .cta-band__inner { border-radius: var(--radius); }
}
@media (max-width: 375px) {
  :root {
    --gutter: 12px;
    --fs-h1: 2rem;
    --fs-h2: 1.5rem;
  }
  .page-banner { padding: 6px 6px 0; }
}
