/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #0a0a0f;
  color: #e8e8e8;
  font-size: 14px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ========== Pages ========== */
.page {
  display: none;
  flex-direction: column;
  height: 100%;
  padding-bottom: 56px;
}
.page.active { display: flex; }

.page-header {
  padding: 12px 16px;
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
  flex-shrink: 0;
}
.page-header h1, .page-header .logo {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}
.logo { font-size: 20px !important; }

.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

/* ========== Search Bar ========== */
.search-bar {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.search-icon { font-size: 14px; }
.search-placeholder { color: #666; font-size: 13px; }

/* ========== Banner ========== */
.banner {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.banner-item {
  padding: 24px 20px;
  min-height: 100px;
  display: flex;
  align-items: center;
}
.banner-text h2 { font-size: 20px; color: #fff; margin-bottom: 6px; }
.banner-text p { font-size: 13px; color: rgba(255,255,255,0.8); }

/* ========== Section Title ========== */
.section-title {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.section-title span {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

/* ========== Product Grid ========== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding-bottom: 20px;
}
.product-card {
  background: #15151f;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid #1e1e2e;
}
.product-card:active { transform: scale(0.97); }
.product-img {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: #1a1a2e;
}
.product-info {
  padding: 10px;
}
.product-name {
  font-size: 13px;
  color: #ddd;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price {
  font-size: 16px;
  font-weight: 700;
  color: #ff6b6b;
}
.product-price small {
  font-size: 11px;
  font-weight: 400;
  color: #888;
  text-decoration: line-through;
  margin-left: 4px;
}
.product-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(102,126,234,0.2);
  color: #8b9cf7;
  margin-top: 4px;
}

/* ========== Category ========== */
.category-layout {
  display: flex;
  height: 100%;
}
.category-sidebar {
  width: 88px;
  background: #0e0e18;
  flex-shrink: 0;
  overflow-y: auto;
}
.category-item {
  padding: 14px 8px;
  font-size: 12px;
  text-align: center;
  color: #888;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.category-item.active {
  color: #8b9cf7;
  background: #15151f;
  border-left-color: #8b9cf7;
}
.category-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}
.category-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1e1e2e;
}
.category-product {
  display: flex;
  align-items: center;
  padding: 10px;
  background: #15151f;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid #1e1e2e;
}
.category-product:active { background: #1a1a2e; }
.category-product-icon {
  font-size: 32px;
  margin-right: 10px;
  flex-shrink: 0;
}
.category-product-info { flex: 1; }
.category-product-name { font-size: 13px; color: #ddd; }
.category-product-desc { font-size: 11px; color: #666; margin-top: 2px; }
.category-product-price { font-size: 14px; font-weight: 700; color: #ff6b6b; flex-shrink: 0; }

/* ========== Orders ========== */
.order-tabs {
  display: flex;
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
  margin: -12px -12px 12px;
  padding: 0 8px;
}
.order-tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.order-tab.active {
  color: #8b9cf7;
  border-bottom-color: #8b9cf7;
}
.order-card {
  background: #15151f;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid #1e1e2e;
}
.order-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e1e2e;
}
.order-id { font-size: 12px; color: #666; }
.order-status { font-size: 12px; font-weight: 600; }
.order-status.pending { color: #ffc107; }
.order-status.paid { color: #8b9cf7; }
.order-status.done { color: #4caf50; }
.order-body {
  display: flex;
  align-items: center;
  gap: 10px;
}
.order-product-icon { font-size: 36px; flex-shrink: 0; }
.order-product-name { font-size: 13px; color: #ddd; flex: 1; }
.order-product-price { font-size: 15px; font-weight: 700; color: #ff6b6b; flex-shrink: 0; }
.order-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1e1e2e;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.order-time { font-size: 11px; color: #555; }
.btn-order-action {
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 14px;
  border: 1px solid #8b9cf7;
  background: transparent;
  color: #8b9cf7;
  cursor: pointer;
}
.btn-order-action:active { background: rgba(139,156,247,0.15); }

/* ========== Profile ========== */
.profile-card {
  display: flex;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 12px;
  margin-bottom: 16px;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2a2a3e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-right: 14px;
  flex-shrink: 0;
}
.nickname { font-size: 16px; font-weight: 600; color: #fff; }
.profile-id { font-size: 12px; color: #666; margin-top: 4px; }

.profile-menu {
  background: #15151f;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid #1e1e2e;
}
.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid #1e1e2e;
  transition: background 0.15s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #1a1a2e; }
.menu-icon { font-size: 18px; margin-right: 12px; }
.menu-text { flex: 1; font-size: 14px; }
.menu-arrow { color: #555; font-size: 18px; }

.profile-actions {
  padding: 0 16px;
}
.btn-login, .btn-logout {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-login {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.btn-login:active { opacity: 0.85; }
.btn-logout {
  background: transparent;
  border: 1px solid #333;
  color: #888;
  margin-top: 10px;
}

/* ========== Tab Bar ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #12121a;
  border-top: 1px solid #1e1e2e;
  display: flex;
  z-index: 100;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s;
}
.tab-icon { font-size: 20px; margin-bottom: 2px; }
.tab-label { font-size: 10px; color: #666; }
.tab-item.active .tab-label { color: #8b9cf7; }

/* ========== Modals ========== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
}
.modal.active { display: flex; }
.modal-content {
  background: #15151f;
  border-radius: 12px;
  margin: auto;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-full {
  width: 100%;
  height: 100%;
  border-radius: 0;
  max-height: 100%;
}
.modal-center {
  width: 88%;
  max-width: 360px;
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-back {
  background: none;
  border: none;
  color: #8b9cf7;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ========== Detail Page ========== */
.detail-hero {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  background: #1a1a2e;
}
.detail-info { padding: 16px; }
.detail-name { font-size: 18px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.detail-price { font-size: 24px; font-weight: 700; color: #ff6b6b; margin-bottom: 12px; }
.detail-price small { font-size: 13px; color: #666; text-decoration: line-through; margin-left: 6px; }
.detail-desc { font-size: 13px; color: #999; line-height: 1.8; }
.detail-features { margin-top: 16px; }
.detail-feature {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #1e1e2e;
  gap: 8px;
}
.detail-feature-icon { font-size: 16px; }
.detail-feature-text { font-size: 13px; color: #ccc; }
.detail-footer {
  padding: 12px 16px;
  background: #12121a;
  border-top: 1px solid #1e1e2e;
  flex-shrink: 0;
}
.btn-buy {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-buy:active { opacity: 0.85; }

/* ========== Form ========== */
.form-group { margin-bottom: 14px; }
.form-input {
  width: 100%;
  padding: 12px 14px;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  color: #e8e8e8;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: #8b9cf7; }
.form-row {
  display: flex;
  gap: 10px;
}
.form-row .form-input { flex: 1; }
.btn-sms {
  padding: 0 16px;
  background: #2a2a3e;
  border: 1px solid #3a3a4e;
  border-radius: 8px;
  color: #8b9cf7;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-sms:disabled { color: #555; cursor: not-allowed; }
.btn-submit {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  cursor: pointer;
  margin-top: 8px;
}
.btn-submit:active { opacity: 0.85; }
.btn-cancel {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  background: transparent;
  color: #666;
  cursor: pointer;
  margin-top: 6px;
}

.login-title {
  font-size: 18px;
  text-align: center;
  margin-bottom: 20px;
  color: #fff;
}

/* ========== Search ========== */
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e8e8e8;
  font-size: 14px;
  outline: none;
}
.search-results .product-card { margin-bottom: 8px; }

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 40px 0;
  display: none;
}
.empty-state.show { display: block; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: #555; }

/* ========== Contact ========== */
.contact-qr {
  text-align: center;
  padding: 20px 0;
}
.qr-placeholder {
  width: 120px;
  height: 120px;
  background: #1a1a2e;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin: 0 auto 12px;
}
.contact-id {
  margin-top: 8px;
  font-size: 14px;
  color: #8b9cf7;
  font-weight: 600;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 3px; }

/* ========== Safe Area ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tab-bar { padding-bottom: env(safe-area-inset-bottom); height: calc(56px + env(safe-area-inset-bottom)); }
  .page { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}
