/* ========================================
   发卡网前端 - 主样式表
   使用本地资源，避免外部CDN加载问题
======================================== */

:root {
    /* 主题色彩变量 */
    --primary-color: #3C8CE7;
    --primary-gradient: linear-gradient(45deg, #448bff, #44e9ff);
    --primary-gradient-hover: linear-gradient(115deg, #448bff, #44e9ff);
    --accent-color: #00EAFF;

    /* 成功/警告/错误色 */
    --success-color: #5fb878;
    --warning-color: #ffb33e;
    --danger-color: #ff5722;

    /* 文本色 */
    --text-primary: #545454;
    --text-secondary: #737373;
    --text-muted: #999;

    /* 背景色 */
    --bg-page: #f8f8f8;
    --bg-card: #ffffff;
    --bg-input: #f8f8f8;

    /* 边框/阴影 */
    --border-color: #f0f0f0;
    --card-shadow: 0 7px 29px 0 rgba(18, 52, 91, 0.11);
    --input-shadow: 0 4px 10px 0 rgba(135, 142, 154, 0.07);

    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-pill: 100px;
}

/* 重置样式 */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

ul,
li {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

button {
    cursor: pointer;
}

/* ========================================
   头部导航样式
======================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 58px;
    background: var(--bg-card);
    border-bottom: 1px solid #e9ecf3;
    box-shadow: 0 0 0.6rem 0 #d0d0d0;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo img {
    max-width: 150px;
    max-height: 45px;
}

.header-nav {
    display: flex;
    gap: 8px;
}

.header-nav a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s ease;
}

.header-nav a:hover {
    background: var(--bg-input);
}

.header-nav a i {
    font-size: 14px;
}

/* ========================================
   主内容区域
======================================== */
.main {
    margin-top: 78px;
    padding: 0 15px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    overflow-x: hidden;
    /* 防止水平滚动 */
}

/* 卡片容器 */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden;
    /* 防止子元素溢出 */
}

.card-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 15px;
    border-bottom: 1px solid #f7f7f7;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   分类选择
======================================== */
.category-list {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding: 15px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.category-item {
    min-width: 130px;
    height: 67px;
    padding: 12px 20px;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.category-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-item.active {
    background: var(--primary-gradient);
}

.category-item .name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.category-item.active .name {
    color: #fff;
}

.category-item .count {
    font-size: 12px;
    color: var(--text-muted);
}

.category-item.active .count {
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   商品列表
======================================== */
.goods-grid {
    display: grid;
    /* PC端自适应列数，每列最小180px */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 15px 0;
}

.goods-item {
    background: var(--bg-card);
    border: 2px solid #f1f4fb;
    border-radius: var(--radius-lg);
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* 防止内容撑开Grid列宽 */
    overflow: hidden;
    /* 确保内容不溢出 */
}

.goods-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(135, 142, 154, 0.2);
}

.goods-item .goods-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    object-fit: cover;
    margin-bottom: 10px;
    background: #f5f5f5;
}

.goods-item .goods-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    /* 固定2行高度，保持卡片高度一致 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.8em;
    /* 2行 × 1.4行高 = 2.8em */
}

.goods-item .goods-price {
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

.goods-item .goods-price small {
    font-size: 12px;
}

.goods-item .goods-stock {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.goods-item .stock-bar {
    flex: 1;
    height: 5px;
    background: #efefef;
    border-radius: 3px;
    overflow: hidden;
}

.goods-item .stock-bar-fill {
    height: 100%;
    background: linear-gradient(55deg, #65d69e, #31dd92);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.goods-item .stock-text {
    color: #0db26a;
    font-weight: 500;
}

/* 搜索框 */
.search-box {
    display: inline-flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 0 15px;
    height: 34px;
    width: 240px;
    margin-left: 20px;
}

.search-box input {
    flex: 1;
    background: transparent;
    font-size: 12px;
    margin-left: 8px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ========================================
   商品详情页
======================================== */
.goods-detail {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    padding: 20px 0;
}

.goods-detail-image {
    position: relative;
}

.goods-detail-image img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.goods-detail-info {
    padding: 10px 0;
}

.goods-detail-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f7f7f7;
}

.goods-detail-tags {
    display: inline-flex;
    gap: 8px;
    margin-left: 10px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.tag-success {
    background: #dff7ea;
    color: #28C76F;
}

.tag-warning {
    background: #ff5722;
    color: #fff;
}

.tag-info {
    background: #cadbff;
    color: var(--primary-color);
}

.goods-detail-price {
    margin: 20px 0;
}

.goods-detail-price .sign {
    font-size: 18px;
    color: #e4393c;
}

.goods-detail-price .num {
    font-size: 28px;
    font-weight: 700;
    color: #e4393c;
}

/* 表单输入 */
.form-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.form-label {
    width: 80px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.form-input {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--input-shadow);
    color: var(--text-primary);
    max-width: 300px;
}

.form-input:focus {
    border-color: var(--primary-color);
}

/* 数量选择器 */
.quantity-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.quantity-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    font-size: 16px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.quantity-btn:hover {
    background: #e0e0e0;
}

.quantity-input {
    width: 60px;
    height: 36px;
    text-align: center;
    font-size: 14px;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

/* 主按钮 */
.btn-primary {
    display: inline-block;
    padding: 12px 40px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(60, 140, 231, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-block;
    padding: 8px 20px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* ========================================
   订单列表
======================================== */
.order-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: var(--input-shadow);
}

.order-card-header {
    padding: 12px 15px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.order-status {
    font-weight: 600;
}

.order-status.paid {
    color: var(--success-color);
}

.order-status.pending {
    color: var(--warning-color);
}

.order-status.expired {
    color: var(--danger-color);
}

.order-card-body {
    padding: 15px;
}

.order-info-row {
    display: flex;
    margin-bottom: 8px;
    font-size: 14px;
}

.order-info-row .label {
    width: 70px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.order-info-row .value {
    color: var(--text-primary);
    word-break: break-all;
}

.order-card-footer {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 15px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-success {
    background: var(--success-color);
    color: #fff;
}

.btn-danger {
    background: var(--danger-color);
    color: #fff;
}

.btn-info {
    background: var(--primary-color);
    color: #fff;
}

/* ========================================
   Tab 切换
======================================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-item {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-item:hover {
    color: var(--primary-color);
}

.tab-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========================================
   支付页面
======================================== */
.pay-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 0;
}

.pay-method {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.pay-method:hover {
    border-color: var(--primary-color);
}

.pay-method.active {
    border-color: var(--primary-color);
    background: #f8faff;
}

.pay-method img {
    width: 24px;
    height: 24px;
}

.pay-method .name {
    font-size: 14px;
    color: var(--text-primary);
}

/* 支付二维码区域 */
.qrcode-container {
    text-align: center;
    padding: 30px;
}

.qrcode-container img {
    max-width: 250px;
    border-radius: var(--radius-md);
}

.qrcode-tip {
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-secondary);
}

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

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state .title {
    font-size: 16px;
    margin-bottom: 10px;
}

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

/* ========================================
   加载状态
======================================== */
.loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

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

/* ========================================
   页脚
======================================== */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 40px;
}

/* ========================================
   响应式适配 - 移动端优化
   使用弹性布局和相对单位，适配各种屏幕尺寸
======================================== */

/* ---- 平板及小屏PC (768px - 1024px) ---- */
@media (max-width: 1024px) {
    .main {
        padding: 0 12px;
    }

    .goods-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

/* ---- 平板竖屏及大屏手机 (576px - 768px) ---- */
@media (max-width: 768px) {

    /* 主内容区域调整 */
    .main {
        margin-top: 65px;
        padding: 0 10px;
    }

    /* 头部导航优化 - 隐藏文字，保留图标 */
    .header-nav {
        gap: 4px;
    }

    .header-nav a {
        padding: 10px 12px;
        /* 增大触摸区域 */
        min-width: 44px;
        /* 最小触摸目标 44px */
        justify-content: center;
    }

    .header-nav a span {
        display: none;
    }

    .header-nav a svg {
        width: 20px;
        height: 20px;
    }

    /* 搜索框 - 弹性宽度 */
    .search-box {
        width: auto;
        min-width: 120px;
        max-width: 180px;
        flex: 1;
        margin-left: 8px;
        height: 36px;
        padding: 0 12px;
    }

    .search-box input {
        font-size: 13px;
    }

    /* 卡片内边距调整 */
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    .card-header {
        font-size: 13px;
        padding-bottom: 12px;
        margin-bottom: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* 商品网格 - 2列布局（强制覆盖） */
    .goods-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
        padding: 10px 0;
    }

    .goods-item {
        padding: 10px 12px;
    }

    .goods-item .goods-name {
        font-size: 13px;
    }

    .goods-item .goods-price {
        font-size: 15px;
    }

    /* 分类列表 - 横向滚动优化 */
    .category-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* iOS 惯性滚动 */
        scroll-snap-type: x proximity;
        padding: 10px 0 15px;
        margin: 0 -10px;
        padding-left: 10px;
        padding-right: 10px;
        scrollbar-width: none;
        /* Firefox 隐藏滚动条 */
    }

    .category-list::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari 隐藏滚动条 */
    }

    .category-item {
        min-width: 110px;
        height: auto;
        min-height: 60px;
        padding: 10px 16px;
        scroll-snap-align: start;
    }

    .category-item .name {
        font-size: 13px;
    }

    .category-item .count {
        font-size: 11px;
    }

    /* 商品详情页 - 单列布局 */
    .goods-detail {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .goods-detail-name {
        font-size: 18px;
    }

    .goods-detail-price .num {
        font-size: 24px;
    }

    /* 表单布局 - 堆叠模式 */
    .form-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .form-label {
        width: auto;
    }

    .form-input {
        width: 100%;
        max-width: none;
        height: 44px;
        /* 增大触摸区域 */
        font-size: 16px;
        /* 防止iOS自动缩放 */
    }

    /* 数量选择器放大 */
    .quantity-selector {
        transform-origin: left center;
    }

    .quantity-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .quantity-input {
        width: 60px;
        height: 40px;
        font-size: 16px;
    }

    /* 按钮调整 */
    .btn-primary {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    /* 订单卡片 */
    .order-info-row {
        flex-direction: column;
        gap: 4px;
    }

    .order-info-row .label {
        width: auto;
    }

    /* 支付方式 */
    .pay-methods {
        flex-direction: column;
    }

    .pay-method {
        width: 100%;
    }
}

/* ---- 小屏手机 (320px - 576px) ---- */
@media (max-width: 576px) {
    html {
        font-size: 13px;
    }

    .main {
        margin-top: 60px;
        padding: 0 8px;
    }

    .header {
        height: 54px;
    }

    .header-inner {
        padding: 0 10px;
    }

    .header-logo img {
        max-width: 120px;
        max-height: 38px;
    }

    /* 搜索框进一步缩小 */
    .search-box {
        min-width: 100px;
        max-width: 140px;
        height: 32px;
        padding: 0 10px;
    }

    .card {
        padding: 12px;
        border-radius: 8px;
    }

    .card-header {
        font-size: 12px;
    }

    /* 小屏手机商品网格保持双列 */
    .goods-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    .goods-item {
        padding: 8px 10px;
        border-radius: 8px;
    }

    .goods-item .goods-cover {
        border-radius: 6px;
    }

    .goods-item .goods-name {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .goods-item .goods-price {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .goods-item .goods-stock {
        font-size: 11px;
    }

    /* 分类项更紧凑 */
    .category-item {
        min-width: 95px;
        min-height: 55px;
        padding: 8px 12px;
    }

    /* 商品详情 */
    .goods-detail-name {
        font-size: 16px;
        padding-bottom: 10px;
    }

    .goods-detail-price .sign {
        font-size: 14px;
    }

    .goods-detail-price .num {
        font-size: 22px;
    }

    .goods-detail-tags .tag {
        font-size: 10px;
        padding: 2px 6px;
    }

    /* 手动发货提示 */
    .manual-ship-notice {
        padding: 10px 12px;
        font-size: 12px;
    }

    /* 页脚 */
    .footer {
        padding: 20px 10px;
        font-size: 11px;
    }

    /* 空状态 */
    .empty-state {
        padding: 40px 15px;
    }

    .empty-state svg {
        width: 60px;
        height: 60px;
    }

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

    .empty-state .desc {
        font-size: 12px;
    }
}

/* ---- 超小屏手机 (<320px) ---- */
@media (max-width: 320px) {
    html {
        font-size: 12px;
    }

    .header-nav a {
        padding: 8px;
        min-width: 40px;
    }

    .search-box {
        display: none;
        /* 超小屏隐藏搜索框 */
    }

    .category-item {
        min-width: 85px;
    }

    .goods-grid {
        grid-template-columns: 1fr !important;
        /* 强制单列 */
    }
}

/* ========================================
   通知公告
======================================== */
.notice-bar {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.8;
}

/* ========================================
   消息提示
======================================== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* ========================================
   手动发货提示
======================================== */
.manual-ship-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 1px solid #ffb74d;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    font-size: 13px;
    color: #e65100;
}

.manual-ship-notice svg {
    flex-shrink: 0;
    color: #ff9800;
}