/* 
 * 17haodanku Styles 
 * Minimalism & Modern UI
 */

.hdk-related-wrap {
    margin: 40px 0 !important;
    padding: 24px !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    box-sizing: border-box !important;
}

.hdk-related-wrap * {
    box-sizing: border-box;
}

.hdk-related-title {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 12px !important;
    margin-top: 0 !important;
    padding: 0 !important;
    min-height: 25px !important;
}

.hdk-related-title h3,
.hdk-related-title .hdk-related-heading {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #1f2937 !important;
    border: none !important;
    padding: 0 !important;
    line-height: 1.5 !important;
}

.hdk-keyword-badge {
    font-size: 12px !important;
    color: #6b7280 !important;
    background: #f3f4f6 !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
}

.hdk-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--hdk-card-size, 160px), 1fr));
    gap: 16px !important;
}

.hdk-item-card {
    background: #fff;
    border-radius: 12px;
    overflow: visible;
    /* 改为 visible，防止二维码 Popover 被截断 */
    border: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.hdk-item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    border-color: #ffe4e6;
}

.hdk-item-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    background: #f9fafb;
}

.hdk-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.hdk-item-card:hover .hdk-item-img img {
    transform: scale(1.05);
}

.hdk-item-info {
    padding: 12px !important;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.hdk-item-title {
    margin: 0 0 10px 0 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #374151 !important;
    font-weight: 500 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 39px !important;
}

.hdk-item-prices {
    display: flex;
    align-items: baseline;
    margin-bottom: 12px;
}

.hdk-price-current {
    color: #ef4444 !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    margin-right: 8px !important;
    line-height: 1 !important;
}

.hdk-price-current small {
    font-size: 14px !important;
    font-weight: 500 !important;
}

.hdk-price-old {
    color: #9ca3af;
    font-size: 12px;
    text-decoration: line-through;
}

/* 交互元素基础样式 */
.hdk-action-btn {
    cursor: pointer;
}

/* 购买按钮 */
.hdk-btn-wrap {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px !important;
}

.hdk-buy-btn {
    flex-grow: 1;
    display: block;
    width: 100%;
    text-align: center;
    background: #ef4444;
    /* 默认淘宝红 */
    color: #ffffff !important;
    padding: 10px 0 !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    transition: background 0.3s ease;
}

.hdk-buy-btn:hover {
    background: #dc2626;
}

/* 平台专属按钮颜色 */
.hdk-badge-taobao-btn {
    background: #ff5000;
}

.hdk-badge-taobao-btn:hover {
    background: #e04600;
}

.hdk-badge-jd-btn {
    background: #e1251b;
}

.hdk-badge-jd-btn:hover {
    background: #c81d14;
}

.hdk-badge-pdd-btn {
    background: #e02e24;
}

.hdk-badge-pdd-btn:hover {
    background: #c6251b;
}

/* 平台角标 */
.hdk-platform-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hdk-badge-taobao {
    background: linear-gradient(90deg, #ff9000 0%, #ff5000 100%);
}

.hdk-badge-jd {
    background: #e1251b;
}

.hdk-badge-pdd {
    background: #e02e24;
}

/* 二维码悬浮 */
.hdk-qrcode-hover-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f3f4f6;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.hdk-qrcode-hover-wrap:hover {
    background: #e5e7eb;
    color: #374151;
}

.hdk-qrcode-popover {
    position: absolute;
    bottom: 100%;
    right: -10px;
    margin-bottom: 10px;
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
    width: 158px;
    box-sizing: border-box;
}

.hdk-qrcode-popover::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border-width: 6px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

.hdk-qrcode-hover-wrap:hover .hdk-qrcode-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hdk-qrcode-popover img {
    width: 140px !important;
    height: 140px !important;
    max-width: 140px !important;
    max-height: 140px !important;
    min-width: 140px !important;
    min-height: 140px !important;
    display: block !important;
    margin-bottom: 6px;
    background: #fff;
    object-fit: contain !important;
}

.hdk-qrcode-popover span {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
}

/* 骨架屏动画 */
@keyframes hdk-shimmer {
    0% {
        background-position: -468px 0;
    }

    100% {
        background-position: 468px 0;
    }
}

.hdk-skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 104px;
    animation-duration: 1s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;
    animation-name: hdk-shimmer;
    animation-timing-function: linear;
    border-radius: 4px;
}

.hdk-skeleton-badge {
    width: 80px;
    height: 20px;
    border-radius: 10px;
}

.hdk-skeleton-text {
    width: 100%;
    height: 14px;
    margin-bottom: 8px;
}

.hdk-skeleton-text-short {
    width: 60%;
}

.hdk-skeleton-btn {
    width: 100%;
    height: 36px;
    border-radius: 8px;
    margin-top: auto;
}

/* 移动端横向滑动布局 (仅限移动端生效) */
@media (max-width: 768px) {
    .hdk-layout-scroll {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 16px;
        margin: 0 -8px;
    }

    .hdk-layout-scroll::-webkit-scrollbar {
        height: 4px;
    }

    .hdk-layout-scroll::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .hdk-layout-scroll::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

    .hdk-layout-scroll .hdk-item-card {
        flex: 0 0 calc(45% - 16px);
        min-width: 140px;
        margin: 0 8px;
        scroll-snap-align: start;
    }
}

/* 底部固定悬浮条 (玻璃拟态特效 - 初始为隐藏态) */
.hdk-sticky-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    display: flex;
    justify-content: center;
    /* 默认隐藏在屏幕下方 */
    opacity: 0;
    transform: translateY(120%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s linear;
    pointer-events: none;
    /* 隐藏时不阻挡页面底部元素的操作 */
}

/* 激活状态：平滑滑入并淡入 */
.hdk-sticky-bar.hdk-sticky-active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.hdk-sticky-inner {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 800px;
    background: #fff;
    border-radius: 40px;
    padding: 6px 42px 6px 12px;
    /* 右侧留出空间给关闭按钮 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    /* 用于关闭按钮的绝对定位 */
}

.hdk-sticky-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
}

.hdk-sticky-info {
    flex-grow: 1;
    overflow: hidden;
}

.hdk-sticky-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.hdk-sticky-price {
    display: flex;
    align-items: center;
}

.hdk-sticky-price .hdk-current {
    color: #ef4444;
    font-weight: bold;
    font-size: 14px;
    margin-right: 6px;
}

.hdk-sticky-price .hdk-tag {
    background: #fee2e2;
    color: #ef4444;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
}

.hdk-sticky-btn {
    background: #ef4444;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    margin-right: 8px;
    /* 留出间距 */
}

/* 关闭按钮样式 */
.hdk-sticky-close {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.hdk-sticky-close:hover {
    background: #f3f4f6;
    color: #4b5563;
    transform: translateY(-50%) scale(1.1);
}

/* 响应式 */
@media (max-width: 768px) {
    .hdk-related-wrap {
        padding: 16px;
        border-radius: 12px;
    }

    .hdk-items-grid:not(.hdk-layout-scroll) {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .hdk-item-title {
        font-size: 13px;
        height: 36px;
    }

    .hdk-price-current {
        font-size: 16px;
    }

    .hdk-qrcode-hover-wrap {
        display: none;
        /* 移动端默认隐藏二维码以省空间 */
    }
}

/* ==========================================
   5. 小工具样式优化（扁平化与自适应横向滑动）
   ========================================== */

/* 消除卡片嵌套：去除小工具内部的白底、圆角与阴影，使完美融合主题侧边栏 */
.hdk-widget-container .hdk-related-wrap {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

/* 避免双重标题：隐藏小工具内嵌的“猜你喜欢”和“相关搜索”标题 */
.hdk-widget-container .hdk-related-title {
    display: none !important;
}

/* 默认小工具网格布局（针对侧边栏进行紧凑微调） */
.hdk-widget-container .hdk-items-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 12px !important;
}

.hdk-widget-container .hdk-item-card {
    padding: 10px !important;
    border: 1px solid #f3f4f6 !important;
}

/* 当开启小工具“横向滑动切换”选项时的幻灯片轮播样式 */
.hdk-widget-container.hdk-widget-force-scroll {
    position: relative !important;
    overflow: hidden !important;
}

/* 幻灯片滚动网格容器：横向不折行、平滑滚动、手势吸附、隐藏滚动条 */
.hdk-widget-force-scroll .hdk-items-grid,
.hdk-widget-force-scroll .hdk-items-list {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    -ms-overflow-style: none !important;
    /* 隐藏 IE/Edge 滚动条 */
    scrollbar-width: none !important;
    /* 隐藏 Firefox 滚动条 */
}

/* 隐藏 Chrome/Safari/Opera 滚动条 */
.hdk-widget-force-scroll .hdk-items-grid::-webkit-scrollbar,
.hdk-widget-force-scroll .hdk-items-list::-webkit-scrollbar {
    display: none !important;
}

/* 幻灯片模式下的单张卡片：宽度 100% 占满，对齐 */
.hdk-widget-force-scroll .hdk-item-card {
    flex: 0 0 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    scroll-snap-align: start !important;
    margin: 0 !important;
    border: none !important;
    padding: 8px 12px 12px 12px !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03) !important;
}

/* 左右切换箭头统一样式 */
.hdk-widget-force-scroll .hdk-slider-arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 32px !important;
    height: 32px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    z-index: 20 !important;
    font-size: 16px !important;
    font-family: monospace !important;
    font-weight: bold !important;
    color: #4b5563 !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* 隐藏时无法交互，防止误触 */
    user-select: none !important;
}

/* 鼠标悬停在小工具上时，渐显箭头 */
.hdk-widget-force-scroll:hover .hdk-slider-arrow {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 箭头悬停态 */
.hdk-widget-force-scroll .hdk-slider-arrow:hover {
    background: #ff5722 !important;
    color: #ffffff !important;
    border-color: #ff5722 !important;
    box-shadow: 0 4px 16px rgba(255, 87, 34, 0.3) !important;
    transform: translateY(-50%) scale(1.1) !important;
}

/* 箭头点击时的微小缩放反馈 */
.hdk-widget-force-scroll .hdk-slider-arrow:active {
    transform: translateY(-50%) scale(0.95) !important;
}

.hdk-widget-force-scroll .hdk-prev-arrow {
    left: 6px !important;
}

.hdk-widget-force-scroll .hdk-next-arrow {
    right: 6px !important;
}

/* 针对幻灯片模式微调按钮的间距 */
.hdk-widget-force-scroll .hdk-btn-wrap {
    margin-top: 12px !important;
}

/* 右上角深色玻璃拟态数字指示器 */
.hdk-widget-force-scroll .hdk-slider-counter {
    position: absolute !important;
    top: 14px !important;
    right: 18px !important;
    background: rgba(0, 0, 0, 0.35) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-weight: 600 !important;
    padding: 3px 8px !important;
    border-radius: 12px !important;
    z-index: 15 !important;
    pointer-events: none !important;
    /* 禁止交互以防阻碍图片点击 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    line-height: 1.2 !important;
}

/* ==========================================
   6. 横向商品列表卡片模版 (.hdk-template-horizontal)
   ========================================== */

/* 容器布局 */
.hdk-items-list.hdk-template-horizontal {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

/* 商品卡片：左图右文横向排布 */
.hdk-template-horizontal .hdk-item-card {
    flex-direction: row !important;
    align-items: stretch !important;
    padding: 10px !important;
    background: #ffffff;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    gap: 14px;
    width: 100%;
    min-height: 120px;
}

.hdk-template-horizontal .hdk-item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    border-color: #ffe4e6;
}

/* 商品主图 */
.hdk-template-horizontal .hdk-item-img {
    flex: 0 0 100px !important;
    width: 100px !important;
    height: 100px !important;
    border-radius: 8px;
    overflow: hidden;
    margin: auto 0;
}

@media (max-width: 480px) {
    .hdk-template-horizontal .hdk-item-img {
        flex: 0 0 80px !important;
        width: 80px !important;
        height: 80px !important;
    }
}

.hdk-template-horizontal .hdk-item-img img {
    border-radius: 8px;
}

/* 右侧内容区域 */
.hdk-template-horizontal .hdk-item-info {
    flex-grow: 1;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: visible;
    /* 改为 visible，防止二维码 Popover 被截断 */
}

/* 商品标题：自适应行高 */
.hdk-template-horizontal .hdk-item-title {
    font-size: 13px;
    line-height: 1.35;
    color: #374151;
    font-weight: 600;
    height: auto;
    margin-bottom: 4px;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 价格区域 */
.hdk-template-horizontal .hdk-item-prices {
    margin-bottom: 6px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.hdk-template-horizontal .hdk-price-current {
    font-size: 17px;
    margin-right: 0;
}

.hdk-template-horizontal .hdk-price-current small {
    font-size: 11px;
}

.hdk-template-horizontal .hdk-price-old {
    font-size: 11px;
}

/* 按钮及二维码容器 */
.hdk-template-horizontal .hdk-btn-wrap {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hdk-template-horizontal .hdk-buy-btn {
    padding: 7px 0 !important;
    font-size: 12px;
    border-radius: 6px;
}

.hdk-template-horizontal .hdk-qrcode-hover-wrap {
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

.hdk-template-horizontal .hdk-qrcode-icon {
    width: 16px;
    height: 16px;
}

/* 侧边栏小工具扁平微调：若小工具为横排，微调边距 */
.hdk-widget-container .hdk-items-list.hdk-template-horizontal {
    gap: 10px !important;
}

.hdk-widget-container .hdk-template-horizontal .hdk-item-card {
    border-radius: 8px !important;
    padding: 8px 16px 8px 16px !important;
    min-height: 100px;
}

.hdk-widget-container .hdk-template-horizontal .hdk-item-img {
    flex: 0 0 76px !important;
    width: 76px !important;
    height: 76px !important;
}

/* 轮播模式下二维码气泡自适应内部定位，防止被 overflow: hidden 裁剪 */
.hdk-widget-force-scroll .hdk-qrcode-popover {
    bottom: 5px !important;
    right: 40px !important;
    margin-bottom: 0 !important;
    transform: translateY(0) !important;
    opacity: 0;
    visibility: hidden;
}

.hdk-widget-force-scroll .hdk-qrcode-hover-wrap:hover .hdk-qrcode-popover {
    opacity: 1 !important;
    visibility: visible !important;
}

.hdk-widget-force-scroll .hdk-qrcode-popover::after {
    display: none !important;
    /* 移除指向底部的小箭头 */
}