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

:root {
  --primary: #07C160;
  --primary-dark: #06AD56;
  --primary-light: #E8F8EE;
  --accent: #FF6B6B;
  --accent-light: #FFF0F0;
  --bg: #F7F7F7;
  --card: #FFFFFF;
  --text: #333333;
  --text-light: #888888;
  --text-lighter: #BBBBBB;
  --border: #EEEEEE;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-height: 56px;
}

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

/* ===== 整体布局 ===== */
.app-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ===== 顶部栏 ===== */
.header {
  background: linear-gradient(135deg, var(--primary), #05A34E);
  color: white;
  padding: 16px 20px 14px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
  font-weight: 400;
}

/* ===== 主要内容区域 ===== */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  display: none;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--tab-height);
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* ===== 菜单页面 ===== */
.menu-page {
  display: none;
  height: 100%;
}

.menu-page.active {
  display: flex;
  flex-direction: row;
}

.category-sidebar {
  width: 90px;
  background: var(--bg);
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.category-item {
  padding: 14px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  position: relative;
}

.category-item.active {
  color: var(--primary);
  background: white;
  border-left-color: var(--primary);
  font-weight: 600;
}

.category-item .cat-emoji {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

.menu-items-area {
  flex: 1;
  overflow-y: auto;
  background: white;
  padding: 12px 16px;
}

.menu-items-area .category-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-top: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 14px;
}

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

.menu-item-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

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

.menu-item-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
}

.menu-item-desc {
  font-size: 12px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.menu-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.menu-item-price small {
  font-size: 11px;
  font-weight: 400;
}

.add-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.add-btn:active {
  transform: scale(0.9);
}

/* ===== 购物车页面 ===== */
.cart-page {
  background: var(--bg);
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-lighter);
}

.cart-empty-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

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

.cart-list {
  padding: 12px 16px;
  flex: 1;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.cart-item-emoji {
  font-size: 32px;
  margin-right: 14px;
}

.cart-item-info {
  flex: 1;
}

.cart-item-name {
  font-size: 15px;
  font-weight: 600;
}

.cart-item-price {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 2px;
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-item-actions button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-minus {
  background: var(--border);
  color: var(--text);
}

.cart-plus {
  background: var(--primary);
  color: white;
}

.cart-item-count {
  font-size: 15px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.cart-summary {
  padding: 16px;
  background: white;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-total-label {
  font-size: 14px;
  color: var(--text-light);
}

.cart-total-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.cart-total-price small {
  font-size: 13px;
  font-weight: 400;
}

.checkout-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), #05A34E);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkout-btn:active:not(:disabled) {
  opacity: 0.9;
}

.cart-note-area {
  margin-bottom: 12px;
}

.cart-note-area textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  resize: none;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.cart-note-area textarea:focus {
  border-color: var(--primary);
}

/* ===== 订单页面 ===== */
.orders-page {
  background: var(--bg);
}

.orders-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-lighter);
}

.orders-empty-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.order-card {
  background: white;
  border-radius: var(--radius);
  margin: 10px 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.order-id {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.order-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.order-status.pending {
  background: #FFF3E0;
  color: #F57C00;
}

.order-status.accepted {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.order-status.delivered {
  background: #E3F2FD;
  color: #1565C0;
}

.order-items {
  padding: 10px 16px;
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.order-item-name {
  color: var(--text);
}

.order-item-price {
  color: var(--text-light);
}

.order-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
}

.order-time {
  font-size: 12px;
  color: var(--text-lighter);
}

.order-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.order-total small {
  font-size: 12px;
  font-weight: 400;
}

.order-note {
  padding: 0 16px 10px;
  font-size: 12px;
  color: var(--text-light);
}

.order-note span {
  color: var(--text-lighter);
}

/* ===== 我的页面 ===== */
.profile-page {
  background: var(--bg);
}

.profile-card {
  margin: 20px 16px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #05A34E);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 36px;
  color: white;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 16px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.profile-footer {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-lighter);
  font-size: 12px;
  line-height: 1.8;
}

.profile-footer .heart {
  color: var(--accent);
}

/* ===== 底部导航栏 ===== */
.tab-bar {
  display: flex;
  background: white;
  border-top: 1px solid var(--border);
  height: var(--tab-height);
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
  position: relative;
  z-index: 10;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  color: var(--text-lighter);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

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

.tab-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
}

.tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -22px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 5px;
  font-weight: 600;
}

/* ===== 模态框 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-btn {
  padding: 12px 40px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== 通知横幅 ===== */
.notification-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  animation: slideDown 0.3s ease;
}

.notification-banner.success {
  background: var(--primary);
  color: white;
}

.notification-banner.error {
  background: var(--accent);
  color: white;
}

.notification-banner.show {
  display: block;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* ===== 订单成功页（加在购物车结账后） ===== */
.success-page {
  display: none;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg);
  text-align: center;
}

.success-page.active {
  display: flex;
}

.success-icon {
  font-size: 80px;
  margin-bottom: 16px;
}

.success-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 30px;
}

.success-btn {
  padding: 12px 36px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.78);
  color: white;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}
