/* === 全局配色 & 基础 === */
:root {
    --tb-orange: #ff5000;
    --tb-red: #ff0036;
    --bg-gray: #f4f4f4;
    --tb-grad: linear-gradient(135deg, #ff9000, #ff5000); /* 淘宝橙色渐变 */
}
body { 
    background-color: #f4f4f4; 
    background-color: var(--bg-gray); 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
}
a { text-decoration: none; color: #333; transition: color 0.2s; }
a:hover { color: var(--tb-orange); }

/* === 1. 顶部导航栏 (62px) === */
.tb-header {
    background: #fff;
    height: 62px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Logo / 店名 */
.site-brand {
    font-size: 22px;
    font-weight: bold;
    color: var(--tb-orange);
    margin-right: 40px;
    display: flex; align-items: center;
}
.site-brand i { margin-right: 8px; font-size: 24px; }

/* 中间导航链接 */
.main-nav { 
    display: flex; 
    flex: 1; 
    align-items: center;
}
.nav-link-item { 
    font-size: 14px; 
    font-weight: 500; 
    color: #333; 
    margin-right: 25px;
}
.nav-link-item:last-child { margin-right: 0; }
.nav-link-item:hover { color: var(--tb-orange); }

/* 右侧搜索与登录 */
.header-right { display: flex; align-items: center; }

.tb-search-group {
    display: flex;
    align-items: center;
    border: 2px solid var(--tb-red);
    border-radius: 20px;
    overflow: hidden;
    width: 280px;
    height: 36px;
    background: #fff;
    margin-right: 15px; 
}
.tb-search-input {
    border: none;
    outline: none;
    padding: 0 15px;
    flex: 1;
    font-size: 13px;
    width: 100%;
    background: transparent;
}
.tb-search-btn {
    background: var(--tb-red);
    color: white;
    border: none;
    padding: 0 20px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    border-radius: 18px;
    margin: 2px;
    height: 28px;
}
.tb-search-btn:hover { background: #d6002a; }

.btn-login {
    color: var(--tb-red);
    border: 1px solid var(--tb-red);
    padding: 4px 15px;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
.btn-login:hover { background: #fff0f0; color: var(--tb-red); }

/* === 布局模块通用 === */
.module-box {
    background: #fff;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 15px;
}

/* [修改 2.1] 模块标题 - 移除border，为伪元素做准备 */
.module-title {
    font-size: 16px;
    font-weight: bold;
    /* border-left: 4px solid var(--tb-orange); */ /* 移除 */
    border-left: none; /* 修改 */
    /* padding-left: 10px; */ /* 移除 */
    padding-left: 14px; /* 修改：4px竖条宽度 + 10px间距 */
    margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    position: relative; /* 添加 */
}

/* [修改 2.2] 模块标题 - 添加伪元素竖条 */
.module-title::before {
    border-radius: 12px;
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 1em; /* 关键：高度关联字体大小 (font-size: 16px) */
    background-color: var(--tb-orange);
}

.module-title a { font-size: 12px; font-weight: normal; color: #999; }

/* === 左侧模块 === */
.category-bar { 
    display: flex; 
    flex-wrap: wrap; 
}

.cat-pill {
    display: inline-flex; 
    align-items: center;
    padding: 4px 12px 4px 8px;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    margin-right: 8px; 
    margin-bottom: 8px;
}
.cat-pill.active, .cat-pill:hover {
    background: #fff3eb;
    color: var(--tb-orange);
    border-color: var(--tb-orange);
}
.cat-pill img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-right: 6px;
    object-fit: cover;
}

.taobao-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.tb-card {
    background: #fff;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid #eee;
    overflow: hidden;
    display: flex; 
    flex-direction: column; 
}
.tb-card:hover { border-color: var(--tb-orange); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.tb-img-wrap { width: 100%; padding-bottom: 100%; position: relative; background: #f9f9f9; }
.tb-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }

@media (min-width: 992px) {
    .tb-img {
        width: 80%;
        height: 80%;
        top: 10%;
        left: 10%;
        object-fit: contain; 
    }
    .tb-img-wrap {
        padding-bottom: 80%;
    }
}

.tb-info { 
    padding: 8px; 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
}

/* [修改 3] 商品标题 - 强制换行 */
.tb-title { 
    font-size: 13px; 
    height: 38px; 
    overflow: hidden; 
    margin-bottom: 3px; 
    line-height: 1.4; 
    color: #333; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    word-break: break-all; /* <-- 添加此行 */
}

.tb-price-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end; 
    margin-top: auto; 
    padding-top: 5px; 
    flex-wrap: nowrap;
}
.tb-price { color: var(--tb-orange); font-weight: bold; font-size: 20px; }
.tb-price small { font-size: 13px;margin-right: 1px;}
.tb-sales { font-size: 12px; color: #999;text-align: right; white-space: nowrap; flex-shrink: 0; margin-bottom: 3px; }

.tb-tags-row {
    height: auto;
    min-height: 16px; 
    overflow: hidden;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.dynamic-tag {
    margin-bottom:2px;
    display:inline-block;
    font-size:11px;
    padding:0px 2px;
    border-radius:3px;
    margin-right:3px;
    line-height:normal;
    border:1px solid transparent;
    white-space:nowrap;
}

.hot-article-item {
    display: flex; justify-content: space-between; padding: 8px 0;
    border-bottom: 1px dashed #eee;
}
.hot-article-item:last-child { border-bottom: none; }
.hot-rank {
    display: inline-block; width: 18px; height: 18px;
    background: #ccc; color: #fff; 
    text-align: center; line-height: 18px; border-radius: 4px; font-size: 12px; margin-right: 8px;
}
.hot-rank.top-3 { background: var(--tb-orange); }

/* === 右侧模块 === */
.notice-content { font-size: 13px; line-height: 1.6; color: #666; }
.top-item { 
    display: flex; 
    margin-bottom: 12px; 
    align-items: center; 
}
.top-img { 
    width: 45px; height: 45px;
    border-radius: 4px; object-fit: cover; border: 1px solid #eee; 
    margin-right: 10px; 
}
.top-info { flex: 1; overflow: hidden; }
.top-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.top-price { color: var(--tb-orange); font-weight: bold; font-size: 14px; }

.art-cat-list a { display: block; padding: 6px 0;
    border-bottom: 1px solid #f5f5f5; font-size: 14px; }
.art-cat-list a:hover { padding-left: 5px; color: var(--tb-orange); }
.tag-cloud { 
    display: flex; 
    flex-wrap: wrap; 
}
.tag-cloud-item {
    font-size: 13px;
    padding: 3px 8px;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 15px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 6px;
    margin-bottom: 6px;
}
.tag-cloud-item:hover, .tag-cloud-item.active {
    background: #fff3eb;
    color: var(--tb-orange);
    border-color: var(--tb-orange);
}

/* === 4. Footer === */
.site-footer {
    background: #fff;
    padding: 30px 0 20px;
    text-align: center;
    margin-top: 30px;
}
.footer-links { margin-bottom: 15px; }
.footer-links a { margin: 0 10px; font-size: 14px; color: #666; }
.copyright { color: #999; font-size: 12px; }


/*
========================================
=== 新增：移动端专属样式 (Taobao Style) ===
========================================
*/

/* 移动端头部 */
.mobile-header {
    height: 50px;
    background: #fff;
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.mh-left, .mh-right {
    flex: 0 0 20px;
    text-align: center;
    font-size: 20px;
    color: #333;
    cursor: pointer;
}
.mh-center {
    flex: 1;
    text-align: center;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#mobile-logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}
#mobile-site-name-wrap {
    font-size: 18px;
    font-weight: bold;
    color: var(--tb-orange);
}
#mobile-site-name-wrap i {
    font-size: 20px; margin-right: 6px;
}


/* 移动端下滑搜索框 */
.mobile-search-dropdown {
    position: fixed;
    top: 50px; /* 头部高度 */
    left: 0;
    width: 100%;
    background: #fff;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    transform: translateY(-150%);
    transition: transform 0.3s ease-in-out;
    display: block; 
}
.mobile-search-dropdown.show {
    transform: translateY(0);
}
.mobile-search-dropdown .tb-search-group {
    width: 100%;
    margin: 0;
    height: 40px; 
    align-items: center;
}
.mobile-search-dropdown .tb-search-input {
    height: 100%; 
    flex: 1;
    padding: 0 15px;
}
.mobile-search-dropdown .tb-search-btn {
    height: 33px; 
    margin: 2px;
}

.mobile-search-overlay {
    position: fixed;
    top: 50px;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: none;
}
.mobile-search-overlay.show {
    display: block;
}

/* 移动端侧滑菜单 */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}
.mobile-overlay.show {
    opacity: 1;
    visibility: visible;
}
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px; 
    height: calc(100% - 50px); 
    background: var(--tb-grad); /* 淘宝渐变背景 */
    color: #fff; 
    z-index: 1003;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}
.mobile-sidebar.show {
    transform: translateX(0);
}
.mobile-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.2); 
    text-align: center;
    position: relative; 
}
.mobile-sidebar-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff; 
    margin: 0;
}
.mobile-sidebar-close {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    font-size: 22px;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
}
.mobile-sidebar-close:hover {
    opacity: 1;
}
.mobile-sidebar-content {
    padding: 15px;
    flex: 1; 
    overflow-y: auto; 
}
#mobile-category-list a {
    display: flex; 
    align-items: center; 
    padding: 10px 5px;
    font-size: 14px;
    color: #fff; 
    border-bottom: 1px solid rgba(255,255,255,0.15); 
}
#mobile-category-list a img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    object-fit: cover;
    background: #fff; 
}
#mobile-category-list a:hover {
    color: #fff; 
    background: rgba(255,255,255,0.1); 
}
.mobile-sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.2); 
    background: rgba(0,0,0,0.1); 
}
.mobile-sidebar-login-link {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 16px;
    color: #fff; 
    border: 1px solid rgba(255,255,255,0.5); 
    border-radius: 18px; 
    background: var(--tb-grad); 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.mobile-sidebar-login-link:hover {
    background: linear-gradient(135deg, #ffa020, #ff6a1a);
    color: #fff;
    border-color: #fff;
}
.mobile-sidebar-login-link i {
    margin-right: 5px;
}

/* 移动端吸底导航栏 */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px; 
    background: #fff;
    border-top: 1px solid #eee;
    z-index: 1006; /* 修改：提高 z-index */
    display: flex;
    justify-content: space-around;
    box-shadow: none; /* 修改：移除阴影 */
}
.mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 10px;
    padding: 5px 0;
}
.mbn-item i {
    font-size: 18px; 
    margin-bottom: 2px;
    line-height: 1;
}
.mbn-item.active, .mbn-item:hover {
    color: var(--tb-orange);
}

/* === [新增] 移动端上滑联系方式 === */
.mobile-contact-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 50px); /* 修改：高度不包括底部 50px */
    bottom: 50px; /* 新增：底部在 50px 之上 */
    background: rgba(0,0,0,0.5);
    z-index: 1004; /* 高于 sidebar */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}
.mobile-contact-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mobile-contact-sheet {
    position: fixed;
    bottom: 50px; /* 修改：从 50px 处(即导航栏上方)开始 */
    left: 0;
    width: 100%;
    background: #fff;
    z-index: 1005;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    /*box-shadow: 0 -4px 15px rgba(0,0,0,0.1);*/
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
}
.mobile-contact-sheet.show {
    transform: translateY(0);
}
.mcs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.mcs-title {
    font-size: 16px;
    font-weight: bold;
}
.mcs-close {
    font-size: 20px;
    color: #999;
    cursor: pointer;
}
.mcs-content {
    padding: 15px;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 13px; /* 修改：设置字体大小 */
}

/* 移动端媒体查询总开关 */
@media (max-width: 991.98px) {
    body {
        padding-top: 50px; /* 为 mobile-header 腾出空间 */
        padding-bottom: 50px; /* 为 mobile-bottom-nav 腾出空间 */
    }

    /* 1. 隐藏PC元素 */
    .tb-header {
        display: none !important; 
    }
    .col-lg-3 {
        display: none; 
    }
    .col-lg-9 {
        width: 100%; 
    }
    .main-nav {
        display: none; 
    }
    
    /* 2. 调整布局 */
    .container {
        margin-top: 10px !important;
        padding-left: 10px;
        padding-right: 10px;
    }
    .row {
        --bs-gutter-x: 10px; 
    }
    .module-box {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
    }
    /* [删除] 移除有问题的 first-child 规则 */
    /* .module-box:first-child { padding-top: 0; } */

    .module-title {
        font-size: 15px;
        margin-bottom: 10px;
    }

    /* 3. 调整商品卡片 (改为左图右文列表) */
    
    /* [修改 1.1] 移除商品间距 */
    .taobao-grid {
        grid-template-columns: 1fr; /* 1. 强制单列 */
        gap: 0; /* 修改 */
    }

    /* [修改 1.2] 移除边框和圆角，添加底部浅灰色线条 */
    .tb-card {
        flex-direction: row; /* 2. 卡片改为水平布局 */
        align-items: center;
        min-height: 90px; /* [修改] 改为 min-height 允许内容溢出时撑开 */ /* <-- 修改：从 100px 改为 90px */
        border-radius: 0; /* 修改：移除圆角 */
        border: none; /* 添加：移除所有边框 */
        border-bottom: 1px solid #f0f0f0; /* 添加：浅灰色分割线 */
    }
    
    /* [任务 1] 新增：覆盖PC端的hover效果，防止底线变色和跳动 */
    .tb-card:hover {
        transform: none;
        box-shadow: none;
        border-color: transparent; /* 确保无边框 */
        border-bottom-color: #f0f0f0; /* 保持底线颜色不变 */
    }

    /* [修改 1.3] 移除最后一个商品的分割线 */
    .tb-card:last-child {
        border-bottom: none;
    }

    .tb-img-wrap {
        flex: 0 0 90px; /* 4. 图片容器固定宽度 */ /* <-- 修改：从 100px 改为 90px */
        width: 90px; /* <-- 修改：从 100px 改为 90px */
        height: 90px; /* <-- 修改：从 100px 改为 90px */
        padding-bottom: 0; /* 5. 移除PC端的padding-hack */
        border-radius: 5px;
    }

    .tb-img {
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        object-fit: contain;
        border-radius: 5px;
    }

    .tb-info {
        padding: 8px 0 8px 10px;
        flex: 1; 
        min-width: 0; /* [关键修复] 允许 flex item 缩小 */
    }

    .tb-title {
        font-size: 13px; /* [修改] 减小字号 */
        height: 36px; /* [修改] 减小高度 (2行) */
        -webkit-line-clamp: 2;
        line-height: 1.4;
        margin-bottom: 4px; /* [修改] 减小间距 */
    }
    
    .tb-tags-row {
        margin-bottom: 4px; /* [修改] 减小间距 */
    }
    
    .tb-price-row {
        padding-top: 4px; /* [修改] 减小间距 */
    }

    .tb-price {
        font-size: 16px; /* [修改] 减小字号 */
    }
    .tb-sales {
        font-size: 11px; /* [修改] 减小字号 */
    }


    /* 4. 调整分类药丸 */
    .cat-pill {
        font-size: 12px;
        padding: 4px 10px 4px 6px;
        margin-right: 6px;
        margin-bottom: 6px;
    }
    .cat-pill img {
        width: 16px; height: 16px;
    }

    /* 5. 调整页脚 */
    .site-footer {
        padding: 20px 0 10px;
        margin-top: 10px;
    }
    .footer-links a {
        margin: 0 5px;
        font-size: 12px;
    }
    .copyright {
        font-size: 11px;
    }
}

/* ============================================= */
/* === PC端 新增按钮样式 (加入购物车/立即购买) === */
/* ============================================= */

/* 按钮左半部分：加入购物车 (浅橙色渐变) */
.btn-buy-split-left {
    height: 43px;
    padding: 0 12px 0 16px;
    border-radius: 22px 0 0 22px; /* 左侧圆角 */
    background: linear-gradient(90deg, #ffbf00, #ffa502); /* 浅橙色渐变 */
    color: #fff;
    font-weight: bold;
    border: none;
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.2s;
}

/* 按钮右半部分：立即购买 (深橙色渐变) */
.btn-buy-split-right {
    height: 43px;
    padding: 0 16px 0 12px;
    border-radius: 0 22px 22px 0; /* 右侧圆角 */
    background: linear-gradient(90deg, #ff8400, #ff5000); /* 深橙色渐变 */
    color: #fff;
    font-weight: bold;
    border: none;
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.2s;
}

/* 悬停效果 */
.btn-buy-split-left:hover, .btn-buy-split-right:hover {
    opacity: 0.9;
}
/* ============================================= */
/* === [新增] 返回顶部按钮样式 (PC & Mobile) === */
/* ============================================= */

.back-to-top-btn {
    position: fixed;
    bottom: 120px;       /* PC端默认距离底部 40px */
    right: 40px;        /* PC端默认距离右侧 40px */
    width: 45px;
    height: 45px;
    background-color: rgb(86 84 84 / 44%); /* 半透明黑色背景 */
    color: #f9f9f9;;
    border-radius: 50%; /* 圆形 */
    text-align: center;
    line-height: 45px;
    font-size: 20px;
    cursor: pointer;
    z-index: 9990;      /* 层级需要高，但不要遮挡弹窗(通常是9999以上) */
    opacity: 0;         /* 默认隐藏 */
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* 悬停效果 */
.back-to-top-btn:hover {
    background-color: var(--tb-orange); /* 悬停变成主题橙色 */
    transform: translateY(-3px);
}

/* 显示状态 (由JS控制) */
.back-to-top-btn.show {
    opacity: 1;
    visibility: visible;
}

/* --- 移动端适配 --- */
@media (max-width: 991.98px) {
    .back-to-top-btn {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
        right: 15px;       /* 移动端靠右 15px */
        bottom: 70px;      /* [关键] 避开底部导航栏(50px) + 20px间距 */
        background-color: rgb(86 84 84 / 44%); /* 移动端建议用白色背景 */
        color: #f9f9f9;
        border: 1px solid #eee;
    }
    
    .back-to-top-btn:hover {
        background-color:  #ff570099;
        transform: none;     /*移动端移除位移效果 */
        color: var(--tb-orange);
        /*border-color: var(--tb-orange);*/
    }
}
