/* ============ CSS 变量 & 全局样式 ============ */
:root {
    --primary: #FF4757;
    --primary-dark: #E63946;
    --primary-light: #FF6B81;
    --secondary: #FF6B35;
    --accent: #FFD166;
    --bg: #F5F5F5;
    --bg-white: #FFFFFF;
    --text: #1A1A2E;
    --text-secondary: #6C6C80;
    --text-light: #999;
    --border: #F0F0F0;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --nav-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
}

.page-content {
    padding-bottom: 10px;
}

/* ============ 底部导航 ============ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    z-index: 100;
    border-top: 1px solid var(--border);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.nav-item .nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.nav-item .nav-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.nav-item.active .nav-icon {
    color: var(--primary);
    transform: scale(1.1);
}

.nav-item:active {
    transform: scale(0.95);
}

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

/* 顶部搜索栏 */
.top-bar {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    color: white;
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 8px 16px;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    color: white;
    font-size: 14px;
    outline: none;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-icon {
    font-size: 18px;
}

/* 轮播图 */
.banner-swiper {
    margin: 12px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    height: 160px;
    box-shadow: var(--shadow);
}

.banner-swiper .swiper-wrapper {
    display: flex;
    transition: transform 0.4s ease;
    height: 100%;
}

.banner-swiper .swiper-slide {
    min-width: 100%;
    height: 100%;
}

.banner-swiper .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.banner-dot {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.5);
    transition: all 0.3s;
}

.banner-dot.active {
    width: 18px;
    background: white;
}

/* 分类导航 */
.category-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--bg-white);
    margin: 0 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.category-item:active {
    background: var(--bg);
    transform: scale(0.95);
}

.category-icon {
    font-size: 13px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.category-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 区块标题 */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.section-title .more {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 400;
}

.section-title .title-deco {
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
    margin-right: 8px;
}

/* 商品卡片 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 12px;
}

.product-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-hover);
}

.product-card .product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #F8F8F8;
}

.product-card .product-info {
    padding: 10px;
}

.product-card .product-name {
    font-size: 13px;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    margin-bottom: 8px;
}

.product-card .product-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.product-card .price-current {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.product-card .price-current::before {
    content: '¥';
    font-size: 13px;
}

.product-card .price-original {
    font-size: 11px;
    color: var(--text-light);
    text-decoration: line-through;
}

.product-card .product-sales {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

.product-card .buy-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255,71,87,0.4);
}

.product-card .product-img-wrap {
    position: relative;
}

.product-card .product-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

/* 分类标签 */
.category-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 7px 16px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all 0.2s;
    flex-shrink: 0;
}

.category-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

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

.order-no {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.status-pending { background: #FFF3E0; color: #E65100; }
.status-paid { background: #E3F2FD; color: #1565C0; }
.status-shipped { background: #E8F5E9; color: #2E7D32; }
.status-completed { background: #F3E5F5; color: #6A1B9A; }

.order-body {
    display: flex;
    gap: 10px;
}

.order-product-img {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.order-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-product-name {
    font-size: 14px;
    font-weight: 500;
}

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

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

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

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

.order-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

.btn-sm.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 我的页面 */
.user-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 30px 20px 25px;
    color: white;
    text-align: center;
}

.user-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255,255,255,0.5);
}

.user-name {
    font-size: 18px;
    font-weight: 600;
}

.user-phone {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 4px;
}

/* 订单任务图标区 */
.task-icons {
    display: flex;
    justify-content: space-around;
    background: var(--bg-white);
    margin: -10px 12px 10px;
    border-radius: var(--radius);
    padding: 16px 8px;
    box-shadow: var(--shadow);
    position: relative;
}

.task-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.task-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: inherit;
    position: relative;
}

.task-icon-badge .badge-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-icon-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 菜单列表 */
.menu-list {
    background: var(--bg-white);
    margin: 10px 12px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
}

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

.menu-item:active {
    background: var(--bg);
}

.menu-item-icon {
    font-size: 20px;
}

.menu-item-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.menu-item-arrow {
    color: var(--text-light);
    font-size: 14px;
}

/* 公司信息 */
.company-footer {
    padding: 20px 16px 10px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.8;
}

.company-footer .company-name {
    font-weight: 600;
    color: var(--text-secondary);
}

.company-footer .divider {
    margin: 0 6px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .empty-icon {
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.empty-state .empty-text {
    font-size: 15px;
    margin-bottom: 16px;
}

.empty-state .btn-primary {
    display: inline-block;
    padding: 10px 30px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 9999;
    pointer-events: none;
}

/* 返回顶部 */
.back-top {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-white);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 50;
}
