/* ============================================
   全局重置 & 基础样式
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    color: #333;
    padding-bottom: 140px;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

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

/* ============================================
   顶部导航
   ============================================ */
.top-header {
    background: linear-gradient(135deg, #ff6b00, #ff8533);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-header .brand {
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
}

.top-header .auth-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.top-header .auth-links a {
    color: white;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.9;
}

.top-header .auth-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.top-header .user-info {
    display: none;
    align-items: center;
    gap: 10px;
}

.top-header .user-info .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
}

.top-header .user-info .nickname {
    font-size: 14px;
}

.top-header .user-info .logout-btn {
    font-size: 12px;
    opacity: 0.7;
    cursor: pointer;
}

.top-header .user-info .logout-btn:hover {
    opacity: 1;
}

/* ============================================
   主体布局（左侧分类 + 右侧内容）
   ============================================ */
.main-layout {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

/* ============================================
   左侧分类导航
   ============================================ */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: white;
    border-radius: 12px;
    padding: 12px 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    height: fit-content;
    position: sticky;
    top: 80px;
}

.sidebar .category-item {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 15px;
    color: #555;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .category-item:hover {
    background: #f8f4f0;
    color: #ff6b00;
}

.sidebar .category-item.active {
    background: #f8f4f0;
    color: #ff6b00;
    border-left-color: #ff6b00;
    font-weight: 600;
}

.sidebar .category-item .icon {
    font-size: 18px;
}

/* ============================================
   右侧内容区
   ============================================ */
.content {
    flex: 1;
    min-width: 0;
}

/* ============================================
   商品卡片网格
   ============================================ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.product-card .product-image {
    width: 100%;
    height: 160px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: #ccc;
    overflow: hidden;
    flex-shrink: 0;
}

.product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card .product-info {
    padding: 16px 18px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card .product-name {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.product-card .product-brand {
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

.product-card .product-performance {
    font-size: 13px;
    color: #888;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .product-desc {
    font-size: 13px;
    color: #888;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.product-card .product-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 8px;
}

.product-card .product-price {
    font-size: 22px;
    font-weight: bold;
    color: #ff6b00;
}

.product-card .product-price .original {
    font-size: 14px;
    color: #bbb;
    text-decoration: line-through;
    font-weight: normal;
    margin-left: 8px;
}

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

.product-card .btn-cart {
    background: #ff6b00;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.product-card .btn-cart:hover {
    background: #e05a00;
}

.product-card .btn-buy {
    background: #ff4d4f;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.product-card .btn-buy:hover {
    background: #d9363e;
}

/* ============================================
   分页
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px 0;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.pagination button:hover {
    border-color: #ff6b00;
    color: #ff6b00;
}

.pagination button.active {
    background: #ff6b00;
    color: white;
    border-color: #ff6b00;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   优惠券专区（首页）
   ============================================ */
.coupon-section {
    background: white;
    border-radius: 12px;
    padding: 24px 28px;
    margin-top: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.coupon-section .section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

.coupon-section .section-title span {
    color: #ff6b00;
}

.coupon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.coupon-card {
    background: linear-gradient(135deg, #fff5ed, #ffe8db);
    border: 1px solid #ffdcc4;
    border-radius: 10px;
    padding: 16px 18px;
    text-align: center;
    transition: transform 0.2s;
}

.coupon-card:hover {
    transform: scale(1.02);
}

.coupon-card .face-value {
    font-size: 28px;
    font-weight: bold;
    color: #ff6b00;
}

.coupon-card .face-value .unit {
    font-size: 16px;
}

.coupon-card .price {
    font-size: 14px;
    color: #888;
    margin-top: 4px;
}

.coupon-card .price span {
    color: #ff4d4f;
    font-weight: 600;
    font-size: 18px;
}

.coupon-card .tag {
    display: inline-block;
    background: #ff6b00;
    color: white;
    font-size: 12px;
    padding: 2px 12px;
    border-radius: 12px;
    margin-top: 8px;
}

/* ============================================
   登录/注册弹窗
   ============================================ */
.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;
    animation: fadeIn 0.25s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 40px 36px 32px;
    width: 400px;
    max-width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal .close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 24px;
    color: #bbb;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
}

.modal .close-btn:hover {
    color: #333;
}

.modal .modal-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: #ff6b00;
    margin-bottom: 24px;
}

.modal .input-group {
    margin-bottom: 18px;
}

.modal .input-group label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
}

.modal .input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}

.modal .input-group input:focus {
    border-color: #ff6b00;
}

.modal .input-group .error-msg {
    color: #ff4d4f;
    font-size: 13px;
    margin-top: 4px;
    display: none;
}

.modal .input-group .error-msg.show {
    display: block;
}

.modal .agreement-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0 20px;
    font-size: 14px;
    color: #666;
}

.modal .agreement-row input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    accent-color: #ff6b00;
    flex-shrink: 0;
    cursor: pointer;
}

.modal .agreement-row .privacy-link {
    color: #ff6b00;
    cursor: pointer;
    font-weight: 500;
}

.modal .agreement-row .privacy-link:hover {
    text-decoration: underline;
}

.modal .btn-submit {
    width: 100%;
    padding: 14px;
    background: #ff6b00;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal .btn-submit:hover {
    background: #e05a00;
}

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

.modal .switch-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #888;
}

.modal .switch-link span {
    color: #ff6b00;
    cursor: pointer;
    font-weight: 500;
}

.modal .switch-link span:hover {
    text-decoration: underline;
}

/* ============================================
   隐私政策弹窗
   ============================================ */
.privacy-modal .modal {
    width: 480px;
}

.privacy-modal .privacy-content {
    padding: 10px 0 4px;
    font-size: 15px;
    line-height: 1.8;
    color: #444;
}

.privacy-modal .privacy-content .highlight {
    color: #ff6b00;
    font-weight: 600;
}

/* ============================================
   底部导航（4项）
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    padding: 6px 0 4px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    border-top: 1px solid #f0f0f0;
    z-index: 999;
}

.bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    cursor: pointer;
    color: #999;
    font-size: 11px;
    padding: 4px 0;
    transition: color 0.2s;
    position: relative;
}

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

.bottom-nav .nav-item .nav-icon {
    font-size: 22px;
    display: block;
}

.bottom-nav .nav-item .nav-text {
    font-size: 11px;
    margin-top: 2px;
}

.bottom-nav .nav-item .badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 18px));
    background: #ff4d4f;
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ============================================
   页脚（公司名 + 备案号）
   ============================================ */
.footer {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    text-align: center;
    padding: 10px 16px;
    font-size: 12px;
    color: #aaa;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    border-top: 1px solid #f0f0f0;
    z-index: 998;
}

.footer .company {
    color: #666;
    font-weight: 500;
}

.footer .icp {
    color: #999;
    margin-left: 12px;
}

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

.loading .spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 4px solid #f0f0f0;
    border-top-color: #ff6b00;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

/* ============================================
   消息提示
   ============================================ */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 15px;
    z-index: 9999;
    max-width: 80%;
    text-align: center;
    animation: fadeIn 0.3s ease;
    pointer-events: none;
}

.toast.success {
    background: rgba(82, 196, 26, 0.9);
}

.toast.error {
    background: rgba(255, 77, 79, 0.9);
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .product-card .product-image {
        height: 120px;
    }

    .product-card .product-info {
        padding: 12px 14px 14px;
    }

    .product-card .product-name {
        font-size: 14px;
    }

    .product-card .product-price {
        font-size: 18px;
    }

    .product-card .btn-cart,
    .product-card .btn-buy {
        font-size: 12px;
        padding: 4px 12px;
    }

    .modal {
        padding: 28px 20px 24px;
    }

    .top-header .brand {
        font-size: 18px;
    }

    .coupon-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr;
    }

    .coupon-grid {
        grid-template-columns: 1fr;
    }

    .footer {
        font-size: 10px;
        padding: 6px 12px;
    }
}
/* ============================================
   优惠券购买按钮
   ============================================ */
.btn-buy-coupon {
    display: inline-block;
    margin-top: 10px;
    background: #ff6b00;
    color: white;
    border: none;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn-buy-coupon:hover {
    background: #e05a00;
}

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

/* 商品卡片图片缩小 */
.product-card .product-image {
    height: 140px !important;
}
.product-card .product-image img {
    object-fit: contain;
    background: #fafafa;
}

@media (max-width: 768px) {
    .product-card .product-image {
        height: 110px !important;
    }
}

@media (max-width: 480px) {
    .product-card .product-image {
        height: 90px !important;
    }
}

/* ============================================
   地址选择弹窗
   ============================================ */
.address-modal .modal {
    width: 480px;
    max-width: 95%;
}
.address-list {
    max-height: 350px;
    overflow-y: auto;
}
.address-item {
    padding: 14px 16px;
    border: 2px solid #f0f0f0;
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.address-item:hover {
    border-color: #ff6b00;
}
.address-item.selected {
    border-color: #ff6b00;
    background: #fff5ed;
}
.address-item .receiver {
    font-weight: 600;
    font-size: 15px;
    color: #333;
}
.address-item .receiver .phone {
    font-weight: normal;
    color: #999;
    font-size: 14px;
    margin-left: 10px;
}
.address-item .detail {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}
.address-item .default-tag {
    display: inline-block;
    background: #ff6b00;
    color: white;
    font-size: 11px;
    padding: 1px 10px;
    border-radius: 10px;
    margin-left: 8px;
}
.address-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.address-actions .btn-primary {
    flex: 1;
    padding: 12px;
    background: #ff6b00;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.address-actions .btn-primary:hover {
    background: #e05a00;
}
.address-actions .btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.address-actions .btn-secondary {
    padding: 12px 24px;
    background: #f0f0f0;
    color: #666;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}
.address-actions .btn-secondary:hover {
    background: #e0e0e0;
}
.no-address {
    text-align: center;
    padding: 30px 0;
    color: #999;
}
.no-address .icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}
.no-address .btn-add {
    display: inline-block;
    margin-top: 12px;
    background: #ff6b00;
    color: white;
    padding: 8px 32px;
    border-radius: 20px;
    cursor: pointer;
    border: none;
    font-size: 14px;
}
