:root { 
    --primary-color: #0084FF; /* เปลี่ยนเป็นสีฟ้าหลัก */
    --primary-light: #4DA3FF; /* สีฟ้าอ่อนสำหรับไล่เฉด */
    --bg-color: #F0F8FF; /* สีพื้นหลังฟ้าอ่อน สบายตา */
    --text-dark: #2c2c2c; 
    --text-muted: #8e8e93; 
}

/* ให้อนุญาตการ Scroll ธรรมชาติบนหน้าจอคอมพิวเตอร์ */
body, html { 
    margin: 0; padding: 0; background-color: var(--bg-color); font-family: 'Inter', sans-serif; color: var(--text-dark); -webkit-font-smoothing: antialiased; width: 100%;
}
.app-wrapper { display: flex; flex-direction: column; width: 100%; min-height: 100vh; }
.top-header-area { flex-shrink: 0; background: rgba(255,255,255,0.98); backdrop-filter: blur(10px); z-index: 1050; padding-top: env(safe-area-inset-top); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.scrollable-content-area { flex-grow: 1; padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }

input[type="text"], input[type="search"], input[type="number"], input[type="tel"], input[type="password"], textarea, select { font-size: 16px !important; }

.bottom-nav { display: flex; justify-content: space-around; align-items: center; height: 55px; background: transparent; }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; height: 100%; width: 100%; position: relative; }
.bottom-nav-item i { font-size: 1.2rem; margin-bottom: 2px; transition: all 0.3s;}
.bottom-nav-item span:not(.badge-cart) { font-size: 0.65rem; font-weight: 600; }
.bottom-nav-item.active { color: var(--primary-color); border-bottom: 2px solid var(--primary-color); }
.bottom-nav-item.active i { transform: translateY(-2px); }
.bottom-nav-item .badge-cart { top: 0px; right: calc(50% - 28px); padding: 2px 6px; position: absolute; background-color: var(--primary-color); color: white; border-radius: 12px; font-size: 0.65rem; font-weight: bold; border: 1.5px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.mobile-hidden-nav { display: none !important; }
.text-primary-custom { color: var(--primary-color) !important; }
.bg-primary-custom { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%) !important; color: white; }
.btn-primary-custom { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%); color: white; border: none; font-weight: 600; letter-spacing: 0.5px; box-shadow: 0 4px 15px rgba(0, 132, 255, 0.3); transition: all 0.3s ease; }
.btn-primary-custom:hover { background: var(--primary-color); color: white; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 132, 255, 0.4);}
.view-section { display: none; animation: fadeIn 0.3s ease-out; } 
.view-section.active { display: block; } 
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.product-card { background: white; border-radius: 4px; overflow: hidden; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,0.04); cursor: pointer; transition: all 0.3s ease; height: 100%; display: flex; flex-direction: column; border: 1px solid rgba(0,0,0,0.03); }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.product-img { width: 100%; height: 180px; object-fit: contain; background: white; border-top-left-radius: 4px; border-top-right-radius: 4px;}
.product-info { padding: 8px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; }
.product-name { font-size: 0.85rem; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-dark); line-height: 1.3;}
.product-price { color: var(--primary-color); font-weight: 700; font-size: 1.05rem; }

.form-control, .form-select { border-radius: 8px; padding: 12px 15px; border: 1px solid #e5e5ea; font-size: 0.95rem; font-weight: 500; color: var(--text-dark); background-color: #fafafa; transition: all 0.2s; }
.form-control:focus, .form-select:focus { background-color: #fff; border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.1); }
.cart-item { background: white; padding: 15px; border-radius: 12px; margin-bottom: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.02);}
.cart-item-img { width: 80px; height: 80px; object-fit: contain; border-radius: 8px; background: #fff;}
.qty-btn { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: bold; border-color: #e5e5ea; color: var(--text-dark);}
.qty-btn:hover { background-color: var(--primary-light); color: white; border-color: var(--primary-light);}
.modal-content { border-radius: 16px; border: none; box-shadow: 0 10px 40px rgba(0,0,0,0.1); }

.profile-card { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%); color: white; border-radius: 16px; padding: 25px; margin-bottom: 20px; box-shadow: 0 10px 20px rgba(0, 132, 255, 0.2); text-align: center; background-size: cover; background-position: center; transition: all 0.3s ease;}
.profile-avatar { width: 80px; height: 80px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; margin: 0 auto 15px auto; border: 3px solid rgba(255,255,255,0.5); background-size: cover; background-position: center;}
.menu-list { background: white; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.menu-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.2s; font-weight: 600; color: var(--text-dark);}
.menu-item:hover { background: #f9f9f9; } .menu-item:last-child { border-bottom: none; }
.menu-icon { width: 35px; height: 35px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-right: 15px; font-size: 1.1rem;}

.loader-overlay { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(255,255,255,0.9); z-index: 2000; display: flex; justify-content: center; align-items: center; flex-direction: column; backdrop-filter: blur(5px); }
.order-pane.active, .vpane.active { display: block; animation: fadeIn 0.3s; }
#imageViewerModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 9999; display: flex; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease; }
#fullScreenImg { max-width: 95%; max-height: 90vh; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: scale(0.9); transition: transform 0.3s ease; }
.close-viewer-btn { position: absolute; top: env(safe-area-inset-top, 20px); right: 25px; color: white; font-size: 2.5rem; font-weight: bold; cursor: pointer; z-index: 10000; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }

.price-modern { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.modal-bottom-sheet { display: flex; align-items: flex-end; min-height: 100%; margin: 0; max-width: 100%; }
.modal-bottom-sheet .modal-content { border-radius: 20px 20px 0 0; border: none; padding-bottom: env(safe-area-inset-bottom); }
.var-btn { border: 1px solid #e0e0e0; background: #f9f9f9; padding: 6px 14px; border-radius: 4px; font-size: 0.85rem; cursor: pointer; color: #333; display: inline-block; margin: 4px 6px 4px 0; transition: all 0.2s;}
.var-btn.active { border-color: var(--primary-color); color: var(--primary-color); background: #E5F2FF; font-weight: bold;}

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.shop-more-item { flex: 0 0 100px; max-width: 100px; border-radius: 6px; border: 1px solid #f0f0f0; overflow: hidden; background: #fff; cursor: pointer; transition: transform 0.2s;}
.shop-more-item:active { transform: scale(0.95); }
.shop-more-img { width: 100%; height: 100px; object-fit: contain; }
.shop-more-price { font-size: 0.85rem; font-weight: 700; color: var(--primary-color); padding: 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}

/* --- VENDOR REDESIGN --- */
#view-vendor { display: none; height: 100%; flex-direction: column; background: var(--bg-color); padding: 0 !important; }
#view-vendor.active { display: flex; }
.vendor-fixed-header { flex-shrink: 0; background: #fff; z-index: 1020; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.vendor-scrollable-content { flex-grow: 1; overflow-y: auto; padding: 8px; -webkit-overflow-scrolling: touch; }

.btn-vendor-tab { background: transparent; border: none; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; padding: 10px 5px; transition: all 0.2s; white-space: nowrap; flex: 1; text-align: center; }
.btn-vendor-tab i { color: var(--text-muted); transition: all 0.2s; }
.btn-vendor-tab.active { color: var(--primary-color); font-weight: 700; border-bottom: 2px solid var(--primary-color); }
.btn-vendor-tab.active i { color: var(--primary-color); }

.v-prod-card { background: #fff; border-radius: 8px; border: 1px solid #e5e5ea; box-shadow: 0 1px 3px rgba(0,0,0,0.02); overflow: hidden; position: relative; display: flex; flex-direction: column; height: 100%; transition: transform 0.2s; }
.v-prod-card:active { transform: scale(0.97); }
.v-prod-img-wrap { position: relative; width: 100%; height: 110px; background: #fff; border-bottom: 1px solid #f9f9f9; }
.v-prod-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.v-prod-id { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,0.6); color: white; font-size: 0.55rem; padding: 2px 4px; border-radius: 4px; z-index: 2; letter-spacing: 0px; }
.v-prod-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; z-index: 2; }
.v-action-btn { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.95); border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0,0,0,0.15); cursor: pointer; font-size: 0.65rem; }
.v-action-btn.edit { color: var(--primary-color); }
.v-action-btn.delete { color: #dc3545; }
.v-prod-info { padding: 6px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; }
.v-prod-name { font-size: 0.7rem; font-weight: 500; color: #333; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; margin-bottom: 4px; }
.v-prod-meta { display: flex; justify-content: space-between; align-items: center; }
.v-prod-price { font-size: 0.85rem; font-weight: 700; color: var(--primary-color); margin: 0; }
.v-prod-stock { font-size: 0.6rem; background: #f0f0f0; padding: 2px 4px; border-radius: 4px; color: #555; font-weight: 600; }

/* --- PRODUCT ACTION BUTTONS --- */
.action-btn-add {
    background-color: #E5F2FF;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}
.action-btn-add:hover, .action-btn-add:active {
    background-color: #CCE5FF;
    color: var(--primary-color);
}
.action-btn-buy {
    border-radius: 4px;
    padding: 6px 18px;
    font-size: 0.95rem;
    box-shadow: none;
}

/* เฉพาะโหมดมือถือ (Mobile App Mode) */
@media (max-width: 767px) {
  body, html { height: 100%; width: 100%; overflow: hidden; position: fixed; }
  .app-wrapper { height: 100dvh; width: 100%; }
  .scrollable-content-area { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  #product-list, #shop-profile-product-list, #pd-recommendations { margin-left: -2px; margin-right: -2px; } 
  #product-list > div, #shop-profile-product-list > div, #pd-recommendations > div { padding-left: 2px; padding-right: 2px; padding-bottom: 4px; }

  .desktop-container { max-width: 100% !important; }
  .search-input-mini { font-size: 0.85rem !important; }
  .input-group-text { font-size: 0.85rem; }
  .pd-zoom-icon { position: absolute; bottom: 15px; right: 15px; background: rgba(0,0,0,0.5); color: white; width: 35px; height: 35px; border-radius: 50%; display: flex; justify-content: center; align-items: center; pointer-events: none; }
  .desktop-action-btns { display: none !important; }
  .cart-desktop-row { display: flex; flex-direction: column; } 
  .cart-items-col { order: 2; padding: 0; } 
  .cart-summary-col { order: 1; width: 100%; position: sticky; top: 0; z-index: 1020; margin-top: 0; }
  #cart-summary { display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; padding: 10px 15px !important; margin-bottom: 8px !important; }
  #cart-summary h6.fw-bold { display: none !important; }
  #cart-summary > div.d-flex { flex-direction: column !important; align-items: flex-start !important; margin-bottom: 0 !important; padding-bottom: 0 !important; border-bottom: none !important; width: auto !important; }
  #cart-summary > div.d-flex span.text-muted { font-size: 0.75rem !important; } 
  #cart-summary > div.d-flex span.fs-4 { font-size: 1.15rem !important; line-height: 1.2 !important; margin-top: 2px; }
  #cart-summary button { width: auto !important; margin-top: 0 !important; padding: 10px 25px !important; font-size: 0.9rem !important; border-radius: 6px !important; flex-shrink: 0; }
  #cart-items > div.mb-3 { background: white; margin-bottom: 8px !important; border-radius: 8px;}
  #cart-items h6.fw-bold { padding: 12px 15px 5px; margin: 0 !important; font-size: 0.95rem; }
  .cart-item { padding: 10px 15px !important; border-radius: 8px !important; margin-bottom: 0 !important; box-shadow: none !important; border: none !important; border-bottom: 1px solid #f9f9f9 !important; }
  #view-profile .profile-card { border-radius: 12px !important; padding: 25px 15px !important; } 
  #view-profile .profile-card h5 { font-size: 1.15rem !important; } 
  #view-profile .profile-card p { font-size: 0.85rem !important; }
  #view-profile .menu-item { padding: 14px 15px !important; } 
  #view-profile .menu-item span { font-size: 0.85rem !important; }
}

@media (min-width: 768px) {
  .app-wrapper { height: auto; min-height: 100vh; overflow: visible; }
  .scrollable-content-area { overflow: visible; padding-bottom: 20px;}
  .top-header-area { position: sticky; top: 0; padding-top: 0; }
  
  .bottom-nav { width: 100%; height: 60px; justify-content: center; gap: 50px; padding: 0 30px; border-bottom: 1px solid #eee; }
  .bottom-nav-item { color: var(--text-muted); font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; width: auto; padding: 0 10px;}
  .bottom-nav-item i { margin-bottom: 0; font-size: 1.1rem; }
  .bottom-nav-item span { font-size: 0.95rem !important; }
  .bottom-nav-item.active { border-bottom: 3px solid var(--primary-color); }
  .bottom-nav-item.active i { transform: none; }
  .desktop-container { max-width: 1200px !important; margin: 0 auto; }
  .pd-desktop-row { display: flex; gap: 40px; align-items: flex-start; } .pd-img-col { flex: 0 0 45%; position: relative; } .pd-info-col { flex: 1; margin-bottom: 0; border: none !important; }
  #pd-img { border-radius: 12px; width: 100%; height: auto; max-height: 500px; object-fit: contain; box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
  .pd-zoom-icon { position: absolute; bottom: 85px; right: 20px; background: rgba(0,0,0,0.5); color: white; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; pointer-events: none;}
  .product-action-bar-mobile { display: none !important; }
  .desktop-action-btns { display: flex !important; gap: 15px; margin-top: 30px; }
  .desktop-action-btns .add-btn { background: #E5F2FF; border: none; color: var(--primary-color); }
  .cart-desktop-row { display: flex; gap: 30px; align-items: flex-start; } .cart-items-col { flex: 1; } .cart-summary-col { width: 380px; position: sticky; top: 130px; }
  .profile-desktop-row { display: flex; gap: 40px; align-items: flex-start; } .profile-left-col { width: 350px; position: sticky; top: 130px; } .profile-right-col { flex: 1; }
  .product-img { height: 220px; }
  .modal-bottom-sheet { align-items: center; justify-content: center; max-width: 500px; margin: 1.75rem auto; min-height: auto;}
  .modal-bottom-sheet .modal-content { border-radius: 16px; padding-bottom: 0;}
  .v-prod-img-wrap { height: 160px; }
  .v-prod-name { font-size: 0.85rem; margin-bottom: 6px; }
  .v-prod-price { font-size: 1rem; }
  .v-prod-info { padding: 10px; }
  .v-action-btn { width: 28px; height: 28px; font-size: 0.8rem; }
}

.order-status-tab {
    padding: 6px 16px !important;
    border-radius: 20px !important;
    background-color: #e0e0e0;
    color: #666;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
}
.order-status-tab.active {
    background-color: #E5F2FF !important;
    color: var(--primary-color) !important;
    border: 1.5px solid var(--primary-color) !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(0, 132, 255, 0.15);
}
.btn-vendor-tab {
    color: var(--text-muted);
    border-bottom: 3px solid transparent !important;
    transition: all 0.2s ease;
}
.btn-vendor-tab.active {
    color: var(--primary-color) !important;
    border-bottom: 3px solid var(--primary-color) !important;
    font-weight: 700 !important;
    background-color: rgba(0, 132, 255, 0.05);
}
.bottom-nav-item.active {
    color: var(--primary-color) !important;
    border-bottom: 3px solid var(--primary-color) !important;
    font-weight: 700;
}
/* 🌟 ปรับขนาด Popup แจ้งเตือน (SweetAlert2) สไตล์แอปมืออาชีพ 🌟 */
div.swal2-container { padding: 15px; }
div.swal2-popup { 
    width: 310px !important; 
    padding: 25px 20px 20px !important; 
    border-radius: 20px !important; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important; 
    border: none !important; 
}
div.swal2-icon { 
    transform: scale(0.65) !important; 
    margin: -20px auto -15px !important; 
    border-width: 3px !important; 
}
h2.swal2-title { 
    font-size: 1.15rem !important; 
    font-weight: 700 !important; 
    color: #1c1c1e !important; 
    margin-bottom: 8px !important; 
}
div.swal2-html-container { 
    font-size: 0.85rem !important; 
    color: #8e8e93 !important; 
    margin: 0 !important; 
}
div.swal2-actions { 
    width: 100% !important; 
    margin-top: 25px !important; 
    gap: 10px; 
}
button.swal2-confirm, button.swal2-cancel { 
    flex: 1; 
    font-size: 0.95rem !important; 
    font-weight: 700 !important; 
    padding: 12px !important; 
    border-radius: 12px !important; 
    margin: 0 !important; 
}
button.swal2-cancel { 
    background-color: #f2f2f7 !important; 
    color: #ff3b30 !important; 
}
