/* 鼓谱编辑器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: visible;
}

/* 标题栏 */
.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;
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
    color: white;
    font-size: 14px;
}

.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;
    max-width: 550px;
    width: 100%;
}

.repeat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.repeat-settings h3 {
    margin: 0;
    color: #495057;
}

.repeat-content {
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.repeat-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

.repeat-group-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-wrap: nowrap;
}

.repeat-group-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.repeat-group-row select {
    font-size: 12px;
    padding: 4px 6px;
}

.repeat-group-row input[type="number"] {
    font-size: 12px;
    padding: 4px 6px;
}

.repeat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.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-repeat-tag {
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 12px;
    color: #dc3545;
    font-weight: bold;
    z-index: 10;
}

.sticking-label {
    font-size: 12px;
    color: #dc3545;
    font-weight: normal;
    pointer-events: none;
}

/* 小节内部布局 - 水平排列 */
.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;
    width: 50px; /* 设置固定宽度，确保时间槽有足够空间显示两个音符 */
}

.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;
}

.beat-vertical-line.has-sub-line {
    box-shadow: 6px 0 0 #495057;
}

/* 音符位置 */
.note-position {
    position: absolute;
    z-index: 5;
    width: auto;
    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%);
    min-width: 22px;
    padding: 0 2px;
}

.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="advance"].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%;
}

/* 抢进音符位置（上端1/3处，往上移动30px） */
.note-position[data-note-type="advance"] {
    top: calc(10% - 30px);
}

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

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

/* 音符位置容器 */
.note-positions-container {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 更新音符位置样式以支持子时间槽 */
.note-position {
    position: absolute;
    z-index: 5;
    width: auto; /* 让JS设置的宽度生效 */
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    transform: translateX(-50%);
    padding: 0 5px;
}

/* 单个音符时的样式 */
.note-position[data-sub-slot-index="0"]:not(.has-sibling) {
    left: 50% !important;
    width: 22px !important;
    border-radius: 50%;
}

/* 中间竖线样式 */
.beat-vertical-line.middle-line {
    position: absolute;
    height: 100%;
    background: #666;
    width: 1px;
    left: 50%;
}

.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: 18px;
}

/* 小节线 */
.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: 18px;
    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: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-align: center;
    min-width: 60px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    white-space: nowrap;
}

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

.note-btn.selected {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

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

.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;
        max-width: 100%;
    }
    
    /* 在移动设备上重置布局 */
    .repeat-settings {
        float: none !important;
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 20px;
    }
    
    .note-palette {
        margin-left: 0 !important;
    }
    
    /* 确保音符按钮容器在移动设备上有足够宽度 */
    .note-palette {
        width: 100%;
    }
    
    /* 调整音符按钮大小，使其在移动设备上更合适 */
    .note-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* 针对更小屏幕的优化 */
@media (max-width: 480px) {
    /* 进一步调整音符按钮大小 */
    .note-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 50px;
    }
    
    /* 减少按钮之间的间距 */
    .note-buttons {
        gap: 8px;
    }
    
    /* 调整金贝音符工具的第二行顶部边距 */
    .note-buttons:nth-child(3) {
        margin-top: 8px !important;
    }
}

/* 加载动画 */
.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); }
}

/* 快捷键说明 */
.shortcuts-info {
    background: #f8f9fa;
    padding: 20px;
    border-top: 1px solid #dee2e6;
}

.shortcuts-info h4 {
    margin-bottom: 15px;
    color: #495057;
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcuts-list div {
    padding: 8px 12px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #007bff;
    font-size: 14px;
    color: #495057;
}

@media print {
    body { margin: 0; }
    #printContainer { display: block !important; }
    .container, #loadDialog, #saveDialog, #newDialog, #contextMenu { display: none !important; }
    .a4-page {
        width: 210mm;
        min-height: 297mm;
        padding: 10mm;
        box-sizing: border-box;
        page-break-after: always;
    }
    .export-header {
        text-align: center;
        margin-bottom: 8mm;
        font-weight: bold;
        color: #333;
    }
    .export-staff {
        margin-bottom: 6mm;
    }
    .export-section {
        margin-bottom: 6mm;
    }
    .export-staff-title {
        font-weight: bold;
        margin-bottom: 2mm;
        color: #333;
    }
    .export-measures-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4mm;
    }
    .a4-page .measure {
        width: auto !important;
    }
}

@page {
    size: A4 portrait;
    margin: 10mm;
}
