/* Nebula 商城 · 对外采购门户样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f6fb; --surface: #ffffff; --border: #e6e9f2; --text: #1c2333; --text-2: #5b6478; --text-3: #98a1b3;
  --primary: #6366f1; --primary-2: #8b5cf6; --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #22c55e; --danger: #ef4444; --warning: #f59e0b;
  --radius: 14px; --shadow: 0 12px 40px rgba(40,50,80,0.14);
}
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; }

/* 按钮/输入 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .18s; font-family: inherit; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,0.3); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: #f4f6fb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.input { width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; color: var(--text); font-size: 14px; font-family: inherit; }
.input:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(139,92,246,0.15); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }

/* 登录 */
.shop-auth { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.45); padding: 24px; }
.auth-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 40px 36px; box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: var(--gradient); color: #fff; font-size: 26px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(139,92,246,0.35); }
.auth-logo.small { width: 32px; height: 32px; margin: 0; font-size: 17px; border-radius: 9px; }
.auth-box h1 { font-size: 22px; }
.sub { color: var(--text-3); font-size: 13px; margin: 4px 0 24px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 6px; }
.hint { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* 应用布局 */
.shop-app { min-height: 100vh; display: flex; flex-direction: column; }
.shop-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.customer-name { color: var(--text-2); font-weight: 600; }
.shop-tabs { display: flex; gap: 4px; padding: 12px 28px 0; background: #fff; border-bottom: 1px solid var(--border); }
.tab { border: none; background: none; padding: 12px 18px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cart-badge { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; margin-left: 4px; }
.shop-main { flex: 1; padding: 24px 28px; }

/* 商品 */
.shop-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: all .18s; }
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.p-img-wrap { height: 200px; background: #f4f6fb; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.p-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-noimg { color: var(--text-3); font-size: 13px; }
.p-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.product-card .p-name { font-weight: 600; font-size: 14px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-card .p-name:hover { color: var(--primary-2); }
.product-card .p-price { color: var(--primary-2); font-size: 20px; font-weight: 800; }
.product-card .p-unit { color: var(--text-3); font-size: 12px; }
.p-actions { display: flex; gap: 8px; }
.p-actions .btn { flex: 1; }
.empty-tip { grid-column: 1/-1; text-align: center; color: var(--text-3); padding: 60px 20px; }

/* 商品详情（淘宝式） */
.shop-detail { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.sd-box { position: relative; width: 100%; max-width: 900px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.sd-close { position: absolute; top: 14px; right: 18px; border: none; background: none; font-size: 30px; color: var(--text-3); cursor: pointer; line-height: 1; }
.sd-close:hover { color: var(--danger); }
.sd-layout { display: flex; gap: 24px; }
.sd-gallery { flex: 0 0 360px; }
.sd-gallery #sd-main-img { width: 360px; height: 360px; object-fit: contain; background: #f4f6fb; border-radius: 12px; }
.sd-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sd-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.sd-thumbs img:hover { border-color: var(--primary-2); }
.sd-info { flex: 1; min-width: 0; }
.sd-info h2 { font-size: 20px; margin-bottom: 10px; }
.sd-price { color: var(--primary-2); font-size: 26px; font-weight: 800; margin-bottom: 12px; }
.sd-params { color: var(--text-2); font-size: 13px; line-height: 1.9; margin-bottom: 16px; }
.sd-detail-section { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.sd-detail-section h3 { font-size: 16px; margin-bottom: 10px; }
.sd-desc { white-space: pre-wrap; color: var(--text-2); margin-bottom: 12px; }
.sd-detail-img { max-width: 100%; display: block; margin: 10px 0; border-radius: 8px; }

/* 购物车 */
.cart-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
.cart-panel h3 { font-size: 16px; }
.cart-items { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.cart-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.cart-item .ci-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item .ci-qty { width: 52px; }
.cart-item .ci-price { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.cart-item .ci-rm { border: none; background: none; color: var(--text-3); cursor: pointer; font-size: 16px; }
.cart-item .ci-rm:hover { color: var(--danger); }
.cart-total { display: flex; justify-content: space-between; font-size: 15px; border-top: 1px solid var(--border); padding-top: 12px; }
.cart-total b { color: var(--primary-2); font-size: 18px; }
.cart-form { display: flex; flex-direction: column; gap: 10px; }

/* 订单 */
.orders-list { display: flex; flex-direction: column; gap: 14px; }
.order-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.order-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.order-no { font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-PENDING { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-SHIPPED { background: rgba(139,92,246,0.14); color: #7c3aed; }
.pill-COMPLETED { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-CANCELLED { background: rgba(239,68,68,0.14); color: #dc2626; }
.pill-DRAFT { background: rgba(148,163,184,0.14); color: #64748b; }
.order-items { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.order-item-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); padding: 4px 0; }
.order-foot { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--text-3); }
.order-foot b { color: var(--text); }
.order-reject { margin-top: 10px; padding: 8px 10px; background: rgba(239,68,68,0.08); border-radius: 8px; color: #dc2626; font-size: 13px; }
.order-invoice { margin-top: 8px; padding: 6px 10px; background: rgba(99,102,241,0.08); border-radius: 8px; color: var(--primary); font-size: 12px; }
.order-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Toast */
.shop-toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.shop-toast div { padding: 13px 18px; border-radius: 10px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 14px; border-left: 3px solid var(--primary); }

/* 自定义弹窗 */
.shop-dialog { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.sdg-box { width: 100%; max-width: 360px; background: #fff; border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.sdg-message { font-size: 14px; font-weight: 600; }
.sdg-actions { display: flex; gap: 10px; margin-top: 16px; }
.sdg-actions .btn { flex: 1; }

/* 在线客服会话 */
.shop-chat { position: fixed; right: 20px; bottom: 20px; width: 340px; height: 440px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 250; overflow: hidden; }
.sc-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--gradient); color: #fff; font-weight: 600; }
.sc-close { border: none; background: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.sc-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.sc-msg { max-width: 80%; }
.sc-msg.sc-in { align-self: flex-start; }
.sc-msg.sc-out { align-self: flex-end; }
.sc-bubble { padding: 8px 12px; border-radius: 12px; font-size: 13px; }
.sc-in .sc-bubble { background: #f1f2f6; color: var(--text); border-bottom-left-radius: 3px; }
.sc-out .sc-bubble { background: var(--gradient); color: #fff; border-bottom-right-radius: 3px; }
.sc-time { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.sc-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }

@media (max-width: 900px) {
  .shop-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
}
