/* 全局 CSS 样式文件 - 供 home.html 和 home_en.html 共用 */

/* CSS 变量定义 - 支持夜间模式 */
:root {
    --bg-color: #f5f5f5;
    --container-bg: white;
    --text-color: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #ddd;
    --shadow-color: rgba(0,0,0,0.1);
    --input-bg: white;
    --hover-bg: #f8f9fa;
    --qq-group-bg: #f0f7ff;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #404040;
    --shadow-color: rgba(0,0,0,0.3);
    --input-bg: #3d3d3d;
    --hover-bg: #383838;
    --qq-group-bg: #3d3d3d;
}

/* 夜间模式下的图表容器 */
[data-theme="dark"] #topThousandChartContainer,
[data-theme="dark"] #chartContainer {
    background-color: transparent;
}

/* 基础样式重置 */
* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    font-family: Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    padding: 10px;
    color: var(--text-color);
}

/* 主容器样式 */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    background-color: var(--container-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    box-sizing: border-box;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* 表单行和表单组 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    align-items: end;
}

.form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    background-color: var(--input-bg);
    color: var(--text-color);
}

button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    height: 40px;
    min-width: 120px;
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

/* 历史查询记录样式 */
.history-section {
    margin-top: 20px;
    border-radius: 4px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border-radius: 4px;
    min-height: 40px;
}

.history-item {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    background-color: var(--input-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px var(--shadow-color);
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: auto;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.history-content {
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    flex-shrink: 1;
    flex-basis: auto;
}

.history-delete {
    background-color: var(--input-bg);
    color: #d53d4a;
    border-radius: 100%;
    padding: 0;
    cursor: pointer;
    font-size: 20px;
    margin-left: 6px;
    min-width: 0;
    width: 26px;
    height: 26px;
}

.history-delete:hover {
    color: #c82333;
    background: white;
}

/* 移动端换行符 */
.mobile-break {
    display: none;
}

/* 徽章样式 */
.title-badge {
    font-size: 16px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    color: var(--text-color);
}

.message-badge {
    font-size: 14px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
    margin-left: 5px;
    color: var(--text-muted);
}

/* 动画关键帧 */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* 图表容器 */
#topThousandChartContainer {
    height: 400px;
    margin-top: 20px;
}

#chartContainer {
    height: 400px;
    margin-top: 20px;
}

/* 无数据提示样式 */
#chartContainer.no-data {
    min-height: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 统计方块 */
.stats-container {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-box {
    flex: 1;
    background-color: var(--input-bg);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    min-width: 150px;
    box-shadow: 0 1px 3px var(--shadow-color);
    min-height: 120px;
}

.stat-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    height: 20px;
}

.stat-box p {
    margin: 5px 0;
    font-weight: bold;
    min-height: 24px;
    line-height: 24px;
}

.qq-group {
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: var(--qq-group-bg);
    border-radius: 4px;
    border-left: 4px solid #1890ff;
}

.current-title {
    margin-top: 10px;
    padding: 8px 15px;
    background-color: var(--qq-group-bg);
    border-radius: 4px;
    border-left: 4px solid #007bff;
    display: none;
    font-size: 14px;
}

.calculator-select {
    margin-top: 10px;
    padding: 10px;
    background-color: var(--qq-group-bg);
    border-radius: 4px;
}

.calculator-select-button {
    padding: 5px 15px;
    min-width: auto;
    height: auto;
    font-size: 13px;
    margin-right: 5px;
    margin-top: 5px;
}

.calculator-result {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background-color: var(--qq-group-bg);
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.user-stats-box {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 3px;
    background-color: var(--container-bg);
    border-radius: 6px;
}


.user-stats-section {
    background-color: var(--qq-group-bg);
    border-radius: 8px;
    padding: 12px 15px;
}
/* 信息区块 */
.info-section {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--hover-bg);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

/* 用户统计区域 */
#userStatsSection {
    margin-top: 8px;
}

#userStatsContent {
    max-height: 500px;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

#userStatsContent.collapsed {
    max-height: 0;
    margin-top: 0;
}

#userStatsToggle.rotated {
    transform: rotate(-180deg);
}

/* 快速导航按钮 */
.quick-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    padding: 15px;
    background-color: var(--input-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.quick-nav-btn {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 140px;
    text-align: center;
}

.quick-nav-btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 查看分数变化详情按钮样式 */
.view-detail-btn {
    background-color: #28a745 !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
    min-width: auto !important;
    opacity: 0.9;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.view-detail-btn:hover {
    background-color: #218838 !important;
    opacity: 1;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3) !important;
}

/* 榜单弹窗样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background-color: var(--container-bg);
    color: var(--text-color);
    border-radius: 8px;
    padding: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px var(--shadow-color);
    min-height: 400px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

.modal-header h2 {
    margin: 0;
    color: #007bff;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    min-width: auto;
    width: 25px;
    height: auto;
    padding: 0;
}

.modal-close:hover {
    color: var(--text-color);
}

/* 榜单表格 */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-height: 300px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.leaderboard-table th {
    background-color: var(--hover-bg);
    font-weight: bold;
    color: var(--text-color);
    position: sticky;
    top: 0;
}

.leaderboard-table tr:hover {
    background-color: var(--hover-bg);
}

/* 分页控件 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.pagination button {
    min-width: 80px;
    height: 35px;
}

/* 按钮 loading 状态 */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button.loading {
    position: relative;
    pointer-events: none;
}

.pagination span {
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.pagination .page-info-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.leaderboard-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.leaderboard-no-data {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* 排名徽章 */
.rank-badge {
    display: inline-block;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
}

.rank-badge.silver {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #000;
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #cd7f32, #e09856);
    color: #fff;
}

/* 移动端适配 - 768px 以下 */
@media screen and (max-width: 768px) {
    .quick-nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .quick-nav-btn {
        width: 100%;
        min-width: auto;
    }
    
    .stats-container {
        flex-direction: column;
    }
    
    .stat-box {
        min-width: auto;
    }
    
    body {
        padding: 5px;
    }
    
    .container {
        padding: 10px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-group {
        min-width: auto;
        width: 100%;
        flex: none;
    }
    
    button {
        width: 100%;
        height: auto;
        padding: 12px;
        flex: none;
    }
    
    #topThousandChartContainer {
        height: 300px;
    }
    
    #chartContainer {
        height: 300px;
    }
    
    #currentTitleRatings {
        /*font-size: 14px;*/
    }
    
    .mobile-break {
        display: inline;
    }
    
    .title-badge {
        display: block;
        text-align: center;
        justify-content: center;
        margin-bottom: 5px;
    }
    
    .message-badge {
        display: block;
        text-align: center;
        justify-content: center;
        margin-bottom: 5px;
        margin-left: 0;
    }

    .leaderboard-table{
        min-height: 0;
    }
    
    .modal-container {
        width: 95%;
        padding: 5px;
    }

    .modal-container input{
        height: 24px;
    }

    .modal-container button{
        height: 26px;
        font-size: 13px;
        padding: 0;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0 5px;
        font-size: 14px;
    }

    .leaderboard-table td button {
        height: 20px;
        margin: 4px 0;
    }
    
    .rank-badge {
        width: 25px;
        height: 25px;
        line-height: 25px;
        font-size: 12px;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .pagination button {
        min-width: 70px;
        height: 26px;
        font-size: 13px;
        padding: 0 10px;
    }
    
    .pagination span {
        font-size: 12px;
        text-align: center;
    }
    
    .pagination input {
        font-size: 13px;
        height: 32px;
        padding: 0 6px;
    }
    
    .pagination .page-info-group {
        display: flex;
        align-items: center;
        gap: 5px;
        flex-basis: auto;
        margin: 0;
    }
}

/* 小屏幕适配 - 480px 以下 */
@media screen and (max-width: 480px) {
    #topThousandChartContainer {
        height: 250px;
    }
    
    #chartContainer {
        height: 250px;
    }
    
    .container {
        padding: 8px;
    }
    
    #currentTitleRatings {
        font-size: 13px;
        color: var(--text-color);
    }
    
    #userStatsSection h3 {
        font-size: 14px;
    }
    
    #userStatsSection p:first-child {
        font-size: 12px;
    }
    
    #userStatsSection p:not(:first-child) {
        font-size: 20px;
    }
}

/* 评分方块样式 */
.rating-square {
    transition: transform 0.2s ease;
}

.rating-square:hover {
    transform: scale(1.1);
    z-index: 10;
}

/* 每局分数变化详情移动端优化 */
@media screen and (max-width: 768px) {
    .rating-change-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start !important;
    }
    
    .rating-change-header h3 {
        width: 100%;
        text-align: center;
    }
    
    .rating-change-header .button-group {
        width: 100%;
        display: flex;
        gap: 10px;
        justify-content: center;
    }
    
    .rating-change-header .button-group button {
        flex: 1;
        max-width: 150px;
    }
    
    /* 表格容器在移动端允许横向滚动 */
    #ratingChangeContent > div {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
        
    /* 表格最小宽度，防止内容被挤压 */
    #ratingChangeContent table {
        min-width: 100% !important;
    }
        
    /* 移动端：强制改变表格行布局为块级布局 */
    .rating-detail-row {
        display: block !important;
        width: 100% !important;
        border-bottom: 2px solid #e8e8e8 !important;
        padding-bottom: 5px !important;
    }
        
    /* 移动端：第一行 (日期 + 分数) 使用 flex 布局 */
    .rating-detail-row::before {
        content: '' !important;
        display: flex !important;
        width: 100% !important;
        margin-bottom: 0 !important;
    }
        
    /* 移动端：日期和分数单元格在一行 - 使用 flex 子元素 */
    .rating-detail-row > td:first-child {
        display: inline-flex !important;
        width: auto !important;
        min-width: auto !important;
        max-width: 40% !important;
        font-weight: bold !important;
        color: #1890ff !important;
        text-align: left !important;
        white-space: normal !important;
        vertical-align: middle !important;
        padding: 8px 0 !important;
        border: none !important;
    }
        
    .rating-detail-row > td:nth-child(2) {
        display: inline-flex !important;
        flex: 1 !important;
        text-align: left !important;
        white-space: normal !important;
        vertical-align: middle !important;
        padding: 8px 0 !important;
        border: none !important;
        margin-left: 8px !important;
    }
        
    /* 移动端：对局详情单独一行 */
    .rating-detail-row > td:last-child {
        display: block !important;
        width: 100% !important;
        padding: 10px 0 0 0 !important;
        border: none !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
        
    /* 对局详情容器 - 强制覆盖内联样式 */
    .rating-detail-row > td:last-child > div {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)) !important;
        gap: 6px !important;
        align-items: center !important;
        justify-content: start !important;
    }
    
    /* 对局详情分页按钮移动端适配 */
    #ratingChangeContent .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #ratingChangeContent .pagination button {
        min-width: 70px;
        height: 26px;
        font-size: 13px;
        padding: 0 10px;
    }
    
    #ratingChangeContent .pagination span {
        font-size: 12px;
        text-align: center;
    }
}
