:root {
    --primary-color: #2196F3;
    --secondary-color: #FFC107;
    --text-color: #333;
    --background-color: #f5f5f5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;  /* Safari 3+ */
    user-select: none;
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    overflow-x: hidden; /* 隐藏水平滚动条 */
}

.container {
    max-width: 100%;
    height: 100vh;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* 隐藏水平滚动条 */
    overflow-y: auto;   /* 保留垂直滚动条 */
}

header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

header h1 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

main {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow-x: hidden; /* 隐藏水平滚动条 */
    overflow-y: auto;   /* 保留垂直滚动条 */
}

.screen {
    display: none; /* 默认隐藏所有界面 */
    width: 100%;
    height: 100%;
}

/* 当界面激活时显示 */
.screen.active {
    display: flex !important;
}

/* 欢迎界面样式 */
#welcomeScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
}

#welcomeScreen h2 {
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    font-weight: 600;
    letter-spacing: 1px;
}

.welcome-content {
    max-width: 800px;
    width: 90%;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    margin: 20px auto;
}

#welcomeScreen ul {
    list-style: none;
    margin: 25px 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

#welcomeScreen li {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    color: var(--text-color);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    font-size: 16px;
}

#welcomeScreen li:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#welcomeScreen li::before {
    content: '•';
    color: var(--primary-color);
    font-size: 24px;
    margin-right: 10px;
}

.welcome-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.welcome-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.start-test-btn {
    background: var(--primary-color);
    color: white;
}

.start-test-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

.other-btn {
    background: #f8f9fa;
    color: var(--text-color);
    border: 1px solid #dee2e6;
}

.other-btn:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* 测试界面样式 */
#testScreen {
    flex-direction: column;
    height: 100%;
    background: var(--background-color);
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.test-header h2 {
    color: var(--primary-color);
    margin: 0;
}

.test-controls-buttons {
    display: flex;
    gap: 15px;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.control-btn:first-child {
    background-color: #f44336;
}

.control-btn:first-child:hover {
    background-color: #d32f2f;
}

.test-controls {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: 100%;
    padding: 20px;
    overflow: hidden;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.patient-info,
.test-options {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.patient-info h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.patient-info p {
    margin: 8px 0;
    line-height: 1.4;
    -webkit-user-select: text;  /* Safari 3+ */
    user-select: text;
}

.audiogram-container {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    height: 100%;
    overflow-x: hidden; /* 隐藏水平滚动条 */
    overflow-y: auto;   /* 保留垂直滚动条 */
}

.audiograms {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
    height: calc(100% - 80px);
}

.audiogram-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.audiogram-title-container {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.audiogram-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 按钮组样式优化 */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.button-group .primary-btn {
    margin: 0;
}

.test-type-buttons,
.masking-buttons,
.tone-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* 设置按钮组的固定宽度 */
.test-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 150px); /* 固定宽度为150px */
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.test-btn,
.masking-btn,
.tone-btn,
.ear-btn {
    padding: 8px 16px;
    border: 1px solid #2196F3;
    border-radius: 4px;
    background-color: white;
    color: #2196F3;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    white-space: nowrap;
    width: 80px;
    text-align: center;
}

/* 右侧按钮组样式 */
.masking-buttons button,
.tone-buttons button {
    width: 100px; /* 与骨导按钮对齐 */
}

.test-btn:hover,
.masking-btn:hover,
.tone-btn:hover,
.ear-btn:hover {
    background-color: rgba(33, 150, 243, 0.1);
}

.test-btn.active,
.ear-btn.active {
    background-color: #2196F3;
    color: white;
    border-color: #1976D2;
}

.test-btn.disabled,
.masking-btn.disabled,
.tone-btn.disabled,
.ear-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 当掩蔽打开时禁用不相关的测试类型 */
.test-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.ear-btn {
    background-color: white;
    color: #2196F3;
    border-color: #2196F3;
    position: relative;
}

.ear-btn::before {
    content: '👂';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.ear-btn[data-ear="left"]::before {
    transform: translateY(-50%) scaleX(-1);  /* 左耳图标水平翻转 */
}

.ear-btn.active {
    background-color: #2196F3;
    color: white;
}

/* 添加键盘操作提示 */
.keyboard-hints {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.keyboard-hints p {
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 10px;
}

.keyboard-hints ul {
    list-style: none;
    padding: 0;
}

.keyboard-hints li {
    margin: 8px 0;
    color: #666;
    font-size: 14px;
}

/* 当前位置指示器样式 */
.current-position {
    position: absolute;
    pointer-events: none;
    border: 2px solid rgba(33, 150, 243, 0.5);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    transition: all 0.2s ease;
}

.indicator-panel {
    height: 80px;
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 5px;
    border-top: 1px solid #eee;
    z-index: 100; /* 添加 z-index 确保在上层 */
}

.indicators-group {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex: 1;
    z-index: 100; /* 确保在上层 */
}

.indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative; /* 添加定位 */
}

.indicator-light {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ddd;
    border: 3px solid #999;
    transition: all 0.3s ease; /* 修改过渡效果 */
    position: relative;
    z-index: 10;
}

/* 修改给声指示灯激活样式 */
.indicator-light.tone-active {
    background-color: #F44336 !important; /* 添加 !important */
    border-color: #D32F2F !important;
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.5);
}

/* 修改应答指示灯激活样式 */
.indicator-light.active {
    background-color: #4CAF50 !important; /* 添加 !important */
    border-color: #388E3C !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

.indicator-label {
    font-size: 14px;
    color: #666;
    user-select: none;
}

/* 频率和分贝标签样式 */
.axis-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    border: 1px solid #ef9a9a;
}

/* 确保按钮样式正确 */
button {
    padding: 10px 20px;
    margin: 0 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #1976D2;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-btn:hover {
    background-color: #1976D2;
}

.end-test-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background-color: #f44336;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 20px;
    white-space: nowrap;
}

.end-test-btn:hover {
    background-color: #d32f2f;
}

.result-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 80%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1001;
    min-width: 300px;
    text-align: center;
}

.result-dialog h2 {
    color: #2196F3;
    margin-bottom: 15px;
}

.accuracy-score {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
    margin: 15px 0;
}

.error-list {
    margin: 15px 0;
    padding: 0;
    list-style: none;
}

.error-item {
    color: #f44336;
    margin: 8px 0;
    padding: 8px;
    background: #ffebee;
    border-radius: 4px;
}

/* 特殊按钮样式 */
.masking-btn {
    background-color: white;
    color: #2196F3;
    border-color: #2196F3;
    width: 80px; /* 固定宽度 */
}

.masking-btn.active {
    background-color: #2196F3;
    color: white;
    border-color: #1976D2;
}

.tone-btn {
    background-color: white;
    color: #4CAF50;
    border-color: #4CAF50;
    width: 80px; /* 固定宽度 */
}

.tone-btn.active {
    background-color: #4CAF50;
    color: white;
    border-color: #388E3C;
}

/* 按钮悬停效果 */
.masking-btn:hover {
    background-color: rgba(33, 150, 243, 0.1);
}

.tone-btn:hover {
    background-color: rgba(76, 175, 80, 0.1);
}

/* 调整按钮组的布局 */
.masking-buttons,
.tone-buttons {
    display: flex;
    justify-content: center;
}

/* 确保按钮在容器中居中 */
.test-type-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

/* 添加遮罩层 */
.result-dialog::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.result-dialog button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.result-dialog button:hover {
    background-color: #1976D2;
}

.error-message {
    color: #f44336;
    margin: 15px 0;
    padding: 10px;
    background-color: #ffebee;
    border-radius: 5px;
}

/* 允许特定元素可选择 */
.patient-info p,
.history-item p,
.tutorial-content {
    -webkit-user-select: text;  /* Safari 3+ */
    user-select: text;
}

/* 病人信息弹窗样式 */
.patient-info-dialog {
    max-width: 500px;
}

.patient-info-content {
    text-align: left;
    margin: 20px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.patient-info-content p {
    margin: 10px 0;
    line-height: 1.6;
    color: #333;
    -webkit-user-select: text;
    user-select: text;
}

.patient-info-content strong {
    color: #2196F3;
    margin-right: 8px;
}

.start-btn {
    background-color: #4CAF50 !important;
    margin-top: 20px;
    padding: 12px 30px !important;
    font-size: 16px;
}

.start-btn:hover {
    background-color: #388E3C !important;
}

.examination-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.examination-info p {
    margin: 5px 0;
}

.examination-info .indent {
    margin-left: 20px;
    color: #666;
}

.examination-info strong {
    color: #2196F3;
}

/* 调整病人信息面板的滚动 */
.patient-info {
    max-height: calc(100vh - 400px);
    overflow-y: auto;
}

/* 调整测试选项面板的大小 */
.test-options {
    flex-shrink: 0;
}

/* 确保内容不会溢出容器 */
main {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow-x: hidden; /* 隐藏水平滚动条 */
    overflow-y: auto;   /* 保留垂直滚动条 */
}

/* 调整指示灯面板的大小 */
.indicator-panel {
    height: 80px;
    flex-shrink: 0;
}

/* 诊断选择对话框样式 */
.diagnosis-dialog {
    max-width: 500px;
    width: 90%;
    height: auto;
    max-height: 90vh;
}

.diagnosis-steps {
    position: relative;
    min-height: 250px;
}

.diagnosis-step {
    display: none;
    position: absolute;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 10px 0;
}

.diagnosis-step h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.diagnosis-step.active {
    display: block;
    opacity: 1;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.prev-btn,
.next-btn,
.confirm-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.prev-btn {
    background-color: #9e9e9e;
    color: white;
}

.next-btn {
    background-color: #2196F3;
    color: white;
}

.confirm-btn {
    background-color: #4CAF50;
    color: white;
    margin-left: auto;
}

.prev-btn:hover { background-color: #757575; }
.next-btn:hover { background-color: #1976D2; }
.confirm-btn:hover { background-color: #388E3C; }

.diagnosis-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.diagnosis-option {
    padding: 15px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diagnosis-option:hover {
    background: #e3f2fd;
    border-color: #2196F3;
    transform: translateY(-2px);
}

.diagnosis-option:active {
    background: #2196F3;
    color: white;
    border-color: #1976D2;
    transform: translateY(0);
}

/* 完整结果显示样式 */
.complete-results {
    max-width: 600px;
    padding: 20px;
}

.score-section {
    margin: 20px 0;
}

.score-item {
    margin: 10px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
}

.final-score {
    margin: 20px 0;
    padding: 15px;
    background: #e3f2fd;
    border-radius: 5px;
    text-align: center;
}

.diagnosis-section {
    margin: 20px 0;
    padding: 15px;
    border-top: 1px solid #eee;
}

.close-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.close-btn:hover {
    background: #1976D2;
}

.score-details-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1000;
}

.score-details-content {
    margin-bottom: 20px;
}

.details-section {
    margin: 15px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 6px;
}

.details-section h3 {
    color: #1a237e;
    margin-bottom: 10px;
}

.deductions-list {
    list-style: none;
    padding: 0;
}

.deductions-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.deduction-count {
    color: #f44336;
    font-weight: bold;
}

.suggestions {
    margin-top: 10px;
    padding: 10px;
    background: #e8eaf6;
    border-radius: 4px;
}

.suggestions h4 {
    color: #283593;
    margin-bottom: 5px;
}

.suggestions ul {
    padding-left: 20px;
    color: #555;
}

.close-details-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #3949ab;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
}

.close-details-btn:hover {
    background: #303f9f;
}

/* 添加到 styles.css 文件中 */
.popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.results-popup {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.results-popup h3 {
    color: #2196F3;
    margin-bottom: 20px;
    font-size: 24px;
}

.results-popup p {
    font-size: 20px;
    margin: 20px 0;
    font-weight: bold;
}

.results-popup .primary-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
}

.results-popup .primary-btn:hover {
    background-color: #1976D2;
} 