@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600;700;800&family=Sarabun:wght@400;500;600&display=swap');

/* ===================== Design Tokens (Minimal Luxury Update) ===================== */
:root {
  --primary: #111111;
  --secondary: #333333;
  --bg: #fdfdfd;
  --bg-alt: #ffffff;
  --text: #1a1a1a;
  --text-muted: #737373;
  --border: #eaeaea;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.06);
  --font-display: 'Kanit', sans-serif;
  --font-body: 'Sarabun', sans-serif;
  --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  --bg: #0c0c0e;
  --bg-alt: #141417;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  transition: background .25s ease, color .25s ease;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ===================== Header ===================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
html[data-theme="dark"] .site-header {
  background: rgba(20, 20, 23, 0.85);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; gap: 24px;
}
.brand-text {
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-logo { height: 120px; }
.main-nav { display: flex; gap: 24px; font-weight: 500; }
.main-nav a { color: var(--text-muted); font-size: 14px; transition: var(--transition); }
.main-nav a:hover { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  background: none; border: 1px solid var(--border); cursor: pointer; font-size: 15px;
  color: var(--text); padding: 8px 12px; border-radius: 10px; transition: var(--transition);
}
.icon-btn:hover { background: var(--border); }
.wallet-badge {
  background: var(--text);
  color: var(--bg-alt); padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 13px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: 115%;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 190px; box-shadow: var(--shadow); overflow: hidden; z-index: 60;
  animation: fadeIn 0.2s ease;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 12px 16px; font-size: 14px; color: var(--text-muted); transition: var(--transition); }
.dropdown-menu a:hover { background: var(--border); color: var(--text); }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 22px; border-radius: 10px; font-weight: 600; font-size: 14px;
  cursor: pointer; border: none; transition: var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--text); color: var(--bg-alt); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.btn-primary:hover { opacity: .85; transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text); background: var(--border); transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-danger { background: var(--danger); color: #fff; }

/* ===================== Layout ===================== */
.main-content { min-height: 70vh; padding: 32px 20px 60px; }
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  margin: 40px 0 20px; display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.01em;
}

/* ===================== Hero / Banner ===================== */
.hero-banner {
  border-radius: 20px; padding: 50px 40px; margin-top: 10px;
  background: linear-gradient(135deg, rgba(120,120,128,0.06) 0%, rgba(120,120,128,0.02) 100%);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 30px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.hero-banner h1 {
  font-family: var(--font-display); font-size: 32px; font-weight: 800; margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.hero-banner p { color: var(--text-muted); max-width: 540px; margin: 0 0 24px; line-height: 1.6; font-size: 15px; }

/* ===================== Category Pills ===================== */
.cat-pills { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 10px; }
.cat-pill {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 14px; font-weight: 500; color: var(--text-muted); background: var(--bg-alt);
  cursor: pointer; transition: var(--transition);
}
.cat-pill.active, .cat-pill:hover { background: var(--text); color: var(--bg-alt); border-color: var(--text); }

/* ===================== Product Grid ===================== */

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px;
}
.product-card {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: var(--transition); position: relative;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--text-muted); }
.product-card .thumb {
  aspect-ratio: 1/1; background: #f4f4f5;
  display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--text-muted);
  overflow: hidden;
}
html[data-theme="dark"] .product-card .thumb { background: #1f1f23; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.product-card:hover .thumb img { transform: scale(1.05); }
.product-card .body { padding: 18px; display: flex; flex-direction: column; flex-grow: 1; }
.product-card .name { font-weight: 600; font-size: 14px; margin-bottom: 8px; min-height: 40px; line-height: 1.4; color: var(--text); }
.product-card .price { font-weight: 700; color: var(--text); font-size: 16px; margin-top: auto; }
.product-card .price .old { color: var(--text-muted); text-decoration: line-through; font-weight: 400; font-size: 13px; margin-right: 6px; }
.badge-flash {
  position: absolute; top: 12px; left: 12px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 6px; z-index: 2;
}
.stock-tag { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ===================== Flash Sale Countdown ===================== */
.flash-strip {
  display: flex; align-items: center; gap: 14px; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 24px 0;
  box-shadow: var(--shadow);
}
.countdown { display: flex; gap: 6px; font-family: var(--font-display); font-weight: 700; }
.countdown span { background: var(--text); color: var(--bg-alt); padding: 6px 10px; border-radius: 8px; min-width: 36px; text-align: center; }

/* ===================== Cards / Forms ===================== */
.card {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; box-shadow: var(--shadow); max-width: 460px; margin: 40px auto;
}
.card h2 { font-family: var(--font-display); margin-top: 0; font-size: 22px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.form-control {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px; font-family: var(--font-body);
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--text); background: var(--bg-alt); }

/* ===================== Alerts ===================== */
.alert { padding: 14px 18px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: rgba(239,68,68,.08); color: var(--danger); border: 1px solid rgba(239,68,68,.2); }
.alert-success { background: rgba(16,185,129,.08); color: var(--success); border: 1px solid rgba(16,185,129,.2); }
.alert-info { background: rgba(17,17,17,.06); color: var(--text); border: 1px solid var(--border); }

/* ===================== Wheel ===================== */
.wheel-wrap { display: flex; flex-direction: column; align-items: center; gap: 24px; margin: 40px 0; }
.wheel-outer { position: relative; width: 320px; height: 320px; }
.wheel-pointer {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-top: 24px solid var(--danger); z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
#wheelCanvas { border-radius: 50%; box-shadow: var(--shadow); }

/* ===================== Tables (admin) ===================== */
table.data-table { width: 100%; border-collapse: collapse; background: var(--bg-alt); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
table.data-table th, table.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; text-align: left; }
table.data-table th { background: var(--bg); font-weight: 600; color: var(--text-muted); }
.status-pill { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pending { background: rgba(245,158,11,.12); color: var(--warning); }
.status-approved, .status-completed, .status-active { background: rgba(16,185,129,.12); color: var(--success); }
.status-rejected, .status-failed, .status-banned { background: rgba(239,68,68,.12); color: var(--danger); }

/* ===================== Admin Layout ===================== */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.admin-sidebar {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; height: fit-content; box-shadow: var(--shadow);
}
.admin-sidebar a {
  display: block; padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 6px; color: var(--text-muted); transition: var(--transition);
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--text); color: var(--bg-alt); }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.stat-card .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }

/* ================= Modal Minimal Design ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-main, #ffffff);
    color: var(--text-main, #1e293b);
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    padding: 28px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border, #e2e8f0);
    transform: scale(0.95) translateY(10px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: var(--bg-secondary, #f1f5f9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--border, #cbd5e1);
    color: var(--text-main);
}

.modal-thumb {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.modal-details {
    font-size: 13px;
    color: var(--text-muted, #64748b);
    margin-bottom: 16px;
    line-height: 1.6;
    max-height: 100px;
    overflow-y: auto;
}

.modal-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.modal-price {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary, #6366f1);
}

/* Dark mode support สำหรับ Modal เฉพาะจุด */
body.dark .modal-box {
    background: #1e293b;
    border-color: #334155;
}
body.dark .modal-thumb {
    background: #0f172a;
    border-color: #334155;
}
body.dark .modal-meta-row {
    background: #0f172a;
    border-color: #334155;
}
body.dark .modal-close {
    background: #334155;
    color: #cbd5e1;
}
html[data-theme="dark"] .modal-thumb { background: #1f1f23; }
.modal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.modal-title { font-family: var(--font-display); font-size: 20px; margin: 0 0 10px; letter-spacing: -0.01em; }
.modal-details { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.modal-price { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.02em; }

/* ===================== Footer ===================== */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; color: var(--text-muted); font-size: 13px; margin-top: 60px; background: var(--bg-alt); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ===================== Keyframes & Responsive ===================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 768px) {
  .main-nav { display: none; }
  .admin-layout { grid-template-columns: 1fr; }
  .hero-banner h1 { font-size: 24px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
/* ===================== Responsive Design (Mobile & Tablet Optimization) ===================== */

/* สำหรับแท็บเล็ตและหน้าจอขนาดกลาง (<= 1024px) */
@media (max-width: 1024px) {
  .container {
    padding: 0 16px;
  }
  
  .hero-banner {
    padding: 40px 24px;
    gap: 20px;
  }

  .hero-banner h1 {
    font-size: 28px;
  }
}

/* สำหรับมือถือ (<= 768px) */
@media (max-width: 768px) {
  /* Header & Navigation */
  .header-inner {
    height: 64px;
    gap: 12px;
  }

  .main-nav {
    display: none; /* ซ่อนเมนูหลักบนมือถือ (ถ้ามีเมนูแฮมเบอร์เกอร์เดิมในระบบอยู่แล้ว) หรือปรับตามความเหมาะสม */
  }

  .brand-text {
    font-size: 18px;
  }

  .header-actions {
    gap: 8px;
  }

  .wallet-badge {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Hero Banner */
  .hero-banner {
    padding: 30px 20px;
    border-radius: 16px;
    text-align: center;
  }

  .hero-banner h1 {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .hero-banner p {
    font-size: 14px;
    margin-bottom: 20px;
  }

  /* Category Pills เลื่อนแนว,นอนบนมือถือได้สมูท */
  .cat-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .cat-pills::-webkit-scrollbar {
    display: none;
  }

  .cat-pill {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Product Grid ปรับให้เรียงสวยงามบนจอเล็ก */
  .product-grid {
    grid-template-columns: repeat(2, 1fr); /* แสดง 2 คอลัมน์บนมือถือ เพื่อให้ไม่เล็กหรือใหญ่จนเกินไป */
    gap: 12px;
  }

  .product-card .body {
    padding: 12px;
  }

  .product-card .name {
    font-size: 13px;
    min-height: 36px;
  }

  .product-card .price {
    font-size: 14px;
  }

  /* Section Titles */
  .section-title {
    font-size: 18px;
    margin: 30px 0 14px;
  }

  /* Forms & Cards */
  .card {
    padding: 20px;
    margin: 20px auto;
  }
/* ================= Modal Minimal Design (Fixed Dark Mode & Mobile) ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    z-index: 99999; /* ให้อยู่เหนือปุ่มแชทของเว็บ */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-alt);
    color: var(--text);
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    padding: 28px;
    position: relative;
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border);
    transform: scale(0.95) translateY(10px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--border);
    color: var(--text);
}

.modal-thumb {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.modal-details {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.6;
}

.modal-price {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

/* ปรับระยะสำหรับจอมือถือ ไม่ให้ทับขอบล่างหรือปุ่มแชท */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end; /* ให้ Modal เด้งขึ้นมาจากขอบล่างบนมือถือ ใช้งานง่ายด้วยมือเดียว */
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 24px 20px 36px 20px;
    animation: slideUp 0.25s ease;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
  /* Admin Layout */
  .admin-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* สำหรับมือถือขนาดเล็กมากๆ (<= 480px) */
@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: 1fr; /* ปรับเหลือ 1 คอลัมน์เต็มจอสำหรับมือถือจอเล็กสุดๆ เพื่อความชัดเจน */
  }

  .stat-cards {
    grid-template-columns: 1fr;
  }
}
.brand-text {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
/* จัดแต่งปุ่ม Category Pill ให้เรียงแนวนอน บรรทัดเดียว */
#catPills .cat-pill {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    gap: 6px !important;
    padding: 6px 14px !important;
}

/* บังคับขนาดไอคอนโลโก้ให้เล็กและสวยงาม ไม่ให้ขยายใหญ่ตามรูปต้นฉบับ */
#catPills .cat-pill img.cat-icon {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    object-fit: contain !important;
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 !important;
}