/* General Styles */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

/* 背景容器样式 */
.background {
    position: fixed; /* 背景固定 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://images.catsansei.xyz/mall.jpg') no-repeat center center;
    background-size: cover; /* 背景适应屏幕宽度 */
    z-index: -1; /* 放在最底层 */
}

/* 页面内容样式 */
.content {
    position: relative; /* 内容层次相对于背景定位 */
    z-index: 1; /* 内容在背景上方 */
    overflow-y: auto; /* 内容可滚动 */
    padding-top: 10px; /* 留出 header 的高度 */
}

/* Header Styles */
header {
    position: fixed; /* 固定在顶部 */
    top: 0;
    left: 0;
    right: 0;
    z-index: 10; /* 层级最高 */
    background: url('https://images.catsansei.xyz/head.jpg') no-repeat center center;
    background-size: cover;
    height: 20vh;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    color: white;
}

header .logo img {
    width: 100px;
    height: auto;
    border-radius: 50%;
}

/* Links */
header .header-links {
    position: relative;
    top: -40%; /* 将链接向上移动 */
    display: flex;
    justify-content: flex-end; /* 默认右对齐 */
    gap: 1rem; /* 链接之间的间距 */
    flex-grow: 1; /* 占用剩余空间 */
    min-width: 0; /* 防止过度拉伸 */
}

header .header-links a {
    color: white;
    text-decoration: underline;
    font-size: 1rem;
    background-color: rgba(0, 0, 0, 0.4); /* 黑色透明背景 */
    padding: 2px 5px; /* 内边距 */
    border-radius: 5px; /* 圆角 */
    display: inline-block; /* 自适应文字大小 */
    transition: color 0.3s ease;
}

header .header-links a:hover {
    color: #28a745;
    text-decoration: none;
}

/* Wallet Info */
header .wallet-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

header button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1rem;
}

#balance-display {
    display: flex;
    flex-direction: column; /* 垂直排列 */
    align-items: flex-end; /* 左对齐内容 */
    font-size: 1rem; /* 适配屏幕的字体大小 */
    color: white;
    margin-top: 0.5rem;
    background-color: rgba(0, 0, 0, 0.6); /* 半透明背景 */
    padding: 5px 10px;
    border-radius: 5px;
}

/* 分类按钮的基础样式 */
.tab-container {
    position: fixed;
    top: 50%; /* 垂直居中 */
    left: 0; /* 靠左排列 */
    transform: translateY(-50%);
    display: flex;
    flex-direction: column; /* 垂直排列按钮 */
    gap: -10px; /* 按钮之间的间距 */
    z-index: 1000; /* 确保按钮层级高于其他内容 */
}

.tab-button {
    width: 40px; /* 统一按钮宽度 */
    height: 100px; /* 统一按钮高度 */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    writing-mode: vertical-rl; /* 垂直文字排列 */
    transition: background-color 0.3s ease, transform 0.3s ease;
}

/* 不同按钮的背景颜色 */
.tab-button.home {
    background-color: #ffc107; /* 黄色背景 */
}

.tab-button.physical {
    background-color: #808080; /* 灰色背景 */
}

.tab-button.virtual {
    background-color: #6f42c1; /* 紫色背景 */
}

.tab-button.knowledge {
    background-color: #007bff; /* 蓝色背景 */
}

/* 悬停效果 */
.tab-button:hover {
    opacity: 0.9;
    transform: scale(1.05); /* 悬停时放大 */
}

/* 激活状态 */
.tab-button.active {
    background-color: #0056b3; /* 深蓝色激活状态 */
}

.search-container {
    position: absolute; /* 设置为绝对定位 */
    top: 220px; /* 距顶部距离，根据实际情况调整 */
    left: 50%; /* 水平居中 */
    transform: translateX(-50%); /* 修正居中偏移 */
    z-index: 10; /* 确保位于其他元素之上 */
    display: flex; /* 设置为 flex 布局 */
    justify-content: center; /* 居中对齐 */
    align-items: center; /* 垂直居中 */
    gap: 10px; /* 输入框和按钮之间的间距 */
    background-color: rgba(255, 255, 255, 0.3); /* 半透明白色背景 */
    border-radius: 5px; /* 圆角边框 */
}

#search-bar {
    width: 600px; /* 输入框宽度 */
    padding: 10px; /* 内边距 */
    border: 1px solid #ccc; /* 边框 */
    border-radius: 5px; /* 圆角边框 */
    font-size: 1rem; /* 字体大小 */
}

.search-container button {
    padding: 10px 20px; /* 按钮大小 */
    background-color: #000000; /* 按钮背景色 */
    color: white; /* 按钮文字颜色 */
    border: none; /* 无边框 */
    border-radius: 5px; /* 圆角边框 */
    cursor: pointer; /* 鼠标手势 */
    font-size: 1rem; /* 字体大小 */
}

.search-container button:hover {
    background-color: #FFD700; /* 按钮悬停颜色 */
}

/* Product Container */
.container {
    position: relative;
    z-index: 5; /* 商品展示框在 head 下面，但在背景 mall 之上 */
    padding: 1rem; /* 保证内容不贴边 */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* 自适应列布局 */
    gap: 2rem; /* 减少商品之间的间距 */
    background-color: transparent; /* 背景透明，露出 mall 图片 */
    max-width: 1200px; /* 限制容器最大宽度 */
    margin: 25vh auto 0; /* 垂直间距为 20vh，水平自动居中 */
}

.product-card h3.title-green {
    color: green;
}

.product-card h3.title-red {
    color: red;
}

/* 商品名颜色 */
.product-name {
    font-weight: bold;
}

.product-name.in-stock {
    color: #7FFFAA !important; /* 绿色，表示有库存 */
}

.product-name.out-of-stock {
    color: #FF0000 !important; /* 红色，表示无库存 */
}

.product-card {
    background: url('https://images.catsansei.xyz/card-background.webp') no-repeat center center;
    background-size: cover;
    color: #7FFFAA;
    text-align: center;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 250px; /* 固定展示柜宽度 */
    height: 500px; /* 固定展示柜高度 */
    margin: 0 auto; /* 居中 */
}

.product-card .image-container {
    display: flex; /* 使用 Flexbox 布局 */
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    width: 100%; /* 容器宽度为父级宽度 */
    height: auto; /* 自适应高度 */
    aspect-ratio: 1 / 2; /* 宽高比为 1:2 */
    overflow: hidden; /* 超出部分隐藏 */
    margin: 0 auto; /* 整个容器居中对齐 */
    padding: 0; /* 移除任何可能的内边距 */
    background-color: #f4f4f4; /* 背景色 */
    border-radius: 10px; /* 圆角效果 */
}

.product-card img {
    display: block;
    max-width: 100%; /* 限制宽度不超过容器 */
    max-height: 100%; /* 限制高度不超过容器 */
    object-fit: cover; /* 裁剪图片以适应容器 */
    margin: 0 auto; /* 居中对齐 */
    border-radius: 10px; /* 圆角效果 */
}

/* 标题和段落的通用样式 */
.product-card h3,
.product-card p {
    margin: 0.2rem 0; /* 统一间距 */
    padding: 3px 5px; /* 统一内边距 */
    width: 100%; /* 宽度设为与父容器一致 */
    text-align: center; /* 居中对齐 */
    background: rgba(0, 0, 0, 0.5); /* 半透明背景 */
    border-radius: 3px; /* 圆角 */
}

/* 单独调整标题的样式 */
.product-card h3 {
    font-size: 1.2rem; /* 缩小标题字体 */
    margin-top: 1px; /* 调整标题与图片容器之间的距离 */
}

/* 单独调整段落（价格和库存）的样式 */
.product-card p {
    font-size: 1rem; /* 缩小字体 */
    color: #FFD700; /* 设置字体颜色 */
}

/* 调整库存字体 */
.product-card p:nth-of-type(2) {
    color: #FFD700; /* 设置库存字体颜色为金色 */
}

.product-card .button-group {
    display: flex;
    justify-content: space-between; /* 均匀分布按钮 */
    gap: 0.5rem; /* 按钮之间的间距 */
    margin-top: 1px; /* 按钮上方留出更多空间 */
}

.product-card button, 
.product-card a {
    display: inline-block;
    text-align: center;
    padding: 10px 15px; /* 统一内边距 */
    font-size: 0.8rem; /* 统一字体大小 */
    border: none;
    border-radius: 5px;
    text-decoration: none;
    color: white; /* 按钮文字颜色 */
    cursor: pointer;
    width: calc(50% - 0.5rem); /* 每个按钮占一半宽度 */
    transition: background-color 0.3s ease;
}

/* "Buy Now" 按钮样式 */
.product-card .buy-button {
    background-color: #28a745;
}

.product-card .buy-button:hover {
    background-color: #218838;
}

/* 禁用状态的购买按钮样式 */
.product-card .buy-button:disabled {
    background-color: gray;
    cursor: not-allowed;
    opacity: 0.7; /* 半透明效果 */
}

/* "View Details" 按钮样式 */
.product-card .details-button {
    background-color: #007bff;
}

.product-card .details-button:hover {
    background-color: #0056b3;
}

.price-container {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
}

.price-container p {
    margin: 0;
    font-weight: bold;
}

.price-container select {
    margin-left: 10px;
    font-size: 0.8rem;
    padding: 1.5px 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    background-color: #f9f9f9;
}

.price-container select:focus {
    border-color: #28a745;
    background-color: #fff;
}

        .carousel {
            position: relative;
            width: 100%;
            max-width: 250px;
            height: 380px;
            margin: 0 auto;
            overflow: hidden;
            border-radius: 10px;
        }

.carousel-images {
    display: flex;
    transition: transform 0.5s ease-in-out;
}

        .carousel-images img {
            width: 250px;
            height: 380px;
            object-fit: cover;
            flex-shrink: 0;
            cursor: pointer; /* 鼠标悬停变为可点击 */
        }

.carousel-button {
    position: absolute;
    top: 50%; /* 垂直居中 */
    transform: translateY(-50%);
    width:  40px !important; /* 设置按钮的宽度 */
    height: 40px !important; /* 设置按钮的高度 */
    background-color: rgba(0, 0, 0, 0.1); /* 半透明背景色 */
    color: white;
    border: none;
    border-radius: 50%; /* 圆形按钮 */
    display: flex; /* 启用 Flexbox 布局 */
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.3s ease;
}

.carousel-button.prev {
    left: 0px; /* 左侧按钮 */
}

.carousel-button.next {
    right: 0px; /* 右侧按钮 */
}

.carousel-button:hover {
    background-color: #28a745 !important; /* 悬停背景为绿色 */
    color: blue; /* 确保文字颜色为白色 */
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.image-modal.show {
    display: flex;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border: 3px solid #fff;
    border-radius: 10px;
}

.image-modal .close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    color: white;
    font-size: 2rem;
    border: none;
    cursor: pointer;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #333;
    color: white;
    font-size: 1.2rem;
    text-decoration: none;
    border-radius: 50%;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.footer-links a:hover {
    background-color: #28a745;
    transform: scale(1.1);
}

.footer-links a.btn {
    padding: 0rem 0.8rem;
    background-color: #333;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.footer-links a.btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.footer-links i {
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.footer-links i:hover {
    color: #007bff;
}

@media (max-width: 767px) {
    .product-card .image-container {
        aspect-ratio: 1 / 2; /* 保持宽高比 */
        height: auto; /* 自适应高度 */
    }

    .product-card img {
        max-width: 100%;
        max-height: 100%;
        object-fit: cover;
    }

    .tab-container {
        position: fixed;
        top: 60%;
        left: 0;
        transform: translateY(-50%);
        gap: 10px;
    }

    .tab-button {
        font-size: 0.9rem;
        padding: 8px 16px;
        writing-mode: vertical-rl; /* 小屏幕垂直文字排列 */
    }
}

/* 针对平板屏幕 (480px ~ 767px) 的响应式设计 */
@media (max-width: 767px) and (min-width: 480px) {
    body {
        font-size: 14px; /* 调整字体大小 */
    }

    header {
        height: auto; /* 自适应高度 */
        flex-direction: column; /* 垂直排列 */
        align-items: flex-start; /* 左对齐内容 */
        padding: 1rem;
    }

    header .logo img {
        width: 80px; /* 缩小 logo 尺寸 */
        margin-bottom: 1rem;
    }

    header .header-links {
        position: absolute;
        top: 10px;
        right: 10px;
        flex-direction: row; /* 链接水平排列 */
        gap: 0.5rem;
        justify-content: flex-end; /* 靠右对齐 */
        background-color: rgba(0, 0, 0, 0.5); /* 半透明背景 */
        padding: 5px 10px; /* 内边距 */
        border-radius: 5px; /* 圆角 */
    }

    header .header-links a {
        font-size: 0.8rem;
        padding: 2px 6px;
    }

    header button {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    #balance-display {
        font-size: 0.8rem;
        text-align: center;
        padding: 2px 6px;
    }

    .tab-container {
        position: fixed;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        gap: 0px;
    }

    .tab-button {
        font-size: 0.9rem;
        padding: 2px 4px;
        writing-mode: vertical-rl; /* 小屏幕垂直文字排列 */
    }

    .container {
        grid-template-columns: repeat(2, 1fr); /* 每行显示两个商品 */
        gap: 1rem;
        padding: 1rem;
        margin: 25vh auto 0; /* 垂直间距为 18vh，水平自动居中 */
    }

    .product-card {
        padding: 1rem;
        width: 200px; /* 调整展示柜宽度 */
        height: 350px; /* 调整展示柜高度 */
        margin: 0 auto; /* 居中显示 */
    }

    .product-card .image-container {
        height: 180px; /* 图片展示区域固定高度 */
        overflow: hidden; /* 超出部分隐藏 */
    }

    .product-card img {
        width: 100%;
        height: 100%; /* 填满展示区域 */
        object-fit: cover; /* 按比例裁剪 */
    }

    .product-card h3, .product-card p {
        font-size: 0.9rem; /* 缩小文字大小 */
    }

    .product-card button {
        font-size: 0.9rem; /* 缩小按钮文字 */
        padding: 0.3rem 0.8rem;
    }

    .search-container {
        top: 200px; /* 调整搜索栏的垂直位置 */
        width: 80%; /* 搜索栏的宽度占屏幕 90% */
        height: auto; /* 确保高度适配内容 */
        padding: 5px; /* 添加内边距，保证内容不贴边 */
    }

    #search-bar {
        height: 30px; /* 设置输入框的固定高度 */
        width: 70%; /* 输入框宽度占搜索容器的 70% */
        padding: 0px; /* 输入框内边距 */
        font-size: 16px; /* 调整字体大小 */
    }

    .search-container button {
        height: 30px; /* 按钮高度与输入框保持一致 */
        padding: 3px 5px; /* 按钮内边距 */
        font-size: 0.8rem; /* 调整按钮字体大小 */
    }
}

/* 针对小屏幕 (小于 480px) 的响应式设计 */
@media (max-width: 480px) {
    body {
        font-size: 12px; /* 再次缩小字体大小 */
        background: url('https://images.catsansei.xyz/mall3.jpg') no-repeat center center !important;
    }

    header {
        background: url('https://images.catsansei.xyz/head4.jpg') no-repeat center center;
        background-size: cover;
        height: auto; /* 自适应高度 */
        flex-direction: column; /* 垂直排列 */
        align-items: flex-start; /* 左对齐内容 */
        padding: 0.5rem;
    }

    header .logo img {
        width: 60px; /* 更小的 logo */
        margin-bottom: 0.5rem;
    }

    header .header-links {
        position: absolute;
        top: 10px;
        right: 10px;
        flex-direction: row; /* 链接水平排列 */
        gap: 0.3rem;
        justify-content: flex-end; /* 靠右对齐 */
        background-color: rgba(0, 0, 0, 0.5); /* 半透明背景 */
        padding: 4px 8px; /* 内边距 */
        border-radius: 5px; /* 圆角 */
    }

    header .header-links a {
        font-size: 0.7rem;
        padding: 2px 4px;
    }

    header button {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }

    #balance-display {
        font-size: 0.6rem;
        text-align: center;
        padding: 2px 4px;
    }

    .container {
        grid-template-columns: 1fr; /* 每行显示一个商品 */
        gap: 0.5rem;
        padding: 0.5rem;
        margin: 20vh auto 0; /* 垂直间距为 18vh，水平自动居中 */
    }

    .product-card {
        padding: 0.5rem;
        width: 240px; /* 进一步缩小展示柜宽度 */
        height: 480px; /* 进一步缩小展示柜高度 */
        margin: 0 auto; /* 居中显示 */
    }

.product-card .image-container {
    display: flex; /* 使用 Flexbox 布局 */
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    width: 100%; /* 容器宽度为父级宽度的 80% */
    aspect-ratio: 1 / 2; /* 容器宽高比为 1:2 */
    overflow: hidden; /* 超出部分隐藏 */
    margin: 0 auto; /* 整个容器居中对齐 */
}

    .product-card img {
        max-width: 100%;
        max-height: 100%;
        object-fit: cover;
        margin: 0; /* 去除任何可能的外边距 */
    }

    .product-card h3, .product-card p {
        font-size: 0.9rem; /* 进一步缩小文字 */
    }

    .product-card button {
        font-size: 0.8rem; /* 缩小按钮文字 */
        padding: 0.2rem 0.5rem;
    }

    .carousel-button {
        width: 30px; /* 针对小屏幕调整大小 */
        height: 30px;
    }

    .tab-container {
        position: fixed;
        top: 60%;
        left: 0;
        transform: translateY(-50%);
        gap: 0px; /* 小屏幕的按钮间距 */
    }

    .tab-button {
        width: 30px;
        height: 80px;
        font-size: 0.8rem;
        padding: 0px 2px;
        writing-mode: vertical-rl; /* 小屏幕垂直文字排列 */
    }

    .search-container {
        top: 145px; /* 调整搜索栏的垂直位置 */
        width: 80%; /* 搜索栏的宽度占屏幕 90% */
        height: auto; /* 确保高度适配内容 */
        padding: 5px; /* 添加内边距，保证内容不贴边 */
    }

    #search-bar {
        height: 30px; /* 设置输入框的固定高度 */
        width: 70%; /* 输入框宽度占搜索容器的 70% */
        padding: 0px; /* 输入框内边距 */
        font-size: 16px; /* 调整字体大小 */
    }

    .search-container button {
        height: 30px; /* 按钮高度与输入框保持一致 */
        padding: 3px 5px; /* 按钮内边距 */
        font-size: 0.8rem; /* 调整按钮字体大小 */
    }
}