/* 移动端优先的响应式设计 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    padding-bottom: 60px; /* 为底部导航留空间 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px;
}

/* 头部导航 - 移动端优化 */
header {
    background: white;
    padding: 12px 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 18px;
    font-weight: bold;
    color: #3498db;
    display: inline-block;
    white-space: nowrap;
}

/* 移动端菜单按钮 */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    float: right;
    margin-top: 5px;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: #333;
    border-radius: 2px;
    transition: all 0.3s;
}

nav {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    text-decoration: none;
    color: #333;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background 0.3s;
    font-size: 14px;
    white-space: nowrap;
}

nav a:active {
    background: #f0f0f0;
}

#user-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

#username-display {
    font-size: 13px;
    color: #666;
}

.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    min-height: 44px; /* 移动端触摸目标最小尺寸 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    background: #2980b9;
    transform: scale(0.98);
}

/* 横幅 */
.banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.banner h1 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.banner p {
    font-size: 14px;
    opacity: 0.9;
}

/* 分类卡片 */
.categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.category-card {
    background: white;
    padding: 20px 15px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
}

.category-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.category-card h3 {
    color: #333;
    font-size: 16px;
    font-weight: 500;
    margin-top: 8px;
}

.category-icon {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

/* 广告轮播 */
.advertisements-slider {
    margin: 20px 0;
    padding: 0 10px;
}

.advertisement-item {
    margin-bottom: 12px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    background: white;
}

.advertisement-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 200px; /* 限制最大高度 */
    border-radius: 10px;
    /* 确保图片在移动端正确显示 */
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none; /* 防止图片被选中或拖拽 */
}

/* 移动端广告优化 */
@media (max-width: 768px) {
    .advertisement-item {
        margin-bottom: 10px;
    }
    
    .advertisement-item img {
        max-height: 150px;
        width: 100%;
        height: auto;
    }
}

/* 商品网格 - 移动端单列，平板双列，桌面多列 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.product-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    touch-action: manipulation;
}

.product-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #f0f0f0;
    display: block;
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 40px;
}

.product-price {
    font-size: 18px;
    color: #e74c3c;
    font-weight: bold;
    margin-bottom: 5px;
}

.product-original-price {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    margin-left: 8px;
}

.product-actions {
    margin-top: 10px;
}

.product-actions .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-bar select {
    flex: 1;
    min-width: 120px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

/* 购物车 */
.cart-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.cart-item-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

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

.cart-item-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 5px;
}

.cart-item-price {
    font-size: 14px;
    color: #666;
}

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

.cart-item-actions button {
    min-width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    touch-action: manipulation;
}

.cart-item-actions button:active {
    background: #f0f0f0;
}

.cart-item-quantity {
    min-width: 40px;
    text-align: center;
    font-size: 16px;
}

.cart-item-actions .btn-delete {
    background: #e74c3c;
    color: white;
    border: none;
    font-size: 12px;
    padding: 8px 12px;
}

.cart-summary {
    background: white;
    padding: 20px;
    margin-top: 15px;
    border-radius: 8px;
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.cart-summary-total {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
}

.cart-summary-total span {
    color: #e74c3c;
    font-size: 24px;
}

#coupon-selector {
    margin-bottom: 15px;
}

#coupon-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

#coupon-selector select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-height: 44px;
}

.cart-summary .btn-primary {
    width: 100%;
    font-size: 16px;
    padding: 14px;
}

/* 模态框 - 移动端优化 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background: white;
    margin: 20px auto;
    padding: 25px 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.close:active {
    color: #000;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.modal-content .btn-primary {
    width: 100%;
    margin-top: 10px;
}

/* 订单 */
.order-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

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

.order-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

.status-pending { background: #f39c12; color: white; }
.status-paid { background: #3498db; color: white; }
.status-completed { background: #2ecc71; color: white; }
.status-cancelled { background: #e74c3c; color: white; }

.order-info {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
}

.order-info p {
    margin-bottom: 5px;
}

/* 标题 */
h2 {
    font-size: 18px;
    margin: 20px 0 15px;
    color: #333;
    font-weight: 600;
}

/* 底部导航栏（移动端） */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 99;
    padding: 8px 0;
}

.bottom-nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 5px;
    text-decoration: none;
    color: #666;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    touch-action: manipulation;
}

.bottom-nav-item:active {
    color: #3498db;
}

.bottom-nav-item.active {
    color: #3498db;
}

/* 响应式设计 - 平板和桌面 */
@media (min-width: 768px) {
    .container {
        padding: 0 20px;
    }
    
    header {
        padding: 20px;
    }
    
    .logo {
        font-size: 24px;
    }
    
    .menu-toggle {
        display: none !important;
    }
    
    nav {
        display: flex !important;
    }
    
    .banner {
        padding: 60px 40px;
    }
    
    .banner h1 {
        font-size: 36px;
    }
    
    .banner p {
        font-size: 16px;
    }
    
    .categories {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .category-card {
        padding: 30px;
    }
    
    .category-card h3 {
        font-size: 20px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .product-image {
        height: 200px;
    }
    
    .product-name {
        font-size: 16px;
    }
    
    .product-price {
        font-size: 20px;
    }
    
    .cart-item {
        padding: 20px;
    }
    
    .cart-item-content {
        flex-direction: row;
    }
    
    .cart-item-actions {
        flex-direction: row;
        margin-top: 0;
    }
    
    .cart-summary {
        position: static;
    }
    
    .cart-summary-total {
        text-align: right;
    }
    
    .modal-content {
        margin: 50px auto;
        padding: 30px;
    }
    
    body {
        padding-bottom: 0;
    }
    
    .bottom-nav {
        display: none !important;
    }
}

/* 响应式设计 - 大屏手机 */
@media (min-width: 480px) and (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* 移动端菜单样式 */
@media (max-width: 767px) {
    .menu-toggle {
        display: flex;
    }
    
    nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 15px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        gap: 0;
    }
    
    nav.active {
        display: flex;
    }
    
    nav a {
        width: 100%;
        padding: 12px;
        border-bottom: 1px solid #eee;
    }
    
    #user-info {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #eee;
    }
    
    #user-info button {
        width: 100%;
    }
    
    .bottom-nav {
        display: flex;
    }
}

/* 微信浏览器优化 */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-font-smoothing: antialiased;
    }
    
    input, select, textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

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

/* 收货地址列表样式 */
.address-item {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.address-info {
    flex: 1;
}

.address-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.default-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.address-text {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.address-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-text {
    background: none;
    border: none;
    color: #667eea;
    font-size: 14px;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

.btn-text:hover {
    color: #764ba2;
    text-decoration: underline;
}

.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 14px;
}
