/* ============================================
   海汇商城 - 公共样式 common.css
   ============================================ */

/* CSS 变量 */
:root {
  /* 主色 - 科技蓝 */
  --primary: #1677ff;
  --primary-dark: #0052d9;
  --primary-light: #e6f0ff;
  --primary-bg: #f0f6ff;

  /* 价格强调色 - 红 */
  --price: #ff4444;
  --price-dark: #e1251b;
  --original-price: #999;

  /* 中性色 */
  --text-main: #333;
  --text-sub: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --bg-page: #f5f5f5;
  --bg-card: #fff;

  /* 促销徽章 */
  --badge-red: #ff4444;
  --badge-orange: #ff7a00;
  --badge-green: #52c41a;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background-color: var(--bg-page);
  line-height: 1.5;
}

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

a:hover {
  color: var(--primary);
}

ul, ol {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input {
  font-family: inherit;
  outline: none;
}

/* ============================================
   Header
   ============================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}

.header-logo .logo-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}

/* 搜索框 */
.header-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  height: 40px;
}

.header-search input {
  flex: 1;
  border: 2px solid var(--primary);
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 0 16px;
  font-size: 14px;
  color: var(--text-main);
}

.header-search input::placeholder {
  color: var(--text-muted);
}

.header-search input:focus {
  box-shadow: 0 0 4px rgba(22, 119, 255, 0.2);
}

.header-search button {
  background: var(--primary);
  color: #fff;
  padding: 0 32px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 0 4px 4px 0;
  transition: background 0.2s;
}

.header-search button:hover {
  background: var(--primary-dark);
}

/* 快捷入口 */
.header-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.header-links a {
  color: var(--text-sub);
  font-size: 13px;
  white-space: nowrap;
}

.header-links a:hover {
  color: var(--primary);
}

.header-links .cart-link {
  position: relative;
  color: var(--primary);
  font-weight: 500;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 30px;
}

.footer .footer-links {
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.footer .footer-links a {
  color: var(--text-sub);
}

/* ============================================
   通用组件
   ============================================ */

/* 筛选芯片 */
.chip {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}

/* 促销徽章 */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  color: #fff;
  line-height: 1.4;
  margin-right: 4px;
}

.badge-red { background: var(--badge-red); }
.badge-orange { background: var(--badge-orange); }
.badge-green { background: var(--badge-green); }

/* 价格组件 */
.price-now {
  color: var(--price);
  font-weight: 700;
}

.price-now .symbol {
  font-size: 12px;
}

.price-old {
  color: var(--original-price);
  text-decoration: line-through;
  font-size: 12px;
  margin-left: 6px;
}

.price-arrival {
  color: var(--price);
  font-size: 12px;
  margin-left: 6px;
}

/* 标签 */
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--primary);
  border: 1px solid var(--primary);
  background: var(--primary-light);
  margin-right: 4px;
}

/* 容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 响应式 */
@media (max-width: 767px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
    gap: 10px;
  }

  .header-search {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  .header-links {
    gap: 12px;
  }

  .header-links a {
    font-size: 12px;
  }

  .header-logo .logo-text {
    font-size: 20px;
  }
}

/* ============================================
   会员登录弹窗 & Toast & 购物车角标
   ============================================ */

/* 登录弹窗遮罩 */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.login-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 登录框 */
.login-card {
  background: #fff;
  border-radius: 12px;
  width: 380px;
  max-width: 90%;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.login-overlay.active .login-card {
  transform: translateY(0);
}

.login-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.login-card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.login-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.login-close-btn:hover {
  color: #666;
}

.login-card-body {
  padding: 24px;
}

/* 提示区 */
.login-tips {
  background: var(--primary-bg);
  border: 1px solid var(--primary-light);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--primary-dark);
}

.login-tips p {
  margin-bottom: 4px;
}
.login-tips p:last-child {
  margin-bottom: 0;
}

.login-tips .copy-text {
  font-family: monospace;
  font-weight: bold;
  background: rgba(22, 119, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 表单组 */
.login-form-group {
  margin-bottom: 16px;
}

.login-form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form-group input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-main);
  transition: all 0.2s;
}

.login-form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.15);
}

/* 错误信息 */
.login-error-msg {
  color: var(--price);
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 12px;
}

/* 提交按钮 */
.login-submit-btn {
  width: 100%;
  height: 42px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.login-submit-btn:hover {
  background: var(--primary-dark);
}

/* Toast 提示 */
.shop-toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  white-space: nowrap;
}

.shop-toast.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.shop-toast.toast-warning {
  background: #fffbe6;
  color: #d46b08;
  border: 1px solid #ffe58f;
}

.shop-toast.toast-success {
  background: #f6ffed;
  color: #389e0d;
  border: 1px solid #b7eb8f;
}

/* 购物车角标 */
.cart-badge {
  display: inline-block;
  background: var(--price);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  height: 16px;
  min-width: 16px;
  line-height: 16px;
  border-radius: 8px;
  text-align: center;
  padding: 0 4px;
  margin-left: 2px;
  vertical-align: top;
}

/* 用户欢迎状态 */
.user-greeting {
  font-size: 13px;
  color: var(--text-sub);
  margin-right: 6px;
}

.logout-link {
  color: var(--text-muted) !important;
}

.logout-link:hover {
  color: var(--price) !important;
}
