/* ============================================================
   简易商城公共样式
   移动端优先，PC端通过媒体查询扩展
   ============================================================ */

* {
    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;
    line-height: 1.5;
    color: #333;
    background: #f5f5f5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #333;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px;
}

/* 顶部导航 */
.header {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
}

.logo {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
}

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

.nav a {
    font-size: 14px;
    color: #666;
    transition: color 0.2s;
}

.nav a:hover,
.nav a.active {
    color: #e74c3c;
}

.cart-badge {
    position: relative;
}

.cart-badge::after {
    content: attr(data-count);
    position: absolute;
    top: -6px;
    right: -12px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    display: none;
}

.cart-badge.has-items::after {
    display: block;
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: #e74c3c;
    color: #fff;
}

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-default {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
}

.btn-default:hover {
    border-color: #999;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

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

.product-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
}

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

.product-info {
    padding: 10px;
}

.product-name {
    font-size: 14px;
    line-height: 1.4;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price {
    color: #e74c3c;
    font-size: 16px;
    font-weight: bold;
    margin-top: 6px;
}

.product-price::before {
    content: '¥';
    font-size: 12px;
}

.product-sales {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

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

/* Toast 提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 4px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

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

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

.modal {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: bold;
}

.modal-close {
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

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

.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: #e74c3c;
}

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

/* 标签页 */
.tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: #e74c3c;
    border-bottom-color: #e74c3c;
}

/* PC端适配 */
@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .header-inner {
        height: 60px;
    }

    .logo {
        font-size: 22px;
    }

    .nav {
        gap: 24px;
    }

    .nav a {
        font-size: 15px;
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
