/* ═══════════════════════════════════════════
   库存管理系统 - 暖橙轻奢金融级风格
   RTL 布局 · 大圆角 · 柔和阴影 · 奶白基底
   ═══════════════════════════════════════════ */

/* ========== 设计令牌 ========== */
:root {
  --primary: #e8783a;
  --primary-dark: #c45d28;
  --primary-light: #fdf0e8;
  --primary-gradient: linear-gradient(135deg, #f0833a, #e8652e);
  --success: #3cb878;
  --warning: #f0a020;
  --danger: #e85545;
  --info: #7ec8e3;

  --bg: #faf7f2;
  --bg-gradient: linear-gradient(180deg, #fefcf8 0%, #faf7f2 40%, #f5f0e8 100%);
  --bg-white: #fff;
  --bg-card: #fefefe;

  --text: #1a1a1a;
  --text-secondary: #8a8a8a;
  --text-hint: #b8b8b8;

  --border: #ede8e0;
  --border-light: #f5f1ec;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.05);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);

  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-active: #1e293b;
  --sidebar-gold: #d4a853;
}

/* ========== 全局重置 + RTL ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100%; }
html { direction: rtl; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Arabic', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

/* ========== 表单元素 ========== */
input, select, textarea, button {
  font-family: inherit; font-size: inherit;
}

input, select, textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.25s;
  width: 100%;
  background: var(--bg-white);
  color: var(--text);
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,120,58,0.1);
  background: #fff;
}

input::placeholder, textarea::placeholder { color: var(--text-hint); }

/* ========== 按钮体系 ========== */
button {
  cursor: pointer; border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.25s;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(232,120,58,0.3);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(232,120,58,0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(232,120,58,0.25); }

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid #f5d0cc;
}
.btn-danger:hover { background: #fef5f4; border-color: var(--danger); }

.btn-default {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-default:hover { background: var(--bg); border-color: #d5cfc4; }

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 28px; font-size: 16px; border-radius: var(--radius); }

.btn-block { width: 100%; }

button:disabled {
  opacity: 0.55; cursor: not-allowed;
  transform: none !important; box-shadow: none !important;
}

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg-white); border-radius: var(--radius-lg);
  width: 90%; max-width: 480px; max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  font-size: 17px; font-weight: 650;
  color: var(--text);
  background: linear-gradient(180deg, #fefdfb, #fff);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
}
.modal-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 24px; right: 24px;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
}

.modal-body { padding: 24px; }
.modal-body p { margin-bottom: 10px; line-height: 1.6; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
  background: #fefdfb;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-hover); }

/* ========== 表格 ========== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  background: #fff;
}

table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-white);
}

th, td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

th {
  background: #fdfbf7;
  font-weight: 650; color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fdf9f4; }
tr { transition: background 0.15s; }

td { color: var(--text); font-size: 13.5px; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-weight: 550; color: var(--text); font-size: 13px;
}
.form-group .label-hint {
  font-weight: 400; color: var(--text-secondary); font-size: 12px;
}

/* ========== 分页 ========== */
.pagination {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 10px; margin-top: 20px;
  color: var(--text-secondary); font-size: 13px;
}
.pagination button { min-width: 36px; border-radius: var(--radius-sm); }

/* ========== Tabs 标签页 ========== */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 11px 22px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  font-weight: 550; color: var(--text-secondary);
  transition: all 0.2s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}
.tab:hover { color: var(--primary); background: var(--primary-light); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: linear-gradient(180deg, rgba(232,120,58,0.06), transparent);
}

.empty {
  text-align: center; color: var(--text-hint);
  padding: 48px 20px; font-size: 14px;
}

/* ═══════════════════════════════════════════
   管理端布局
   ═══════════════════════════════════════════ */

.admin-layout { display: flex; height: 100%; direction: rtl; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.85);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}
.sidebar::after {
  content: '';
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, var(--sidebar-gold), transparent 60%);
}

.sidebar-logo {
  padding: 22px 20px;
  font-size: 18px; font-weight: 750;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 1px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
}
.sidebar-logo .crown {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(212,168,83,0.5));
  color: var(--sidebar-gold);
  flex-shrink: 0;
}
.sidebar-logo .crown svg { width: 24px; height: 24px; }

.sidebar-item > span:first-child {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-menu { padding: 10px 0; flex: 1; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 22px;
  color: rgba(255,255,255,0.55);
  cursor: pointer; transition: all 0.25s;
  font-size: 14px;
  border-right: 3px solid transparent;
  margin: 2px 0;
}

.sidebar-item:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.05);
}

.sidebar-item.active {
  color: #fff;
  background: var(--sidebar-active);
  border-right-color: var(--sidebar-gold);
  font-weight: 600;
}

.main-content { flex: 1; overflow-y: auto; padding: 24px 28px; }

.page-header { margin-bottom: 24px; }
.page-header h2 {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 13px;
}

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}

.search-box { display: flex; gap: 10px; }
.search-box input { width: 240px; }

/* ========== 统计卡片 ========== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px; margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card:nth-child(1)::before { background: var(--primary-gradient); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--warning), #f5c842); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, #7ec8e3, #5aadd6); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, #3cb878, #2ea365); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.stat-card .stat-label {
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 10px; font-weight: 500;
}
.stat-card .stat-value {
  font-size: 30px; font-weight: 750;
  color: var(--text); line-height: 1.1;
}
.stat-card .stat-value.blue { color: var(--primary); }
.stat-card .stat-value.green { color: var(--success); }
.stat-card .stat-value.orange { color: var(--warning); }

/* ═══════════════════════════════════════════
   移动端底部 TabBar (管理端)
   ═══════════════════════════════════════════ */

.mobile-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-tabbar .tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 0 6px;
  font-size: 11px; color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s;
  gap: 2px;
}
.mobile-tabbar .tab-item.active { color: var(--primary); }
.mobile-tabbar .tab-icon { 
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1px; 
}
.mobile-tabbar .tab-icon svg { width: 22px; height: 22px; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .admin-layout { flex-direction: column; }
  .main-content { padding: 14px; padding-bottom: 70px; }
  .mobile-tabbar { display: flex; }
  .card { padding: 16px; border-radius: var(--radius); }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
  .page-header h2 { font-size: 18px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .pagination { flex-wrap: wrap; justify-content: center; }
}

/* ═══════════════════════════════════════════
   批发客户移动端布局
   ═══════════════════════════════════════════ */

.client-layout {
  max-width: 480px; margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  position: relative;
}

.client-header {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between; align-items: center;
  font-size: 16px; font-weight: 650;
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.client-header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--sidebar-gold), var(--primary), var(--sidebar-gold));
}

.client-content { padding: 16px; padding-bottom: 80px; }

/* 底部 TabBar */
.client-tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; background: #fff;
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.client-tabbar .tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 0 6px; gap: 2px;
  font-size: 11px; color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s;
}
.client-tabbar .tab-item.active { color: var(--primary); }
.client-tabbar .tab-icon { 
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1px; 
}
.client-tabbar .tab-icon svg { width: 22px; height: 22px; }

/* ========== 产品卡片 (商品网格) ========== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.product-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #f5d5c0;
}
.product-card .product-name {
  font-weight: 650; margin-bottom: 8px;
  font-size: 14px; color: var(--text);
}
.product-card .product-price {
  color: var(--primary); font-size: 17px;
  font-weight: 750; margin-bottom: 4px;
}
.product-card .product-stock {
  color: var(--text-hint); font-size: 12px;
}

/* ========== 购物车浮动按钮 ========== */
.cart-float {
  position: fixed; bottom: 80px; left: 16px;
  background: var(--primary-gradient);
  color: #fff;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px;
  box-shadow: 0 6px 24px rgba(232,120,58,0.4);
  cursor: pointer; z-index: 99;
  transition: all 0.3s;
}
.cart-float:hover { transform: scale(1.08); }
.cart-float:active { transform: scale(0.95); }

.cart-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--danger); color: #fff;
  font-size: 11px; min-width: 22px; height: 22px;
  border-radius: 11px; display: flex;
  align-items: center; justify-content: center;
  font-weight: 700;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(232,85,69,0.3);
}

/* ========== 确认订单页 ========== */
.confirm-page {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 18px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.confirm-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.confirm-item:last-child { border-bottom: none; }

.confirm-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; font-size: 18px; font-weight: 750;
  border-top: 2px dashed var(--border);
  margin-top: 6px;
}
.confirm-total .price { color: var(--primary); }

/* ========== 提示卡片 ========== */
.hint-card {
  background: #f0f7fb;
  border: 1px solid #cce5f5;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #3a7ca5;
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.5;
}
.hint-card::before {
  content: '💡';
  font-size: 16px; flex-shrink: 0;
}

/* ========== 仪表盘柱形图 ========== */
.bar-chart {
  display: flex; flex-direction: column; gap: 10px;
}
.bar-row {
  display: flex; align-items: center; gap: 12px;
}
.bar-label {
  width: 90px; min-width: 70px;
  font-size: 13px; font-weight: 550;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  flex-shrink: 0;
}
.bar-track {
  flex: 1; height: 22px;
  background: var(--border-light);
  border-radius: 11px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%; border-radius: 11px;
  min-width: 8px;
  transition: width 0.6s ease;
  box-shadow: 0 2px 8px rgba(232,120,58,0.2);
}
.bar-fill.bar-low {
  box-shadow: 0 2px 8px rgba(232,85,69,0.2);
}
.bar-value {
  width: 60px; flex-shrink: 0;
  text-align: right;
  font-size: 14px; font-weight: 650;
  color: var(--text);
}

@media (max-width: 768px) {
  .bar-label { width: 60px; min-width: 50px; font-size: 12px; }
  .bar-value { width: 50px; font-size: 13px; }
  .bar-row { gap: 8px; }
}
