/* ============================================
   泓沛电解电容选型 H5 - 全局样式
   ============================================ */

:root {
  --primary: #1a6fb5;
  --primary-dark: #155a8f;
  --primary-light: #e8f4fd;
  --success: #07c160;
  --danger: #e64340;
  --warning: #ff976a;
  --bg: #f5f6f8;
  --bg-white: #ffffff;
  --text: #333333;
  --text-secondary: #666666;
  --text-light: #999999;
  --border: #e5e5e5;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 4px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  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);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 750px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #2196F3 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 16px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}

.logo {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-search-btn {
  font-size: 20px;
  color: #fff;
  padding: 4px 8px;
  text-decoration: none;
}

/* Main Content */
.main-content {
  flex: 1;
  padding-bottom: calc(60px + var(--safe-bottom));
  overflow-y: auto;
}

/* Tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 750px;
  height: calc(50px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}

.tabbar-item.active {
  color: var(--primary);
}

.tabbar-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.tabbar-text {
  font-size: 10px;
}

/* Card */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 18px;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  gap: 4px;
  -webkit-appearance: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:active {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:active {
  background: #06ad56;
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:active {
  background: var(--primary-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* Tag */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.tag-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-success {
  background: #e8f8ee;
  color: var(--success);
}

.tag-warning {
  background: #fff3e0;
  color: #e65100;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 750px;
  max-height: 80vh;
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 16px;
}

/* Form */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
}

.form-input::placeholder {
  color: #ccc;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  position: sticky;
  top: 48px;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.filter-chip:active {
  transform: scale(0.96);
}

/* Product Card */
.product-card {
  background: #fff;
  margin: 8px 16px;
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: transform 0.15s;
}

.product-card:active {
  transform: scale(0.985);
}

.product-card .pc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.product-card .pc-model {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.product-card .pc-series {
  font-size: 11px;
}

.product-card .pc-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-card .pc-spec {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.product-card .pc-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Section */
.section {
  margin: 16px 0;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Detail Page */
.detail-header {
  background: linear-gradient(135deg, var(--primary) 0%, #2196F3 100%);
  color: #fff;
  padding: 20px 16px;
}

.detail-header .dh-model {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-header .dh-series {
  font-size: 13px;
  opacity: 0.9;
}

.detail-header .dh-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.detail-section {
  background: #fff;
  margin: 8px 16px;
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-section-title {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-row {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
}

.spec-row:last-child {
  border-bottom: none;
}

.spec-label {
  width: 80px;
  color: var(--text-secondary);
  font-size: 13px;
  flex-shrink: 0;
}

.spec-value {
  flex: 1;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

/* Cross Reference */
.cross-ref-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
}

.cross-ref-item:last-child {
  border-bottom: none;
}

.cross-ref-brand {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.cross-ref-model {
  font-size: 14px;
  color: var(--text);
}

.cross-ref-advantage {
  font-size: 12px;
  color: var(--success);
  margin-top: 4px;
}

/* Bottom Bar (Detail) */
.detail-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 750px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  gap: 8px;
  z-index: 100;
}

.detail-bottom-bar .btn {
  flex: 1;
  font-size: 13px;
  padding: 10px 8px;
}

/* Contact Modal */
.contact-channels {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.contact-channel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s;
}

.contact-channel:active {
  transform: scale(0.96);
}

.contact-channel .cc-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.contact-channel .cc-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Home Grid */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px;
}

.home-grid-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: transform 0.15s;
  text-decoration: none;
  color: var(--text);
}

.home-grid-item:active {
  transform: scale(0.96);
}

.home-grid-item .hgi-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.home-grid-item .hgi-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.home-grid-item .hgi-desc {
  font-size: 11px;
  color: var(--text-light);
}

/* Stats */
.stats-row {
  display: flex;
  gap: 12px;
  padding: 0 16px;
  margin-top: 12px;
}

.stat-item {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-item .stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.stat-item .stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Compare Table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.compare-table th, .compare-table td {
  padding: 10px 8px;
  border: 1px solid var(--border);
  text-align: center;
  min-width: 100px;
}

.compare-table th {
  background: var(--primary-light);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.compare-table td:first-child {
  background: var(--bg);
  font-weight: 500;
  text-align: left;
  color: var(--text-secondary);
}

.compare-wrapper {
  overflow-x: auto;
  margin: 0 16px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: #fff;
  gap: 8px;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 0 12px;
}

.search-input-wrap .search-icon {
  font-size: 16px;
  color: var(--text-light);
  margin-right: 6px;
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 14px;
  outline: none;
}

.search-cancel {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  padding: 8px;
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  padding: 8px 16px;
  border: none;
  background: none;
}

/* Responsive */
@media (min-width: 750px) {
  .home-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
