/* ============================================
   视频购物H5 - 全局样式
   移动端优先，微信绿主色调 #07c160
   ============================================ */

/* CSS变量 */
:root {
  --primary: #07c160;
  --primary-light: #38d98a;
  --primary-dark: #06ad56;
  --danger: #ee0a24;
  --warning: #ff976a;
  --info: #1989fa;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --bg: #f5f5f5;
  --bg-white: #fff;
  --border: #e8e8e8;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --nav-height: 50px;
  --header-height: 46px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* 容器：居中适配手机 */
.app-container {
  max-width: 750px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* 页面头部 */
.page-header {
  height: var(--header-height);
  line-height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header .back-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.page-header .title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.page-header .right-action {
  width: 32px;
  text-align: right;
  font-size: 14px;
  color: var(--primary);
}

/* 底部导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 750px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  padding-bottom: var(--safe-bottom);
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  color: var(--text-light);
  font-size: 10px;
  transition: color .2s;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
}

.bottom-nav .nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.bottom-nav .nav-item .badge {
  position: absolute;
  top: 2px;
  right: 50%;
  margin-right: -16px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  border-radius: 8px;
  text-align: center;
  padding: 0 4px;
}

/* 页面主体（有底部导航时） */
.page-body {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
}

.page-body-no-nav {
  padding-bottom: 10px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: opacity .2s;
  font-family: inherit;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-info {
  background: var(--info);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-lg {
  min-height: 50px;
  font-size: 16px;
  border-radius: 25px;
}

.btn-round {
  border-radius: 22px;
}

/* 输入框 */
.input-field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.input-field:focus {
  border-color: var(--primary);
}

/* 搜索框 */
.search-bar {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-white);
}

.search-bar input {
  flex: 1;
  height: 36px;
  padding: 0 10px 0 32px;
  border: none;
  border-radius: 18px;
  background: var(--bg);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.search-bar .search-icon {
  position: absolute;
  left: 22px;
  width: 16px;
  height: 16px;
  color: var(--text-light);
}

/* 卡片 */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px 12px;
  box-shadow: var(--shadow);
}

/* 列表 */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
}

/* Tab栏 */
.tab-bar {
  display: flex;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-bar .tab-item {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.tab-bar .tab-item.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-bar .tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

/* 角标 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  border-radius: 9px;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
}

.tag-primary {
  background: rgba(7,193,96,0.1);
  color: var(--primary);
}

.tag-danger {
  background: rgba(238,10,36,0.1);
  color: var(--danger);
}

.tag-warning {
  background: rgba(255,151,106,0.1);
  color: var(--warning);
}

.tag-info {
  background: rgba(25,137,250,0.1);
  color: var(--info);
}

/* 弹窗/模态框 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  width: calc(100% - 48px);
  max-width: 400px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.modal-header {
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  border-top: 1px solid var(--border);
}

.modal-footer .modal-btn {
  flex: 1;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
}

.modal-footer .modal-btn + .modal-btn {
  border-left: 1px solid var(--border);
}

.modal-footer .modal-btn.confirm {
  color: var(--primary);
  font-weight: 600;
}

.modal-footer .modal-btn.cancel {
  color: var(--text-secondary);
}

/* Toast提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}

.toast.show {
  opacity: 1;
}

/* 加载状态 */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .text {
  font-size: 14px;
}

/* 视频通话页面特殊样式 */
.video-page {
  background: #000;
  color: #fff;
}

.video-container {
  position: relative;
  width: 100%;
  height: 50vh;
  background: #1a1a1a;
  overflow: hidden;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-container .local-video {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 100px;
  height: 140px;
  border-radius: var(--radius);
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 10;
}

.video-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  background: rgba(0,0,0,0.8);
}

.video-controls .ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: transform .2s;
}

.video-controls .ctrl-btn:active {
  transform: scale(0.9);
}

.video-controls .ctrl-btn svg {
  width: 24px;
  height: 24px;
}

.video-controls .hangup-btn {
  background: var(--danger);
  color: #fff;
}

.video-controls .answer-btn {
  background: var(--primary);
  color: #fff;
}

.video-controls .mute-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.video-controls .mute-btn.active {
  background: var(--warning);
}

.video-controls .switch-cam-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* 通话下半屏面板 */
.call-panel {
  height: calc(50vh - var(--nav-height));
  background: var(--bg-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.call-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.call-panel .panel-body {
  flex: 1;
  overflow-y: auto;
}

/* 购物车项 */
.cart-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.cart-item .goods-name {
  flex: 1;
  font-size: 13px;
}

.cart-item .goods-price {
  color: var(--danger);
  font-size: 13px;
  margin-right: 8px;
  white-space: nowrap;
}

.cart-item .quantity-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item .quantity-ctrl button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-white);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cart-item .quantity-ctrl .qty {
  min-width: 20px;
  text-align: center;
  font-size: 13px;
}

/* 实时通知弹窗 */
.realtime-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 1500;
  animation: slideDown .3s ease-out;
  white-space: nowrap;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* 识别结果区 */
.recognize-result {
  padding: 8px 12px;
  background: rgba(25,137,250,0.05);
  border-top: 1px solid var(--border);
}

.recognize-result .result-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  cursor: pointer;
}

.recognize-result .result-item .name {
  flex: 1;
  font-size: 13px;
}

.recognize-result .result-item .price {
  color: var(--danger);
  font-size: 13px;
  margin-right: 8px;
}

/* 通话等待动画 */
.call-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.call-waiting .avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  margin-bottom: 16px;
}

.call-waiting .name {
  font-size: 18px;
  margin-bottom: 8px;
}

.call-waiting .status-text {
  font-size: 14px;
  color: var(--text-light);
}

/* 呼吸灯动画 */
.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 角色选择页面 */
.role-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #07c160 0%, #38d98a 100%);
}

.role-select .logo {
  width: 80px;
  height: 80px;
  background: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.role-select .logo svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
}

.role-select .app-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.role-select .app-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  margin-bottom: 40px;
}

.role-card {
  width: 100%;
  max-width: 300px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform .2s;
}

.role-card:active {
  transform: scale(0.98);
}

.role-card .role-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 24px;
}

.role-card .role-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.role-card .role-desc {
  font-size: 13px;
  color: var(--text-light);
}

/* 管理后台 */
.admin-sidebar {
  width: 200px;
  background: #304156;
  color: #fff;
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
}

.admin-sidebar .menu-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: background .2s;
}

.admin-sidebar .menu-item:hover,
.admin-sidebar .menu-item.active {
  background: rgba(255,255,255,0.1);
}

.admin-sidebar .menu-item svg {
  width: 18px;
  height: 18px;
}

.admin-main {
  margin-left: 200px;
  padding: 20px;
  background: var(--bg);
  min-height: 100vh;
}

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
}

/* 状态指示器 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.green { background: var(--primary); }
.status-dot.red { background: var(--danger); }
.status-dot.gray { background: #ccc; }
.status-dot.orange { background: var(--warning); }

/* 切换开关 */
.switch {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #ccc;
  position: relative;
  cursor: pointer;
  transition: background .2s;
}

.switch.on {
  background: var(--primary);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
}

.switch.on::after {
  left: 22px;
}

/* 图片占位 */
.img-placeholder {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 12px;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-light { color: var(--text-light); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 商品列表项 */
.goods-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.goods-item .goods-img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  background: var(--bg);
  margin-right: 10px;
  flex-shrink: 0;
  object-fit: cover;
}

.goods-item .goods-info {
  flex: 1;
  min-width: 0;
}

.goods-item .goods-info .name {
  font-size: 14px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.goods-item .goods-info .spec {
  font-size: 12px;
  color: var(--text-light);
}

.goods-item .goods-info .price {
  font-size: 15px;
  color: var(--danger);
  font-weight: 600;
}

.goods-item .goods-info .price .unit {
  font-size: 12px;
  color: var(--text-light);
  font-weight: normal;
  margin-left: 2px;
}

.goods-item .add-cart-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* 订单状态色 */
.order-status-0 { color: var(--warning); }  /* 待支付 */
.order-status-1 { color: var(--info); }     /* 已支付待备货 */
.order-status-2 { color: var(--primary); }  /* 备货完成 */
.order-status-3 { color: var(--primary); }  /* 配送中 */
.order-status-4 { color: var(--primary-dark); } /* 已送达 */
.order-status-5 { color: var(--text-light); }  /* 已取消 */
.order-status-6 { color: var(--danger); }   /* 已退款 */
