@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Open+Sans:wght@400;600&display=swap');

:root {
    --primary-color: #ffd700;
    --secondary-color: #1c3b57;
    --accent-color: #8b0000;
    --bg-dark: rgba(28, 59, 87, 0.9);
    --text-light: #ffffff;
    --dark-text: #18d9e7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', sans-serif;
    background-image: url('/static/R.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh; /* 设置最小高度为100%视口高度 */
    display: flex;
    flex-direction: column;
    padding-left: 0; /* 移除左侧padding */
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex; /* 添加这行 */
}

header {
    background-color: transparent;
    padding: 15px 0;
    box-shadow: none;
    padding-left: 0; /* 移除左侧padding */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

header h1 {
    font-family: 'Cinzel', serif;
    color: var(--dark-text);
    font-size: 2.5rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
    margin: 0 auto;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: 2px solid var(--dark-text);
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

.main-container {
    display: flex;
    flex-grow: 1; /* 使主容器在flex布局中占据剩余空间 */
    padding: 20px 0;
    position: relative;
    max-width: 1400px; /* 添加这行 */
    margin: 0 auto; /* 添加这行 */
}

.sidebar {
    width: 200px;
    background-color: var(--bg-dark);
    padding: 20px;
    border-radius: 10px 0 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: calc(100vh - 140px); /* 设置侧边栏的高度 */
    position: sticky;
    top: 20px;
    overflow-y: auto;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar h2 {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.2rem;
    text-align: center;
}

nav ul {
    list-style-type: none;
}

nav ul li {
    margin-bottom: 10px;
}

nav ul li a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: block;
    padding: 8px;
    border-radius: 5px;
}

nav ul li a:hover, nav ul li a.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.main-content {
    flex-grow: 1;
    background-color: rgba(28, 59, 87, 0.7);
    padding: 20px;
    border-radius: 0 10px 10px 0;
    margin-left: 20px;
    overflow-y: auto;
    height: calc(100vh - 140px); /* 设置主内容区域的高度 */
}

.search-bar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-bar select {
    padding: 8px 12px;
    margin-right: 10px;
    border: 2px solid var(--primary-color);
    background-color: rgba(255, 255, 255, 0.3);
    color: var(--text-light);
    font-size: 0.9rem;
    border-radius: 5px;
    width: 200px;
}

.search-bar select option {
    background-color: rgba(28, 59, 87, 0.9);
    color: var(--text-light);
}

.search-container {
    display: flex;
    align-items: center;
}

.search-bar input {
    padding: 8px 12px;
    width: 300px;
    border: 2px solid var(--primary-color);
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
    border-radius: 5px 0 0 5px;
}

.search-bar button {
    padding: 8px 15px;
    background-color: var(--primary-color);
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    font-weight: bold;
    border-radius: 0 5px 5px 0;
    transition: background-color 0.3s ease;
}

.search-bar button:hover {
    background-color: #e6c300;
}

.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;

}

.product {
    background-color: var(--bg-dark);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.product-image {
    width: 100%;
    height: 150px;
    overflow: hidden;
}

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

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1rem;
    line-height: 1.2rem;
    max-height: 2.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-description {
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.2rem;
    max-height: 3.6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.product-details {
    margin-top: auto;
}

.product .quantity, .product .price {
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.product .price {
    font-weight: bold;
    color: var(--primary-color);
}

.buy-button {
    width: 100%;
    padding: 8px;
    background-color: var(--accent-color);
    border: none;
    color: var(--text-light);
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: bold;
    border-radius: 5px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.buy-button:hover {
    background-color: #a01010;
}

.product .quantity {
    color: yellow;
}

footer {
    background-color: var(--bg-dark);
    color: var(--text-light);
    text-align: center;
    padding: 15px 0;
    margin-top: auto;
    padding-left: 0; /* 移除左侧padding */
    display: flex; /* 添加这行 */
    justify-content: center; /* 添加这行 */
}

.pagination {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.page-link {
    color: var(--text-light);
    background-color: var(--secondary-color);
    padding: 8px 12px;
    margin: 0 5px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.page-link:hover {
    background-color: var(--primary-color);
    color: var(--secondary-color);
}

.page-link.active {
    background-color: var(--primary-color);
    color: var(--secondary-color);
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    .main-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-radius: 10px 10px 0 0;
        margin-bottom: 20px;
    }
    .main-content {
        margin-left: 0;
        border-radius: 0 0 10px 10px;
    }
    .search-bar input {
        width: 70%;
    }
    .header-content {
        flex-direction: column;
    }
    .logo {
        margin-bottom: 10px;
    }
    body, header, footer {
        padding-left: 0;
    }
}

.login-button, .logout-button {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 15px;
    background-color: var(--primary-color);
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    font-weight: bold;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.login-button:hover, .logout-button:hover {
    background-color: #e6c300;
}

.welcome-message {
    position: absolute;
    right: 150px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-weight: bold;
    display: none;
}

.login-modal, .buy-modal, .result-modal, .character-select-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-dark);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    width: 300px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.login-modal h2, .buy-modal h2, .result-modal h2, .character-select-modal h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
}

.login-modal input, .buy-modal button, .result-modal button, .character-select-modal button {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
}

.login-modal button, .buy-modal button, .character-select-modal button {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.login-modal button:hover, .buy-modal button:hover, .character-select-modal button:hover {
    background-color: var(--primary-color);
    color: var(--secondary-color);
}

.balance {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    color: var(--secondary-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: auto; /* 将金币显示推到底部 */
}

.balance span {
    font-size: 1.5em;
    display: block;
    margin-top: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* 添加一个金币图标 */
.balance::before {
    content: '🪙';
    font-size: 1.5em;
    display: block;
    margin-bottom: 5px;
}