/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

/* 主容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 标题样式 - 修复重复定义，保留一个 */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #3498db;
    color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

/* 表格样式 */
.instruction-table {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.instruction-table h2 {
    color: #2c3e50;
    margin: 0;
    text-align: center;
    flex: 1;
}

.toggle-btn {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.toggle-btn:hover {
    background-color: #2980b9;
    transform: scale(1.1);
}

.toggle-btn:active {
    transform: scale(0.95);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    transition: max-height 0.3s ease-out;
}

.table-wrapper.collapsed {
    max-height: 0;
    overflow: hidden;
    margin-bottom: 0;
    padding-bottom: 0;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    transition: box-shadow 0.3s ease;
}

.table-wrapper:hover table {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #34495e;
    color: white;
    font-weight: bold;
}

/* 不同灯光操作类型的样式 */
.alternate { background-color: #ebf5fb; }
.alternate td:last-child {
    background-color: #e67e22;
    color: white;
    font-weight: bold;
}

.near { background-color: #f8f9f9; }
.near td:last-child {
    background-color: #27ae60;
    color: white;
    font-weight: bold;
}

.far { background-color: #fdebd0; }
.far td:last-child {
    background-color: #9b59b6;
    color: white;
    font-weight: bold;
}

.warning { background-color: #fcf3cf; }
.warning td:last-child {
    background-color: #e74c3c;
    color: white;
    font-weight: bold;
}

.highlight {
    font-weight: bold;
    color: #e74c3c;
}

/* 模拟练习区域 - 优先显示并加宽 */
.simulation-area {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    order: -1; /* 确保在移动设备上显示在最上面 */
}

.simulation-area h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.simulation-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 当前指令区域 */
.current-command {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 24px;
    border-radius: 8px;
    border-left: 5px solid #3498db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.current-command:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.current-command h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.command-text {
    font-size: 1.3em;
    font-weight: bold;
    color: #3498db;
    min-height: 60px;
    display: flex;
    align-items: center;
}

/* 灯光控制按钮 */
.light-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.light-btn {
    padding: 15px 10px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.light-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.light-btn:active {
    transform: translateY(0);
}

.alternate-btn {
    background-color: #e67e22;
    color: white;
}

.alternate-btn:hover {
    background-color: #d35400;
}

.near-btn {
    background-color: #27ae60;
    color: white;
}

.near-btn:hover {
    background-color: #229954;
}

.far-btn {
    background-color: #9b59b6;
    color: white;
}

.far-btn:hover {
    background-color: #8e44ad;
}

.warning-btn {
    background-color: #e74c3c;
    color: white;
}

.warning-btn:hover {
    background-color: #c0392b;
}

/* 模拟控制按钮 */
.mode-selection {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.mode-selection h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.2rem;
}

.mode-options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.mode-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.mode-option:hover {
    background-color: #e3f2fd;
}

.mode-option input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.group-selection {
    margin-top: 10px;
}

.group-selection h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #495057;
    font-size: 1rem;
}

#group-select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.auto-next-setting {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.auto-next-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
}

.auto-next-option input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
}

.delay-setting {
    margin-top: 10px;
    margin-left: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#delay-select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

#delay-select:hover {
    border-color: #3498db;
}

#group-select:hover:not(:disabled) {
    border-color: #3498db;
}

#group-select:disabled {
    background-color: #f1f3f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.simulation-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.control-btn {
    flex: 1;
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:not(:disabled) {
    background-color: #3498db;
    color: white;
    box-shadow: 0 3px 6px rgba(52, 152, 219, 0.3);
}

.control-btn:not(:disabled):hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(52, 152, 219, 0.4);
}

.control-btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.control-btn:disabled {
    background-color: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 结果显示区域 */
.result-display {
    background-color: #f8f9fa;
    padding: 15px;
    margin-top: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-display h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

#result-text {
    min-height: 40px;
    font-size: 1.1em;
    margin-bottom: 15px;
}

.correct {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
    animation: pulseCorrect 0.5s ease-in-out;
}

.wrong {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
    animation: pulseWrong 0.5s ease-in-out;
}

/* 结果动画 */
@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 4px 12px rgba(21, 87, 36, 0.2); }
    100% { transform: scale(1); }
}

@keyframes pulseWrong {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 4px 12px rgba(114, 28, 36, 0.2); }
    100% { transform: scale(1); }
}

.stats {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    color: #34495e;
}

/* 页脚样式 */
footer {
    text-align: center;
    padding: 20px;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px;
    margin-top: 30px;
}

/* 倒计时样式 */
.countdown-container {
    position: relative;
    margin-top: 15px;
    text-align: center;
}

.countdown {
    font-size: 3rem;
    font-weight: bold;
    color: #3498db;
    animation: countdownPulse 1s infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.countdown.warning {
    color: #e74c3c;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .instruction-table, .simulation-area {
        min-width: 100%;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .light-controls {
        grid-template-columns: 1fr;
    }
    
    .simulation-controls {
        grid-template-columns: 1fr;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
    
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 8px 10px;
    }
    
    /* 移动设备上表格默认折叠 */
    .instruction-table .table-wrapper {
        max-height: 0;
        overflow: hidden;
    }
    
    .instruction-table .table-wrapper:not(.collapsed) {
        max-height: 600px;
    }
    
    /* 移动设备上倒计时样式优化 */
    .countdown {
        font-size: 2.5rem;
    }
}