/* 鼓谱编辑器Web版样式 */

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* 标题栏 */
.header {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    margin: 0;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.controls input[type="text"],
.controls input[type="number"] {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    background: rgba(255,255,255,0.9);
    color: #333;
    font-size: 14px;
}

.controls label {
    color: white;
    font-weight: bold;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

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

.btn-primary { background: #007bff; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-warning { background: #ffc107; color: #333; }
.btn-info { background: #17a2b8; color: white; }
.btn-small { padding: 4px 8px; font-size: 12px; }

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 160px;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    transform: rotate(-90deg);
}
.volume-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.volume-label {
    font-size: 12px;
    color: #333;
}

/* 重复记号设置 */
.repeat-settings {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

.repeat-settings h3 {
    margin-bottom: 10px;
    color: #495057;
}

.repeat-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.repeat-controls select {
    padding: 5px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
}

/* 鼓谱编辑区域 */
.score-editor {
    padding: 20px;
    min-height: 400px;
}

.staffs-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 声部样式 */
.staff {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.staff-sidebar {
    width: 76px;
    border-right: 1px solid #dee2e6;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px;
    overflow: visible;
    position: relative;
}

.staff-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #333;
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: none;
}
.staff-name-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.staff-name-char {
    display: block;
    font-size: 12px;
    line-height: 1.1;
}

.hide-btn {
    margin-top: 4px;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #f8f9fa;
    cursor: pointer;
}

.volume-slider-side {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    transform: translateY(-50%) rotate(-90deg);
    position: absolute;
    top: 50%;
    left: 20px;
}

.measure-count {
    font-size: 12px;
    opacity: 0.9;
}

/* 小节网格 */
.measures-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px;
    background: white;
}

.measure {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    position: relative;
    min-height: 80px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.measure:hover {
    border-color: #007bff;
    box-shadow: 0 0 10px rgba(0,123,255,0.3);
}

.measure.selected {
    border-color: #007bff;
    background: #e7f3ff;
}

.measure-number {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 12px;
    color: #6c757d;
    font-weight: bold;
    z-index: 10;
}

/* 小节内部布局 - 水平排列 */
.measure-content {
    padding: 8px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}

/* 拍子容器 - 改为水平排列 */
.beats {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 2px;
    height: 100%;
    align-items: center;
}

/* 时间槽 */
.time-slot {
    border: 1px dashed #ced4da;
    border-radius: 4px;
    margin: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
    min-height: 12px;
}

.time-slot:hover {
    background: rgba(0,123,255,0.1);
    border-color: #007bff;
}

.time-slot.empty {
    background: transparent;
}

.time-slot.has-note {
    background: rgba(255,107,107,0.1);
    border-color: #ff6b6b;
}

/* 单个拍子 - 水平排列 */
.beat {
    position: relative;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0%;
    min-width: 52px;
    margin: 0 2px;
}

/* 横线连接所有竖线 */
.beat-line {
    position: absolute;
    top: 20%;
    left: 5%;
    right: 5%;
    height: 2px;
    background: #495057;
}

/* 四根竖线 */
.beat-lines {
    position: absolute;
    top: 20%;
    bottom: 20%;
    left: 5%;
    right: 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.beat-vertical-line {
    position: relative;
    width: 1px;
    height: 100%;
    background: #495057;
}

/* 音符位置 */
.note-position {
    position: absolute;
    z-index: 5;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    left: 50%;
    transform: translateX(-50%);
}

.note-position:hover {
    background: rgba(0,123,255,0.1);
    transform: translateX(-50%) scale(1.1);
}

.note-position.has-note {
    background: rgba(255,107,107,0.1);
    border: 2px solid #ff6b6b;
}
.note-position[data-note-type="t"].has-note {
    background: transparent;
    border: none;
}
.note-position[data-note-type="d"].has-note,
.note-position[data-note-type="ox"].has-note,
.note-position[data-note-type="B"].has-note,
.note-position[data-note-type="O"].has-note,
.note-position[data-note-type="X"].has-note,
.note-position[data-note-type="O2"].has-note,
.note-position[data-note-type="X2"].has-note,
.note-position[data-note-type="xX"].has-note,
.note-position[data-note-type="xB"].has-note,
.note-position[data-note-type="bX"].has-note,
.note-position[data-note-type="OO"].has-note,
.note-position[data-note-type="OO2"].has-note,
.note-position[data-note-type="XX"].has-note,
.note-position[data-note-type="XX2"].has-note {
    background: transparent;
    border: none;
}

/* 牛铃音符位置（上端1/3处） */
.note-position[data-note-type="t"] {
    top: 10%;
}

/* 击鼓和制鼓音符位置（下端根部） - 适用于除牛铃(t)以外的所有音符 */
.note-position:not([data-note-type="t"]) {
    bottom: -15px;
}

.note-symbol {
    font-size: 18px;
    font-weight: bold;
    color: #495057;
    white-space: nowrap;
}

.note-symbol.drum-t { color: #ff6b6b; }
.note-symbol.drum-d { color: #4ecdc4; }
.note-symbol.drum-ox { color: #45b7d1; }

/* 敦敦鼓组击鼓音符(d)放大 */
.note-position[data-note-type="d"] .note-symbol {
    font-size: 24px;
}

/* 小节线 */
.measure-divider {
    position: absolute;
    top: 10%;
    bottom: 10%;
    width: 3px;
    background: #495057;
    z-index: 5;
}

.measure-divider.start {
    left: -2px;
}

.measure-divider.end {
    right: -2px;
}

/* 播放状态 */
.time-slot.current {
    background: #28a745;
    color: white;
    border-color: #28a745;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.note-symbol {
    font-size: 16px;
    font-weight: bold;
    color: #495057;
    transition: all 0.3s ease;
}

.note-symbol.drum-t { color: #ff6b6b; }
.note-symbol.drum-d { color: #4ecdc4; }
.note-symbol.drum-ox { color: #45b7d1; }

/* 播放状态 */
.playback-status {
    background: #f8f9fa;
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 30px;
    align-items: center;
}

.playback-status div {
    font-weight: bold;
    color: #495057;
}

/* 音符工具面板 */
.note-palette {
    background: #f8f9fa;
    padding: 20px;
    border-top: 1px solid #dee2e6;
}

.note-palette h3 {
    margin-bottom: 15px;
    color: #495057;
}

.note-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.note-btn {
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-align: center;
    min-width: 80px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.note-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.note-btn.selected {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.note-btn small {
    display: block;
    font-size: 10px;
    opacity: 0.9;
    margin-top: 5px;
}

.clear-btn {
    background: #6c757d !important;
}

/* 调试信息 */
.debug-info {
    background: #f8f9fa;
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    max-height: 200px;
    overflow-y: auto;
}

.debug-info h4 {
    color: #dc3545;
    margin-bottom: 10px;
}

.debug-info pre {
    background: #f1f3f4;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    color: #495057;
    white-space: pre-wrap;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    min-width: 300px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #495057;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

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

.score-item {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.score-item:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.score-item.selected {
    background: #e7f3ff;
    border-color: #007bff;
}

.score-item-title {
    font-weight: bold;
    color: #495057;
}

.score-item-meta {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .controls {
        justify-content: center;
    }
    
    .repeat-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .measures-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .playback-status {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .note-buttons {
        justify-content: center;
    }
}

/* 加载动画 */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #007bff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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