/* 全局样式和字体设置 */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f9;
    color: #333;
    position: relative;
}

/* 水印样式 */
.watermark {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.watermark::before {
    content: 'B站Convergence42';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 3em;
    color: rgba(0, 0, 0, 0.03);
    white-space: nowrap;
    user-select: none;
    font-weight: bold;
}

header {
    background-color: #ffffff;
    padding: 15px 30px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
}

h1, h2 {
    margin: 0;
    font-size: 1.5em;
    color: #2c3e50;
}

h2 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-size: 1.2em;
}

.container {
    display: flex;
    padding: 20px;
    gap: 20px;
}

.panel {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.07);
    padding: 20px;
}

/* 左侧控制面板的样式 */
#controls-panel {
    width: 25%;
    max-width: 300px;
    height: calc(100vh - 120px); /* 视口高度减去header和padding */
    display: flex;
    flex-direction: column;
}

#project-selector {
    margin-bottom: 20px;
}

#project-select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.95em;
}

/* 左侧风扇选择区域的样式 */
#fan-selector {
    flex-grow: 1;
    overflow-y: auto; /* 如果风扇太多，则出现滚动条 */
    display: flex;
    flex-direction: column;
}

#fan-selector h2 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-size: 1.2em;
}

#select-all-container {
    padding: 5px 5px 15px 5px;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
    font-size: 0.95em;
    cursor: pointer;
}

#fan-list {
    overflow-y: auto;
}

#fan-list label {
    display: block; /* 每个选项占一行 */
    margin-bottom: 10px;
    font-size: 0.95em;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#fan-list label:hover {
    background-color: #f0f0f0;
}

/* 右侧包含图表和说明的列 */
#right-column {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0; /* 防止flex item溢出 */
    height: calc(100vh - 120px); /* 视口高度减去header和padding */
}

/* 右侧图表区域的样式 */
#chart-container {
    flex: 1 1 auto; /* 占据剩余空间，允许伸缩 */
    min-height: 400px; /* 增加最小高度确保图表完整显示 */
    max-height: calc(100vh - 320px); /* 确保不会超出视口，为描述区域留出空间 */
    display: flex; /* 让子元素可以伸缩 */
    overflow: hidden; /* 防止内容溢出 */
}

#chart {
    width: 100%;
    height: 100%;
    min-width: 0; /* 防止flex item溢出 */
    min-height: 400px; /* 确保图表有足够高度 */
}

/* 说明区域样式 */
#description-container {
    flex: 0 0 auto; /* 固定大小，不伸缩 */
    height: 180px; /* 固定高度而不是最大高度 */
    line-height: 1.6;
    color: #555;
    font-size: 0.9em;
    overflow-y: auto;
}

/* 移动端响应式设计 */
/* 平板设备和小屏幕 */
@media screen and (max-width: 768px) {
    header {
        padding: 10px 15px;
    }

    h1 {
        font-size: 1.2em;
    }

    .container {
        flex-direction: column;
        padding: 10px;
        gap: 15px;
    }

    #controls-panel {
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
    }

    #fan-selector {
        max-height: 300px;
        overflow-y: auto;
    }

    #right-column {
        height: auto;
        min-height: 500px;
    }

    #chart-container {
        min-height: 350px;
        max-height: 450px;
    }

    #chart {
        min-height: 350px;
    }

    #description-container {
        height: auto;
        min-height: 100px;
        max-height: 200px;
    }

    .panel {
        padding: 15px;
    }

    #fan-list label {
        padding: 8px;
        margin-bottom: 8px;
        font-size: 1em;
    }

    #select-all-container {
        padding: 8px;
        font-size: 1em;
    }

    #project-select {
        padding: 10px;
        font-size: 1em;
    }
}

/* 手机横屏优化 */
@media screen and (max-width: 950px) and (orientation: landscape) {
    body {
        overflow-x: hidden;
    }

    header {
        padding: 5px 15px;
    }

    h1 {
        font-size: 1em;
    }

    .container {
        flex-direction: row;
        padding: 8px;
        gap: 10px;
        height: calc(100vh - 40px);
    }

    #controls-panel {
        width: 35%;
        max-width: 280px;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #project-selector {
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    #fan-selector {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    #fan-selector h2 {
        font-size: 0.95em;
        padding-bottom: 5px;
        margin-bottom: 8px;
        flex-shrink: 0;
    }

    #select-all-container {
        padding: 4px 5px;
        font-size: 0.85em;
        margin-bottom: 6px;
        flex-shrink: 0;
    }

    #fan-list {
        flex-grow: 1;
        overflow-y: auto;
        min-height: 0;
    }

    #fan-list label {
        padding: 4px 5px;
        margin-bottom: 4px;
        font-size: 0.85em;
    }

    #right-column {
        flex-grow: 1;
        height: 100%;
        gap: 10px;
        overflow: hidden;
    }

    #chart-container {
        flex: 1 1 auto;
        min-height: 250px;
        max-height: calc(100% - 150px);
    }

    #chart {
        min-height: 250px;
    }

    #description-container {
        flex: 0 0 auto;
        height: 120px;
        font-size: 0.85em;
    }

    .panel {
        padding: 10px;
    }

    h2 {
        font-size: 1em;
        padding-bottom: 6px;
    }

    #project-select {
        padding: 6px;
        font-size: 0.9em;
    }
}

/* 手机竖屏优化 */
@media screen and (max-width: 480px) and (orientation: portrait) {
    header {
        padding: 8px 10px;
    }

    h1 {
        font-size: 1.1em;
    }

    h2 {
        font-size: 1em;
    }

    .container {
        padding: 8px;
        gap: 12px;
    }

    #controls-panel {
        width: 100%;
    }

    #fan-selector {
        max-height: 250px;
    }

    #chart-container {
        min-height: 300px;
        max-height: 400px;
    }

    #chart {
        min-height: 300px;
    }

    #description-container {
        height: auto;
        max-height: 180px;
    }

    .panel {
        padding: 12px;
        border-radius: 6px;
    }

    #fan-list label {
        padding: 10px;
        margin-bottom: 6px;
        font-size: 0.95em;
    }

    #select-all-container {
        padding: 10px;
        font-size: 0.95em;
    }

    #project-select {
        padding: 10px;
        font-size: 0.95em;
    }
}
