:root {
  --blue: #0b5f8a;
  --blue-dark: #073e5c;
  --bg: #f7f9fb;
  --card: #ffffff;
  --text: #1c2b36;
  --muted: #5c7080;
  --border: #e3e9ee;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Sarabun", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.section { padding: 40px 20px; }

.topbar { background: var(--blue-dark); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.brand { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.topbar nav a { color: #dceaf5; text-decoration: none; margin-left: 20px; font-size: 0.95rem; }
.topbar nav a:hover { color: #fff; }

.hero { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; padding: 60px 20px; text-align: center; }
.hero h1 { font-size: 1.8rem; margin-bottom: 16px; }
.hero p { max-width: 640px; margin: 0 auto 24px; color: #e6f1f8; }

.hero-photo { position: relative; padding: 0; overflow: hidden; }
.hero-bg { width: 100%; height: 420px; object-fit: cover; display: block; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(135deg, rgba(11,95,138,0.88), rgba(7,62,92,0.92)); display: flex; align-items: center; }
.hero-overlay .container { padding-top: 40px; padding-bottom: 40px; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: 1px; font-size: 0.78rem; color: #ffd166; font-weight: 700; margin-bottom: 10px; }
.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-outline { display: inline-block; padding: 12px 26px; border-radius: 8px; text-decoration: none; font-weight: 600; border: 2px solid #fff; color: #fff; background: transparent; }
.btn-outline:hover { background: rgba(255,255,255,0.15); }

.trust-bar { background: #eaf3f8; border-bottom: 1px solid var(--border); padding: 24px 20px; }
.trust-bar-inner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; text-align: center; }
.trust-item strong { display: block; color: var(--blue-dark); font-size: 0.98rem; margin-bottom: 4px; }
.trust-item span { font-size: 0.85rem; color: var(--muted); }

.cta-section { text-align: center; background: #fff; border-top: 1px solid var(--border); }
.cta-section p { color: var(--muted); margin-bottom: 18px; }

.btn-line-block { width: 100%; justify-content: center; margin: 16px 0; }
.shop-cta { text-align: center; margin-top: 32px; padding: 24px; background: #eaf3f8; border-radius: 12px; }
.shop-cta p { margin-bottom: 14px; color: var(--blue-dark); font-weight: 600; }

.btn { display: inline-block; padding: 12px 26px; border-radius: 8px; text-decoration: none; font-weight: 600; border: none; cursor: pointer; font-size: 1rem; }
.btn-primary { background: #ffb703; color: #1c2b36; }
.btn-primary:hover { background: #ffc93c; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.cat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 600; transition: 0.15s; display: block; overflow: hidden; }
.cat-card:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 6px 16px rgba(11,95,138,0.12); }
.cat-card-img { width: 100%; height: 110px; object-fit: cover; display: block; background: #eaf3f8; }
.cat-card-label { display: block; padding: 14px; font-size: 0.92rem; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; }
.product-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); overflow: hidden; transition: 0.15s; display: block; }
.product-card:hover { box-shadow: 0 6px 16px rgba(11,95,138,0.12); transform: translateY(-2px); }
.product-card-img { width: 100%; height: 160px; object-fit: cover; display: block; background: #eaf3f8; }
.product-card-body { padding: 18px; }
.product-card h3 { font-size: 1.02rem; margin: 0 0 6px; }
.unit { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; }
.price { color: var(--blue-dark); font-weight: 700; font-size: 1.1rem; margin: 0; }
.price-lg { font-size: 1.6rem; }

.product-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; }
.product-gallery-main { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 12px; background: #eaf3f8; border: 1px solid var(--border); }
.product-gallery-thumbs { display: flex; gap: 10px; margin-top: 10px; }
.product-thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 2px solid var(--border); cursor: pointer; background: #eaf3f8; }
.product-thumb:hover { border-color: var(--blue); }
.thumb-active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(11,95,138,0.2); }
@media (max-width: 760px) {
  .product-detail-grid { grid-template-columns: 1fr; }
}

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.chip { background: #fff; border: 1px solid var(--border); padding: 8px 14px; border-radius: 20px; text-decoration: none; color: var(--text); font-size: 0.9rem; }
.chip-active { background: var(--blue); color: #fff; border-color: var(--blue); }

.product-detail .desc { margin: 16px 0; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--blue); text-decoration: none; }

.inquiry-form { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 22px; margin-top: 24px; max-width: 420px; }
.inquiry-form input, .inquiry-form textarea {
  width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 0.95rem;
}
.inquiry-form textarea { min-height: 80px; }

.why ul { padding-left: 20px; }
.why li { margin-bottom: 6px; }

.note { background: #fff7e0; border: 1px solid #f0d98c; padding: 14px 16px; border-radius: 8px; font-size: 0.9rem; color: #6b5900; margin-bottom: 24px; }
.section-sub { margin-top: 28px; }
.sell-yes { color: #157347; }
.sell-no { color: #b02a37; }

.analysis-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.analysis-table th, .analysis-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; vertical-align: top; }
.analysis-table th { background: #f0f4f7; }

.footer { background: var(--blue-dark); color: #dceaf5; margin-top: 40px; padding: 30px 20px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; }
.footer-note { width: 100%; font-size: 0.8rem; color: #a9c4d5; margin-top: 10px; padding-top: 16px; padding-right: 150px; border-top: 1px solid rgba(255,255,255,0.12); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* ข้อมูลบริษัทผู้นำเข้า/จัดจำหน่าย (นิติบุคคล) ใน footer */
.footer-legal { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 280px; font-size: 0.85rem; line-height: 1.5; }
.footer-legal-logo { width: 110px; height: auto; border-radius: 4px; }

/* เครดิตผู้พัฒนาเว็บ มุมขวาล่างของ footer */
.footer-credit { display: inline-flex; align-items: center; gap: 6px; color: #a9c4d5; text-decoration: none; font-size: 0.78rem; white-space: nowrap; }
.footer-credit:hover { color: #fff; }
.footer-credit img { width: 20px; height: 20px; border-radius: 5px; display: block; }

/* ปุ่ม LINE ลอยมุมขวาล่าง แสดงทุกหน้า */
.line-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  background: #06C755;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 6px 18px rgba(6,199,85,0.4);
  transition: transform 0.15s;
}
.line-float:hover { transform: scale(1.05); }
.line-float svg { flex-shrink: 0; }

/* ปุ่ม LINE ในหน้ารายละเอียดสินค้า (แบบ inline ไม่ลอย) */
.btn-line {
  display: inline-flex; align-items: center; gap: 8px;
  background: #06C755; color: #fff; padding: 12px 22px; border-radius: 8px;
  text-decoration: none; font-weight: 700; font-size: 1rem; border: none; cursor: pointer;
}
.btn-line:hover { background: #05b34c; }
.btn-line svg { flex-shrink: 0; }

.rfq-note { background: #eaf3f8; border: 1px solid #cfe3ef; border-radius: 8px; padding: 12px 16px; font-size: 0.88rem; color: #073e5c; margin-bottom: 16px; }

/* ========== Mobile responsive ========== */
@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; gap: 8px; align-items: flex-start; }
  .topbar nav a { margin: 0 12px 0 0; }
  .hero h1 { font-size: 1.35rem; }
  .hero p { font-size: 0.92rem; }
  .hero-bg { height: 280px; }
  .section { padding: 28px 16px; }
  .product-grid, .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card-img, .cat-card-img { height: 110px; }
  .product-card-body { padding: 12px; }
  .product-card h3 { font-size: 0.9rem; }
  .price { font-size: 0.98rem; }
  .price-lg { font-size: 1.3rem; }
  .line-float { bottom: 14px; right: 14px; padding: 10px 14px; font-size: 0.85rem; }
  .line-float span { display: none; } /* มือถือจอเล็กมาก โชว์แค่ไอคอนพอ */
  .footer-inner { flex-direction: column; gap: 14px; }
  .footer-legal { max-width: 100%; }
  .footer-note { flex-direction: column; align-items: flex-start; padding-right: 0; }
  .analysis-table { font-size: 0.78rem; }
  .analysis-table th, .analysis-table td { padding: 7px 8px; }
  .trust-bar-inner { grid-template-columns: 1fr; gap: 14px; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .product-grid, .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ========== Technical Info section (product detail page) ========== */
.tech-info { margin-top: 48px; border-top: 2px solid var(--border); padding-top: 32px; }
.tech-info > h2 { font-size: 1.3rem; margin-bottom: 20px; color: var(--blue-dark); }
.tech-block { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; margin-bottom: 16px; }
.tech-block h3 { font-size: 1.02rem; margin: 0 0 12px; color: var(--blue-dark); }
.tech-block-warn { background: #fff8ea; border-color: #f0d98c; }
.tech-list { margin: 0; padding-left: 22px; }
.tech-list li { margin-bottom: 8px; font-size: 0.92rem; line-height: 1.55; }
.tech-note { font-size: 0.88rem; color: #6b5900; margin-top: 12px; padding-top: 12px; border-top: 1px dashed #e0cf8c; }
.tech-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tech-table th, .tech-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.tech-table th { background: #f0f4f7; }

@media (max-width: 640px) {
  .tech-block { padding: 14px 16px; }
  .tech-list li { font-size: 0.85rem; }
  .tech-table { font-size: 0.78rem; }
}

/* ========== ปุ่มแอดมินมุมล่างซ้าย (หน้าแรกเท่านั้น) ========== */
.admin-corner-link {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(7,62,92,0.35);
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  text-decoration: none;
  z-index: 998;
  transition: 0.2s;
}
.admin-corner-link:hover { background: var(--blue-dark); color: #fff; }

/* ========== หน้า Reference Project (สาธารณะ) ========== */
.ref-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 20px; }
.ref-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: 0.15s; }
.ref-card:hover { box-shadow: 0 8px 20px rgba(11,95,138,0.15); transform: translateY(-3px); }
.ref-thumb { position: relative; height: 160px; background: #eaf3f8; overflow: hidden; }
.ref-thumb iframe { width: 400%; height: 400%; transform: scale(0.25); transform-origin: top left; border: none; pointer-events: none; }
.ref-thumb-overlay {
  position: absolute; inset: 0; background: rgba(7,62,92,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
  opacity: 0; transition: 0.2s;
}
.ref-card:hover .ref-thumb-overlay { opacity: 1; }
.ref-card-body { padding: 14px; }
.ref-card-body h3 { font-size: 0.95rem; margin: 0 0 6px; }
.ref-date { font-size: 0.8rem; color: var(--muted); margin: 0; }
.ref-empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Modal ขยายดู PDF เต็มจอ */
.ref-modal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 2000; align-items: center; justify-content: center; padding: 20px;
}
.ref-modal.active { display: flex; }
.ref-modal-inner { background: #fff; border-radius: 10px; width: 100%; max-width: 900px; height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.ref-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--blue-dark); color: #fff; }
.ref-modal-header span { font-weight: 600; font-size: 0.95rem; }
.ref-modal-close { background: none; border: none; color: #fff; font-size: 0.9rem; cursor: pointer; }
.ref-modal-inner iframe { flex: 1; border: none; width: 100%; }

@media (max-width: 900px) {
  .ref-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .ref-grid { grid-template-columns: 1fr; }
  .ref-modal-inner { height: 85vh; }
}

/* ========== หน้าแอดมิน (dashboard, references, prices) ========== */
.admin-body { background: var(--bg); }
.admin-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.admin-menu-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 24px; text-decoration: none; color: var(--text); transition: 0.15s; }
.admin-menu-card:hover { box-shadow: 0 8px 20px rgba(11,95,138,0.12); transform: translateY(-2px); }
.admin-menu-icon { font-size: 1.8rem; display: block; margin-bottom: 10px; }
.admin-menu-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.admin-menu-card p { margin: 0; font-size: 0.85rem; color: var(--muted); }

.admin-upload-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 24px; margin: 20px 0; max-width: 480px; }
.admin-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.admin-form label { font-size: 0.85rem; font-weight: 600; color: var(--blue-dark); }
.admin-form input[type="text"], .admin-form input[type="file"] { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 0.95rem; }
.admin-hint { font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
.admin-error { background: #fde8e8; color: #b02a37; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.admin-success { background: #eafaf0; color: #157347; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.admin-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0 10px; }
.admin-form code { background: #f0f4f7; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }
.admin-list-title { margin-top: 30px; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.admin-table th, .admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; vertical-align: middle; }
.admin-table th { background: #f0f4f7; }
.btn-delete { background: #fde8e8; color: #b02a37; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
.btn-delete:hover { background: #f8c9c9; }

.admin-price-table .admin-price-input { width: 110px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.admin-price-current { font-size: 0.78rem; color: var(--muted); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.row-saved { background: #eafaf0; }

@media (max-width: 640px) {
  .admin-table { font-size: 0.8rem; }
  .admin-price-table .admin-price-input { width: 80px; }
}

/* ========== หน้าสถิติผู้เข้าชม (Analytics Dashboard) ========== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 20px 0 30px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; text-align: center; }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--blue-dark); }
.stat-number-sm { font-size: 1.1rem; }
.stat-label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 20px; }
.analytics-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.analytics-box h3 { margin: 0 0 6px; font-size: 1rem; }
.analytics-hint { font-size: 0.78rem; color: var(--muted); margin: 0 0 10px; }
.analytics-box .admin-table { margin-top: 8px; }

.table-scroll { overflow-x: auto; margin-top: 10px; }
.table-scroll .admin-table { min-width: 700px; }

.admin-reset-form { margin-top: 24px; text-align: right; }

@media (max-width: 640px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-number { font-size: 1.4rem; }
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ========== กราฟสถิติ (Chart.js) ========== */
.chart-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.chart-box h3 { margin: 0 0 4px; font-size: 1rem; }
.chart-box-wide { margin-bottom: 18px; }
.chart-canvas-wrap { position: relative; height: 220px; margin-top: 12px; }
.chart-canvas-wide { height: 260px; }
.chart-canvas-tall { height: 320px; }

.chart-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.chart-box-tall .chart-canvas-wrap { height: 320px; }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-canvas-tall { height: 280px; }
}
