/* =============================================
   在线商城 - 全局样式（响应式/H5自适应）
   ============================================= */

* {
    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;
    font-size: 14px;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #e4393c;
    text-decoration: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

a:hover {
    text-decoration: underline;
}

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

/* 移动端容器 */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }
}

/* =============================================
   顶部导航（响应式）
   ============================================= */
.site-header {
    background: #e4393c;
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 15px;
}

.logo a {
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
}

/* 网址显示区域（支付宝审核要求） */
.site-url-display {
    flex: 1;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.url-label {
    font-weight: 500;
}

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

.nav-link, .nav-user {
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
}

.nav-link:hover {
    text-decoration: underline;
}

.cart-link {
    position: relative;
    padding: 5px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff5722;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* 移动端导航优化 */
@media (max-width: 768px) {
    .header-inner {
        padding: 0 12px;
        height: 50px;
        gap: 8px;
    }
    
    .logo a {
        font-size: 16px;
    }
    
    .site-url-display {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .nav-links {
        gap: 8px;
    }
    
    .nav-link, .nav-user {
        font-size: 12px;
    }
    
    .nav-user {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* =============================================
   主内容区域
   ============================================= */
.main-content {
    flex: 1;
    padding: 20px 0;
}

@media (max-width: 768px) {
    .main-content {
        padding: 12px 0;
    }
}

/* =============================================
   商品网格（响应式）
   ============================================= */
.category-nav {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.category-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-item {
    padding: 6px 15px;
    background: #f5f5f5;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.category-item:hover, .category-item.active {
    background: #e4393c;
    color: #fff;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* 平板 */
@media (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
}

/* 手机 */
@media (max-width: 768px) {
    .category-nav {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .category-list {
        gap: 6px;
    }
    
    .category-item {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* =============================================
   商品卡片（响应式）
   ============================================= */
.product-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f8f8f8;
}

.product-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.product-spec {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
}

.product-price {
    font-size: 20px;
    font-weight: bold;
    color: #e4393c;
    margin-bottom: 10px;
}

.product-price small {
    font-size: 14px;
}

.btn-add-cart {
    width: 100%;
    padding: 8px;
    background: #e4393c;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-add-cart:hover {
    background: #c62828;
}

/* 移动端商品卡片优化 */
@media (max-width: 768px) {
    .product-info {
        padding: 8px;
    }
    
    .product-name {
        font-size: 13px;
        margin-bottom: 6px;
        min-height: 36px;
    }
    
    .product-spec {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .product-price {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .product-price small {
        font-size: 12px;
    }
    
    .btn-add-cart {
        padding: 6px;
        font-size: 12px;
    }
}

/* =============================================
   表单样式（响应式）
   ============================================= */
.form-container {
    max-width: 450px;
    margin: 40px auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.form-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: #e4393c;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-checkbox {
    margin-right: 6px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #e4393c;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #c62828;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.alert {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

/* 移动端表单优化 */
@media (max-width: 768px) {
    .form-container {
        margin: 20px auto;
        padding: 20px 15px;
    }
    
    .form-title {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-input, .form-select, .form-textarea {
        padding: 10px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}

/* =============================================
   购物车/订单页面（响应式）
   ============================================= */
.cart-container, .checkout-container {
    max-width: 1000px;
    margin: 0 auto;
}

.cart-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.cart-table table {
    width: 100%;
    border-collapse: collapse;
}

.cart-table th {
    background: #f5f5f5;
    padding: 12px;
    text-align: left;
    font-weight: 500;
    border-bottom: 1px solid #e0e0e0;
}

.cart-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
}

.quantity-input {
    width: 50px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
}

/* 移动端购物车优化 */
@media (max-width: 768px) {
    .cart-table {
        overflow-x: auto;
    }
    
    .cart-table table {
        min-width: 600px;
    }
    
    .cart-table th, .cart-table td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .cart-item-image {
        width: 60px;
        height: 60px;
    }
    
    .quantity-btn {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
    
    .quantity-input {
        width: 40px;
        font-size: 13px;
    }
}

/* =============================================
   结算页面（响应式）
   ============================================= */
.checkout-steps {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #fff;
    margin-bottom: 20px;
    border-radius: 8px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #999;
}

.step-item.active {
    color: #e4393c;
    font-weight: 500;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.step-item.active .step-number {
    background: #e4393c;
}

.order-summary {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.summary-row:last-child {
    border-bottom: none;
    font-size: 18px;
    font-weight: bold;
    color: #e4393c;
}

/* 移动端结算页优化 */
@media (max-width: 768px) {
    .checkout-steps {
        padding: 12px;
        margin-bottom: 12px;
        overflow-x: auto;
    }
    
    .step-item {
        font-size: 12px;
        gap: 6px;
        white-space: nowrap;
    }
    
    .step-number {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .order-summary {
        padding: 15px;
        margin-bottom: 12px;
    }
    
    .summary-row {
        padding: 8px 0;
        font-size: 13px;
    }
    
    .summary-row:last-child {
        font-size: 16px;
    }
}

/* =============================================
   地址管理（响应式）
   ============================================= */
.address-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.address-card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.address-card:hover {
    border-color: #e4393c;
}

.address-card.selected {
    border-color: #e4393c;
    background: #fff5f5;
}

.default-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff9800;
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
}

/* 移动端地址管理优化 */
@media (max-width: 768px) {
    .address-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .address-card {
        padding: 12px;
    }
}

/* =============================================
   底部
   ============================================= */
.site-footer {
    background: #333;
    color: #999;
    text-align: center;
    padding: 20px;
    margin-top: auto;
}

@media (max-width: 768px) {
    .site-footer {
        padding: 15px;
        font-size: 12px;
    }
}

/* =============================================
   工具类
   ============================================= */
.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

/* 移动端隐藏 */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* PC端隐藏 */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}
