/* ============================================================
   ถั่วงอกธนกร - Main Stylesheet
   ร้านขายสินค้าเกษตรออนไลน์
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
  /* ========================================================
     🔧 UI Density / Font Scale (ปรับขนาดฟอนต์ + UI โดยรวม)
     ใช้วิธี scale font-size บน html (rem-based) — ปลอดภัยกับ mobile viewport
     1    = ขนาดเต็ม (default เดิม)      -> 16px
     0.95 = เล็กลง 5%                    -> 15.2px
     0.92 = เล็กลง 8%  (ใกล้ Shopee)     -> 14.7px
     0.90 = เล็กลง 10% (compact สุด)     -> 14.4px
     เปลี่ยนค่านี้แล้ว refresh ได้เลย
     (ต้องเปลี่ยนที่ admin-nav.js ด้วยเพื่อให้หน้า admin ตรงกัน)
     ======================================================== */
  --ui-zoom: 0.92;

  --primary:        #2e7d32;
  --primary-light:  #4caf50;
  --primary-dark:   #1b5e20;
  --primary-bg:     #e8f5e9;
  --accent:         #f9a825;
  --accent-dark:    #e65100;
  --danger:         #e53935;
  --warning:        #fb8c00;
  --info:           #0288d1;
  --success:        #2e7d32;
  --text-primary:   #1a1a2e;
  --text-secondary: #555;
  --text-muted:     #999;
  --bg:             #f0f4f0;
  --surface:        #ffffff;
  --border:         #e0e0e0;
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.15);
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --radius-xl:      28px;
  --font:           'Prompt', 'Helvetica Neue', Arial, sans-serif;
  --transition:     0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: calc(16px * var(--ui-zoom, 1)); scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ============================================================
   Auth Layout (Login, Register, Forgot Password)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}

.auth-banner {
  background: linear-gradient(145deg, #1b5e20 0%, #2e7d32 40%, #388e3c 70%, #4caf50 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.auth-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.auth-banner-content { position: relative; text-align: center; color: #fff; }
.auth-banner-logo { font-size: 80px; margin-bottom: 24px; animation: float 3s ease-in-out infinite; }
.auth-banner h1 { font-size: 36px; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.5px; }
.auth-banner p { font-size: 16px; opacity: 0.85; max-width: 320px; line-height: 1.7; }
.auth-banner-features { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 280px; }
.auth-feature { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2); border-radius: var(--radius-md); padding: 14px 20px; display: flex; align-items: center; gap: 14px; backdrop-filter: blur(4px); }
.auth-feature-icon { font-size: 28px; flex-shrink: 0; }
.auth-feature-text { text-align: left; }
.auth-feature-text strong { display: block; font-size: 15px; font-weight: 600; }
.auth-feature-text span { font-size: 13px; opacity: 0.8; }

.auth-form-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  animation: slideUp 0.4s ease;
}
.auth-card-logo { text-align: center; margin-bottom: 28px; }
.auth-card-logo .logo-icon { font-size: 48px; }
.auth-card-logo h2 { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-top: 8px; }
.auth-card-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
/* ---- Bootstrap Override: ขนาดฟอนต์ input/select/textarea เท่ากับ label ทุกหน้า ---- */
input.form-control, select.form-select, select.form-control, textarea.form-control {
  font-size: 15px !important;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(76,175,80,0.15); }
.form-control::placeholder { color: #bbb; }
.form-control.is-invalid { border-color: var(--danger); }
.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #aaa; font-size: 18px; pointer-events: none; }
.input-icon ~ .form-control { padding-left: 44px; }
.input-toggle { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #aaa; cursor: pointer; font-size: 18px; transition: color var(--transition); }
.input-toggle:hover { color: var(--primary); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 6px; display: none; }
.form-control.is-invalid + .form-error,
.form-error.show { display: block; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0.1); opacity: 0; transition: opacity var(--transition); }
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; box-shadow: 0 4px 14px rgba(46,125,50,0.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(46,125,50,0.45); transform: translateY(-1px); }
.btn-secondary { background: var(--primary-bg); color: var(--primary-dark); }
.btn-secondary:hover { background: #c8e6c9; }
.btn-danger { background: linear-gradient(135deg, #c62828, var(--danger)); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius-md); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }
.btn .spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: none; }
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { display: none; }

/* ---- Social Buttons ---- */
.btn-google { background: #fff; color: #444; border: 1.5px solid #ddd; box-shadow: var(--shadow-sm); }
.btn-google:hover { border-color: #aaa; box-shadow: var(--shadow-md); }
.btn-apple { background: #000; color: #fff; }
.btn-apple:hover { background: #1a1a1a; }
.social-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 13px; }
.social-divider::before, .social-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.social-btns { display: flex; gap: 12px; }
.social-btns .btn { flex: 1; }

/* ---- Auth Links ---- */
.auth-links { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-links a { color: var(--primary); font-weight: 500; }

/* ---- Alert / Toast ---- */
.alert {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  align-items: flex-start;
  gap: 10px;
  animation: slideDown 0.3s ease;
}
.alert.show { display: flex; }
.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-error   { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffcc02; }
.alert-info    { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--primary);
}
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast-close { margin-left: auto; cursor: pointer; color: #aaa; font-size: 18px; }

/* ============================================================
   Main App Layout (Dashboard, Profile)
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; overflow-x: hidden; max-width: 100vw; }

/* ---- Sidebar ---- */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #1b5e20 0%, #2e7d32 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
  transition: width 0.25s ease, transform var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}
.sidebar-brand {
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  transition: padding 0.25s ease;
  flex: 0 0 auto;   /* ตรึงด้านบน ไม่ให้ยุบเมื่อเมนูยาวเกินจอ */
}
.sidebar-brand .brand-icon { font-size: 32px; flex-shrink: 0; }
.sidebar-brand .brand-name { font-size: 17px; font-weight: 700; }
.sidebar-brand .brand-sub { font-size: 11px; opacity: 0.7; }
/* พื้นที่เมนูกลาง — เลื่อนได้เมื่อจอเตี้ย */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;              /* สำคัญ: ให้ flex item หดได้ภายใต้ container ที่ overflow:hidden */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
.nav-section-title {
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.45);
  letter-spacing: 1px; text-transform: uppercase; padding: 16px 20px 6px;
  white-space: nowrap; overflow: hidden; transition: opacity 0.2s, height 0.25s;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; }
.nav-item .nav-icon { font-size: 20px; width: 24px; flex-shrink: 0; text-align: center; }
.nav-item .nav-label { transition: opacity 0.2s; }

/* Tooltip เมื่อ sidebar ย่อ */
.nav-item .nav-tooltip {
  position: absolute;
  left: 68px; top: 50%;
  transform: translateY(-50%);
  background: #1b5e20;
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
}
.nav-item .nav-tooltip::before {
  content: '';
  position: absolute;
  left: -5px; top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: #1b5e20;
  border-left: 0;
}

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: background var(--transition), padding 0.25s ease;
  white-space: nowrap;
  overflow: hidden;
  flex: 0 0 auto;   /* ตรึงด้านล่าง ไม่ให้ยุบเมื่อเมนูยาวเกินจอ */
}
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.sidebar-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; color: #fff; flex-shrink: 0; }
.sidebar-user-name { font-size: 14px; font-weight: 600; }
.sidebar-user-role { font-size: 11px; opacity: 0.7; }

/* ปุ่ม ออกจากระบบ ใน sidebar */
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  margin: 0 10px 12px;
  border-radius: 8px;
  background: rgba(231,76,60,0.18);
  border: 1px solid rgba(231,76,60,0.35);
  color: rgba(255,180,170,0.95);
  font-size: 13.5px; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, padding 0.25s ease;
  white-space: nowrap; overflow: hidden;
  flex-shrink: 0;
}
.sidebar-logout:hover { background: rgba(231,76,60,0.4); color: #fff; }
.sidebar-logout .logout-icon { font-size: 18px; flex-shrink: 0; }
.sidebar-logout .logout-text { transition: opacity 0.2s; }

/* ═══ COLLAPSED STATE ═══ */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .main-content { margin-left: 64px; }

body.sidebar-collapsed .sidebar-brand { padding: 20px 0; justify-content: center; gap: 0; }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .brand-sub { display: none; }

body.sidebar-collapsed .nav-section-title { height: 8px; opacity: 0; padding: 4px 0; }
body.sidebar-collapsed .nav-item { padding: 14px; justify-content: center; gap: 0; }
body.sidebar-collapsed .nav-item .nav-label { display: none; }
body.sidebar-collapsed .nav-item:hover .nav-tooltip { opacity: 1; }

body.sidebar-collapsed .sidebar-user { padding: 14px; justify-content: center; gap: 0; }
body.sidebar-collapsed .sidebar-user-name,
body.sidebar-collapsed .sidebar-user-role { display: none; }

body.sidebar-collapsed .sidebar-logout { padding: 11px; justify-content: center; gap: 0; margin: 0 8px 12px; }
body.sidebar-collapsed .sidebar-logout .logout-text { display: none; }

/* ---- Main Content ---- */
.main-content { margin-left: 260px; flex: 1; display: flex; flex-direction: column; transition: margin-left 0.25s ease; min-width: 0; overflow-x: hidden; }
.topbar {
  background: var(--surface);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  overflow: hidden;
  max-width: 100%;
}
.topbar-title { font-size: 20px; font-weight: 700; color: var(--text-primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg); border: none; font-size: 18px; cursor: pointer; transition: background var(--transition); color: var(--text-secondary); }
.topbar-btn:hover { background: var(--primary-bg); color: var(--primary); }
.topbar-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; cursor: pointer; border: 2px solid var(--primary-light); display:flex; align-items:center; justify-content:center; background:var(--primary-bg); color:var(--primary); font-weight:700; font-size:.95rem; }
.topbar-avatar-link { text-decoration:none; }
.topbar-avatar-img { width:40px; height:40px; border-radius:50%; object-fit:cover; border:2px solid var(--primary-light); }
.topbar-badge-btn { display:flex; align-items:center; gap:4px; padding:4px 10px; border-radius:20px; background:var(--bg); border:1px solid var(--border); color:var(--text-secondary); font-size:.85rem; position:relative; transition:background .2s; flex-shrink:0; white-space:nowrap; }
.topbar-badge-btn:hover { background:var(--primary-bg); color:var(--primary); }
.topbar-badge-btn .tb-icon { font-size:1.1rem; }
.topbar-badge-btn .tb-count { font-size:.82rem; }
.tb-badge { position:absolute; top:-4px; right:-4px; background:#e53935; color:#fff; font-size:.65rem; font-weight:700; min-width:18px; height:18px; border-radius:9px; display:flex; align-items:center; justify-content:center; padding:0 4px; line-height:1; }

/* ============================================================
   Cart Pulse + Attention Arrow (เมื่อมีสินค้าในตะกร้า)
   ============================================================ */
@keyframes cart-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.topbar-badge-btn.has-cart {
  animation: cart-pulse 1.4s ease-in-out infinite;
  background: #fff3e0 !important;
  border-color: #ffb74d !important;
}
.topbar-badge-btn.has-cart .tb-badge {
  box-shadow: 0 0 0 3px rgba(229,57,53,.22);
}

@keyframes cart-arrow-bounce {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-8px); }
}
@keyframes cart-arrow-fade-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.cart-attention-arrow {
  display: none;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  padding: 4px 10px 4px 14px;
  background: linear-gradient(90deg, #fff3e0, #ffe0b2);
  border: 1.5px solid #ff9800;
  border-radius: 20px;
  color: #e65100;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  animation: cart-arrow-fade-in .35s ease-out;
  position: relative;
  box-shadow: 0 2px 8px rgba(255,152,0,.25);
  pointer-events: none;
}
.cart-attention-arrow.show { display: inline-flex; }
.cart-attention-arrow .caa-text { letter-spacing: .02em; }
.cart-attention-arrow .caa-chevron {
  display: inline-flex;
  font-size: 1rem;
  line-height: 1;
  animation: cart-arrow-bounce .9s ease-in-out infinite;
  color: #e65100;
}

@media (max-width: 768px) {
  .cart-attention-arrow { padding: 3px 7px 3px 10px; font-size: .72rem; margin-right: 3px; }
  .cart-attention-arrow .caa-text { display: none; }
  .cart-attention-arrow .caa-chevron { font-size: 1.15rem; }
}

/* Topbar logout button */
.topbar-logout-btn {
  background: rgba(231,76,60,.1);
  border: 1px solid rgba(231,76,60,.3);
  border-radius: 8px;
  padding: 6px 12px;
  color: #e74c3c;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background .2s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-logout-btn:hover { background: rgba(231,76,60,.2); }

/* ปุ่ม collapse sidebar บน desktop */
.sidebar-toggle-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: var(--text-secondary);
  transition: background var(--transition), transform 0.25s ease;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--primary-bg); color: var(--primary); }
body.sidebar-collapsed .sidebar-toggle-btn { transform: rotate(180deg); }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger:hover span { background: var(--primary); }

.page-content { padding: 28px 24px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 56px; height: 56px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.stat-icon.green  { background: var(--primary-bg);   }
.stat-icon.yellow { background: #fff8e1; }
.stat-icon.blue   { background: #e3f2fd; }
.stat-icon.orange { background: #fff3e0; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ---- Avatar / Upload ---- */
.avatar-upload { position: relative; display: inline-block; cursor: pointer; }
.avatar-img { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary-light); display: block; }
.avatar-placeholder { width: 200px; height: 200px; border-radius: 50%; background: var(--primary-bg); border: 3px solid var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 60px; color: var(--primary); font-weight: 600; }
.avatar-overlay { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity var(--transition); color: #fff; font-size: 28px; }
.avatar-upload:hover .avatar-overlay { opacity: 1; }
.avatar-upload input[type="file"] { display: none; }

/* ---- Profile Form ---- */
.profile-header { display: flex; align-items: flex-start; gap: 24px; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.profile-info h2 { font-size: 22px; font-weight: 700; }
.profile-info p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.profile-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; margin-top: 8px; }
.badge-admin { background: #fce4ec; color: #880e4f; }
.badge-member { background: var(--primary-bg); color: var(--primary-dark); }
.badge-verified { background: #e8f5e9; color: var(--primary-dark); }
.badge-unverified { background: #fff8e1; color: #e65100; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- OTP Input ---- */
.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.otp-input {
  width: 52px; height: 60px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--text-primary);
  outline: none;
}
.otp-input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(76,175,80,0.15); background: #fff; }
.otp-input.filled { border-color: var(--primary); background: var(--primary-bg); }

/* ---- Tab System ---- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn { padding: 12px 24px; font-size: 14px; font-weight: 500; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; transition: all var(--transition); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--text-primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s ease; }

/* ---- Password Strength ---- */
.strength-bar { height: 4px; border-radius: 2px; background: var(--border); margin-top: 8px; overflow: hidden; }
.strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease, background 0.3s ease; width: 0; }
.strength-text { font-size: 12px; margin-top: 4px; }
.strength-0 .strength-fill { width: 0; }
.strength-1 .strength-fill { width: 25%; background: var(--danger); }
.strength-2 .strength-fill { width: 50%; background: var(--warning); }
.strength-3 .strength-fill { width: 75%; background: #8bc34a; }
.strength-4 .strength-fill { width: 100%; background: var(--success); }

/* ---- Dashboard Quick Links ---- */
.quick-links-section { margin-top: 24px; }
.quick-links-section .section-title {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 14px;
}
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.quick-link-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-decoration: none; color: var(--text-primary);
  transition: all 0.2s ease;
  font-weight: 500;
}
.quick-link-card:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.quick-link-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.quick-link-title { font-size: 0.92rem; white-space: nowrap; }

/* ---- Admin Config ---- */
.config-section { margin-bottom: 32px; }
.config-section-title { font-size: 17px; font-weight: 600; padding-bottom: 12px; margin-bottom: 20px; border-bottom: 2px solid var(--primary-bg); display: flex; align-items: center; gap: 10px; }
.config-section-title .icon { font-size: 22px; }
.config-group { background: var(--bg); border-radius: var(--radius-sm); padding: 20px; margin-bottom: 16px; }
.config-toggle { display: flex; align-items: center; justify-content: space-between; }
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 34px; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary-light); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---- Loading Overlay ---- */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 9999; display: none; }
.loading-overlay.show { display: flex; }
.loading-spinner { width: 48px; height: 48px; border: 4px solid var(--primary-bg); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ---- Mobile Bottom Nav ---- */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); height: 64px; z-index: 100; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); }
.bottom-nav-items { display: flex; height: 100%; }
.bottom-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); font-size: 10px; font-weight: 500; cursor: pointer; transition: color var(--transition); text-decoration: none; }
.bottom-nav-item .nav-icon { font-size: 22px; }
.bottom-nav-item.active { color: var(--primary); }

/* ---- Animations ---- */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-primary { color: var(--primary); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.skeleton { background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%); background-size: 200% 100%; animation: skeletonShimmer 1.5s infinite; border-radius: 4px; }
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-banner { display: none; }
  .auth-form-wrapper { padding: 24px 16px; }
  .auth-card { padding: 28px 20px; box-shadow: none; border: 1px solid var(--border); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 260px !important; z-index: 1000 !important; }
  .sidebar.open { transform: translateX(0) !important; }
  .main-content { margin-left: 0 !important; }
  .hamburger { display: flex; }
  .sidebar-toggle-btn { display: none; }   /* ซ่อนปุ่ม collapse บน mobile */
  /* ยกเลิก collapsed state บน mobile */
  body.sidebar-collapsed .sidebar { width: 260px !important; transform: translateX(-100%); }
  body.sidebar-collapsed .sidebar.open { transform: translateX(0) !important; }
  body.sidebar-collapsed .main-content { margin-left: 0 !important; }
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .brand-sub,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section-title,
  body.sidebar-collapsed .sidebar-user-name,
  body.sidebar-collapsed .sidebar-user-role,
  body.sidebar-collapsed .logout-text { display: unset !important; }
  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .sidebar-brand,
  body.sidebar-collapsed .sidebar-user,
  body.sidebar-collapsed .sidebar-logout { justify-content: flex-start !important; padding: revert !important; gap: 12px !important; }
  .page-content { padding: 20px 16px 80px; }
  .bottom-nav { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .topbar { padding: 0 16px; }
  .social-btns { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 16px; border-radius: var(--radius-md); }
  .otp-input { width: 44px; height: 52px; font-size: 20px; }
  .page-header h1 { font-size: 20px; }
  .topbar-logout-btn span { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar-badge-btn { padding: 3px 5px; font-size: .78rem; }
  .topbar-badge-btn .tb-count { display: none; }
  .topbar-badge-btn .tb-icon { font-size: 1rem; }
  .topbar-title { font-size: 16px; }
  .topbar { padding: 0 10px; gap: 8px; }
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }
.sidebar-overlay.show { display: block; }

/* ---- Mobile Nav (rendered by sidebar.js) ---- */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); height: 60px; z-index: 100; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); padding-bottom: env(safe-area-inset-bottom, 0); }
.mobile-nav { display: none !important; }
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;      /* สำหรับ ::before accent bar ด้านบน */
  padding-top: 4px;
}
.mobile-nav-icon { font-size: 20px; transition: transform 0.2s ease; }
.mobile-nav-label { font-size: 10px; }

/* ── Active state (เมื่ออยู่หน้านั้น) ───────────────────────── */
.mobile-nav-item.active {
  color: var(--primary-dark);
  font-weight: 700;
}
/* แถบสีด้านบนของปุ่ม active (แบบ Shopee/Lazada) */
.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
/* ไอคอนใหญ่ขึ้นเล็กน้อย + เด้งขึ้นเบาๆ */
.mobile-nav-item.active .mobile-nav-icon {
  transform: translateY(-2px) scale(1.1);
}
.mobile-nav-item.active .mobile-nav-label {
  font-weight: 700;
}

/* Hover/press feedback */
.mobile-nav-item:active { background: rgba(46,125,50,0.06); }

@media (max-width: 768px) {
  .mobile-nav { display: flex !important; }
}
