:root { --primary-color: #ee4d2d; --primary-light: #ff734d; --bg-color: #f6f6f9; --text-dark: #2c2c2c; --text-muted: #8e8e93; }
body { background-color: var(--bg-color); font-family: 'Inter', sans-serif; color: var(--text-dark); -webkit-font-smoothing: antialiased; padding-bottom: calc(60px + env(safe-area-inset-bottom)); padding-top: env(safe-area-inset-top); }
.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(238, 77, 45, 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(238, 77, 45, 0.4);}
.view-section { display: none; animation: fadeIn 0.4s ease-out; } .view-section.active { display: block; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.sticky-header { position: sticky; top: 0; z-index: 1000; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 15px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.product-card { background: white; border-radius: 0px; 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; }
.product-info { padding: 10px; 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(238, 77, 45, 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); }
.app-layout { width: 100%; min-height: 100vh; background-color: var(--bg-color); position: relative;}
.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(238, 77, 45, 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: #fff5f3; 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: 100vh; flex-direction: column; overflow: hidden; 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 8px calc(75px + env(safe-area-inset-bottom)) 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: #007bff; font-weight: 700; }
.btn-vendor-tab.active i { color: #007bff; }

.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; backdrop-filter: blur(2px); }
.v-action-btn.edit { color: #007bff; }
.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; }

@media (max-width: 767px) {
  .desktop-container { max-width: 100% !important; }
  .bottom-nav { position: fixed !important; bottom: 0 !important; left: 0 !important; width: 100% !important; z-index: 1000 !important; background: rgba(255,255,255,0.98); backdrop-filter: blur(10px); display: flex; justify-content: space-around; align-items: center; height: calc(50px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid #ebebeb; }
  .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); }
  .bottom-nav-item.active i { transform: translateY(-2px); }
  .bottom-nav-item .badge-cart { top: -1px; right: calc(50% - 18px); transform: scale(0.75); padding: 4px 6px; }
  .mobile-hidden-nav { display: none !important; }
  #product-list, #shop-profile-product-list { margin-left: -5px; margin-right: -5px; } #product-list > div, #shop-profile-product-list > div { padding-left: 5px; padding-right: 5px; }
  #view-product { padding: 0 !important; background: white !important; } #view-product > .container-fluid { padding: 0 !important; }
  
  #pd-header-wrapper { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; z-index: 1000 !important; background: transparent !important; border: none !important; padding: calc(10px + env(safe-area-inset-top)) 15px 0 15px !important; pointer-events: none; }
  #pd-header-wrapper button, #pd-search-overlay { pointer-events: auto; }
  #pd-header-wrapper button { background: rgba(0,0,0,0.4) !important; color: white; border: none; width: 35px !important; height: 35px !important; }
  
  .pd-img-col { padding: 0 !important; margin: 0 !important; border: none !important; border-radius: 0 !important; box-shadow: none !important; background: white; position: relative;}
  #pd-img { width: 100vw; height: 100vw; max-height: 450px; object-fit: contain; border-radius: 0 !important; cursor: zoom-in; }
  .pd-zoom-icon { position: absolute; bottom: 85px; 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; }
  
  .pd-info-col { padding: 15px !important; margin-bottom: 0 !important; border-radius: 0 !important; border: none !important; box-shadow: none !important; margin-top: 0px; border-bottom: 1px solid #f0f0f0 !important; }
  .pd-recommendations-wrapper { padding: 15px; background: white; margin-top: 0; }
  
  .product-action-bar-mobile { position: fixed !important; bottom: 0 !important; left: 0 !important; width: 100% !important; background: white; z-index: 1050 !important; display: flex; height: calc(50px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid #ebebeb; }
  .action-icon-btn { width: 20%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #555; background: white; border-right: 1px solid #ebebeb; cursor: pointer; }
  .action-icon-btn i { font-size: 1.15rem; margin-bottom: 1px; color: #555; } .action-icon-btn span { font-size: 0.65rem; }
  .action-text-btn { width: 30%; height: 100%; border-radius: 0; border: none; font-size: 0.9rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0; }
  .btn-add-mobile { background-color: #ffeae5; color: var(--primary-color); } .btn-buy-mobile { background-color: var(--primary-color); color: white; }
  .desktop-action-btns { display: none !important; }
  #view-cart { padding: 0 !important; background: var(--bg-color); }
  #view-cart h4.fw-bold { font-size: 1.15rem; padding: 15px 15px 5px 15px; margin-bottom: 0 !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; border-radius: 0 !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: 0; border-bottom: 1px solid #ebebeb;}
  #cart-items h6.fw-bold { padding: 12px 15px 5px; margin: 0 !important; font-size: 0.95rem; }
  .cart-item { padding: 10px 15px !important; border-radius: 0 !important; margin-bottom: 0 !important; box-shadow: none !important; border: none !important; border-bottom: 1px solid #f9f9f9 !important; }
  #view-profile > .container-fluid { padding: 0 !important; }
  .profile-card { border-radius: 0 !important; margin-bottom: 8px !important; padding: 25px 15px !important; } .profile-card h5 { font-size: 1.15rem !important; } .profile-card p { font-size: 0.85rem !important; }
  #view-profile .card.rounded-4, #view-profile .bg-white.rounded-4 { border-radius: 0 !important; box-shadow: none !important; margin-bottom: 8px !important; border-bottom: 1px solid #ebebeb !important; }
  #view-profile .menu-list { border-radius: 0 !important; box-shadow: none !important; margin-bottom: 0 !important; border-bottom: 1px solid #ebebeb !important; }
  #view-profile .menu-item { padding: 14px 15px !important; } #view-profile .menu-item span { font-size: 0.85rem !important; }
  input[type="text"], input[type="search"] { font-size: 16px !important; }
  .vendor-fixed-header { padding-top: env(safe-area-inset-top); }
}

@media (min-width: 768px) {
  body { padding-bottom: 20px; padding-top: 80px; }
  .bottom-nav { position: fixed; top: 0; left: 0; width: 100%; height: 75px; z-index: 1000; background: rgba(255,255,255,0.98); backdrop-filter: blur(10px); display: flex; justify-content: center; gap: 50px; align-items: center; box-shadow: 0 2px 15px rgba(0,0,0,0.05); padding: 0 30px; }
  .bottom-nav-item { color: var(--text-muted); cursor: pointer; font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; padding: 10px; }
  .bottom-nav-item.active { color: var(--primary-color); border-bottom: 3px solid var(--primary-color); padding-bottom: 25px; top: 12px;}
  .sticky-header { top: 75px; background: transparent; border-bottom: 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; }
  #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); background: white; }
  .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: #ffeae5; 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: 100px; }
  .profile-desktop-row { display: flex; gap: 40px; align-items: flex-start; } .profile-left-col { width: 350px; position: sticky; top: 100px; } .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;}
  .pd-recommendations-wrapper { padding: 0 10px; margin-top: 20px; }
  
  /* Vendor Desktop Specific */
  .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; }
}

@media (max-width: 767px) {
    /* เมื่อเริ่มพิมพ์ ให้แถบล่างหายวับไปเลย คีย์บอร์ดจะได้ดันไม่ได้ */
    body.keyboard-open .bottom-nav,
    body.keyboard-open .product-action-bar-mobile {
        display: none !important;
    }
}
