/* public/styles.css */

/* 定义CSS变量，方便管理颜色和字体 */
:root {
    --primary-gradient-start: #a18cd1; /* 柔和紫色 */
    --primary-gradient-end: #fbc2eb;   /* 柔和粉色 */
    --container-bg: rgba(255, 255, 255, 0.95); /* 近白色半透明 */
    --card-bg: rgba(255, 255, 255, 0.8);      /* 稍透明的白色 */
    --text-color-dark: #333;
    --text-color-light: #555;
    --heading-color: #6a5acd; /* 稍深的蓝紫色 */
    --accent-color: #ff6b6b;  /* 亮红色 */
    --border-color: #e0e0e0;
    --input-bg: #f5f5f5;
    --button-gradient-start: #84fab0; /* 绿色系渐变 */
    --button-gradient-end: #8fd3f4;   /* 蓝色系渐变 */
    --error-color: #d9534f; /* 警告红 */
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --shadow-strong: rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Open Sans', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center; /* 垂直居中容器 */
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: var(--text-color-dark);
    overflow-y: auto; /* 允许垂直滚动 */
    overflow-x: hidden; /* 防止body本身出现横向滚动条 */
    position: relative;
    padding: 20px; /* 增加页面边缘的内边距 */
    box-sizing: border-box;
}

/* 背景动态效果 */
.background-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    background-size: 200% 200%;
    animation: moveBackground 20s infinite alternate ease-in-out;
    z-index: -1; /* 确保在内容下方 */
}

@keyframes moveBackground {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.container {
    background: var(--container-bg);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-strong);
    width: 100%;
    max-width: 800px; /* 增加最大宽度以适应更多内容 */
    text-align: center;
    backdrop-filter: blur(8px); /* 磨砂玻璃效果 */
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: fadeInScale 0.8s ease-out; /* 容器加载动画 */
    margin: auto; /* 自动上下外边距，当内容超出时允许垂直滚动 */
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

h1, h2, h3 {
    font-family: 'Montserrat', sans-serif;
    color: var(--heading-color);
    text-shadow: 1px 1px 3px var(--shadow-light);
}

h1 {
    margin-bottom: 30px;
    font-size: 2.5em;
    position: relative;
    display: inline-block; /* 确保伪元素定位正确 */
}

h1::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -10px;
    width: 60px;
    height: 3px;
    background: linear-gradient(to right, var(--primary-gradient-start), var(--primary-gradient-end));
    border-radius: 2px;
}

h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color-light);
    font-size: 1.1em;
}

input[type="text"],
select {
    width: calc(100% - 24px); /* 减去padding */
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color-dark);
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
    outline: none;
}

input[type="text"]::placeholder {
    color: #a0a0a0;
}

button {
    background: linear-gradient(45deg, var(--button-gradient-start) 0%, var(--button-gradient-end) 100%);
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    opacity: 0.9;
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* 加载动画 */
.spinner {
    border: 5px solid rgba(132, 250, 176, 0.3); /* 绿色系 */
    border-top: 5px solid var(--button-gradient-start);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 30px auto;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误信息 */
.error-message {
    color: var(--error-color);
    margin-top: 25px;
    font-weight: 600;
    font-size: 1.1em;
    display: none;
    background-color: rgba(255, 255, 255, 0.8);
    border-left: 5px solid var(--error-color);
    padding: 10px 15px;
    border-radius: 5px;
    box-shadow: 0 2px 5px var(--shadow-light);
}

/* 统计结果卡片 */
.stats-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-top: 35px;
    box-shadow: 0 6px 20px var(--shadow-medium);
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.4);
    opacity: 0; /* 初始隐藏，用于动画 */
    transform: translateY(20px); /* 初始位移，用于动画 */
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.stats-card.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.player-info {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px dashed var(--border-color);
}

.player-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin-right: 20px;
    border: 4px solid var(--accent-color);
    object-fit: cover;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.4);
    transition: transform 0.3s ease;
}

.player-avatar:hover {
    transform: scale(1.05) rotate(5deg);
}

.player-details {
    flex-grow: 1;
}

.player-info h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    color: var(--heading-color);
    font-size: 2em;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px var(--shadow-light);
}

.player-info p {
    margin: 5px 0 0 0;
    color: var(--text-color-light);
    font-size: 1.1em;
    font-weight: 600;
}

/* 修改 stats-grid 样式以实现自适应横向和分行 */
.stats-grid {
    display: grid;
    /* 关键：自动适应列数，每列最小280px，最大填充可用空间 */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; /* 网格项之间的间距 */
}

.stat-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 240, 0.9) 100%);
    padding: 18px;
    border-radius: 10px;
    box-shadow: 0 4px 12px var(--shadow-light);
    display: flex;
    flex-direction: column; /* 调整为垂直排列，标签在上，值在下 */
    align-items: flex-start; /* 左对齐内容 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-sizing: border-box; /* 包含padding和border在宽度内 */
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-medium);
}

.stat-label {
    font-weight: 600;
    color: var(--text-color-light);
    font-size: 1em;
    margin-bottom: 5px; /* 标签和值之间留白 */
}

.stat-value {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.3em;
    text-align: left; /* 值左对齐 */
    word-break: break-all;
    text-shadow: 0.5px 0.5px 1px var(--shadow-light);
    width: 100%; /* 确保值占据全部宽度 */
}

/* 战队信息样式 */
.platoon-info {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.platoon-details {
    display: flex;
    align-items: center;
    gap: 20px;
}

.platoon-emblem {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 武器和载具列表样式 */
.weapons-section, .vehicles-section {
    margin-top: 30px;
}

.weapons-list, .vehicles-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.weapon-item, .vehicle-item {
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 3px 10px var(--shadow-light);
    transition: transform 0.3s ease;
}

.weapon-item:hover, .vehicle-item:hover {
    transform: translateY(-3px);
}

.weapon-image, .vehicle-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.weapon-details, .vehicle-details {
    flex-grow: 1;
}

.weapon-details h3, .vehicle-details h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    color: var(--heading-color);
}

.weapon-details p, .vehicle-details p {
    margin: 3px 0;
    font-size: 0.9em;
    color: var(--text-color-light);
}

/* 媒体查询，针对小屏幕设备 */
@media (max-width: 768px) {
    body {
        align-items: flex-start; /* 小屏幕时，内容顶部对齐，避免垂直居中导致内容被截断 */
    }
    .container {
        padding: 25px;
        margin-top: 20px; /* 小屏幕时顶部留白 */
        margin-bottom: 20px; /* 小屏幕时底部留白 */
    }
    h1 {
        font-size: 2em;
    }
    button {
        padding: 12px 20px;
        font-size: 1.1em;
    }
    .player-info {
        flex-direction: column;
        text-align: center;
    }
    .player-avatar {
        margin-right: 0;
        margin-bottom: 15px;
    }
    .player-info h2 {
        font-size: 1.6em;
    }
    .player-info p {
        font-size: 1em;
    }
    .stat-item {
        padding: 15px;
    }
    .stat-value {
        font-size: 1.2em;
    }
    .platoon-details {
        flex-direction: column;
        text-align: center;
    }
    .weapons-list, .vehicles-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
        border-radius: 10px;
    }
    h1 {
        font-size: 1.8em;
    }
    input[type="text"],
    select,
    button {
        font-size: 0.95em;
        padding: 10px;
    }
    .stats-card {
        padding: 20px;
    }
}