/* =========================================
   MidiTOY V5.0 主样式表 (全量清理版)
   ========================================= */
/* 1. 注册本地字体 */
@font-face {
    font-family: 'Comfortaa';
    src: url('/static/Comfortaa.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-color: #ff9800;
    --border-color: #333;
    --highlight-color: #2c2c2c;
    --beat-bg: #2a2a2a;
}

/* 1. 基础全局修正 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    padding-bottom: 220px;
    /* 给底部调音台留空间 */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === 顶部工具栏 === */
.toolbar {
    background: #252525;
    /* 原来的 padding: 15px 20px; 改为下面这样，增加垂直空间 */
    padding: 12px 25px;
    padding-left: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #333;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    /* 加一点阴影更有质感 */
    /* 确保工具栏有足够的高度容纳 LOGO */
    min-height: 80px;
    box-sizing: border-box;
    /* 确保 padding 不会撑破高度 */
}

.toolbar-logo {
    height: 55px;
    /* 根据需要微调高度 */
    width: auto;

    /* 🔴 核心修改 1：消除 LOGO 左右多余的边距 */
    margin-left: 0;
    margin-right: 5px;
    /* 原来可能是 15px 或 20px，现在改小 */

    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.toolbar-logo:hover {
    transform: scale(1.1);
    /* 放大倍数 */
    filter: drop-shadow(0 0 8px rgba(0, 234, 255, 0.6));
}

.toolbar h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent-color);
    margin-right: 20px;
}

.version-tag {
    font-size: 0.7rem;
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    vertical-align: middle;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 0.9rem;
    color: #888;
}

/* 通用交互组件 (按钮/输入/选择) */
button {
    background: #333;
    border: 1px solid #444;
    color: #eee;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

button:hover {
    background: #444;
    border-color: #666;
}

button.primary {
    background: var(--accent-color);
    color: #000;
    border: none;
    font-weight: bold;
}

button.primary:hover {
    background: #f57c00;
}

input,
select {
    background: #222;
    border: 1px solid #444;
    color: #eee;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

input:focus,
select:focus {
    outline: 1px solid var(--accent-color);
    border-color: var(--accent-color);
}

/* === 网格区域 === */
.bar-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    align-content: start;
}

.bar-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.bar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: #555;
}

.bar-card.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px var(--accent-color);
}

/* 段落颜色主题 */
.bar-card.theme-verse {
    border-left: 4px solid #4caf50;
}

.bar-card.theme-chorus {
    border-left: 4px solid #f44336;
}

.bar-card.theme-intro {
    border-left: 4px solid #9c27b0;
}

.bar-card.theme-outro {
    border-left: 4px solid #607d8b;
}

.bar-card.theme-fill {
    border-left: 4px solid #ffeb3b;
}

.seg-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #888;
}

/* 小节红色删除圆点 */
.bar-card .delete-btn {
    position: absolute;
    top: -10px !important;
    right: -10px !important;
    width: 22px !important;
    height: 22px !important;
    background: #d32f2f !important;
    color: white !important;
    border: 2px solid var(--bg-color) !important;
    border-radius: 50% !important;
    font-size: 14px !important;
    line-height: 18px !important;
    text-align: center !important;
    padding: 0 !important;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
    transition: opacity 0.2s ease-in-out, transform 0.2s !important;
}

.bar-card:hover .delete-btn {
    opacity: 1;
    pointer-events: auto;
}

.bar-card .delete-btn:hover {
    background: #f44336 !important;
    transform: scale(1.1);
}

/* === 拍子容器与输入 === */
.beat-container {
    display: grid;
    gap: 5px;
    width: 100%;
}

.beat-box {
    background: var(--beat-bg);
    border-radius: 4px;
    position: relative;
    height: 40px;
    min-width: 0;
    overflow: visible !important;
    /* 确保删除红点不被遮挡 */
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.beat-box.active {
    background: #3d3d3d;
    border: 1px solid var(--accent-color);
}

.beat-box:hover {
    border-color: #555;
}

.beat-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: #fff;
    text-align: center !important;
    font-family: 'Segoe UI', 'Roboto', sans-serif !important;
    font-weight: bold !important;
    font-size: 1.0rem !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0;
}

.beat-delete-btn {
    position: absolute;
    top: -6px !important;
    right: -6px !important;
    width: 16px !important;
    height: 16px !important;
    background: #f44336;
    color: white;
    border-radius: 50%;
    font-size: 12px !important;
    line-height: 16px !important;
    text-align: center;
    cursor: pointer;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.beat-box:hover .beat-delete-btn {
    opacity: 1;
}

/* === 和弦选择器 (Picker) === */
#chordPicker {
    position: absolute;
    background: #252525;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 10px;
    z-index: 1000;
    display: none;
    width: 280px;
}

.picker-section {
    margin-bottom: 10px;
}

.picker-label {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 5px;
}

.grid-12 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.cp-btn {
    background: #333;
    color: #eee;
    border: 1px solid #444;
    text-align: center;
    padding: 6px 2px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 3px;
}

.cp-btn:hover {
    background: #444;
    border-color: #666;
}

.cp-btn.active {
    background: var(--accent-color);
    color: #000;
    font-weight: bold;
}

.cp-btn.special {
    background: #00796b;
    color: white;
}

.slash-menu {
    display: none;
    grid-column: 1 / -1;
    background: #1a1a1a;
    border: 1px solid #444;
    margin-top: 5px;
    padding: 5px;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
}

.slash-menu.show {
    display: grid;
}

/* === 🎚️ 底部调音台 (Mixer Dock) === */
.mixer-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 190px;
    background: #181818;
    border-top: 1px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 15px;
    z-index: 999;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.8);
}

.channel-strip {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    height: 100%;
    position: relative;
}

.channel-label {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 5px;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.vol-val {
    font-family: 'Consolas', monospace !important;
    font-size: 11px !important;
    text-align: center;
    display: block;
}

.fader-track {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 110px;
    position: relative;
}

input[type=range].fader {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
    transform: rotate(-90deg);
    cursor: pointer;
}

input[type=range].fader::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 28px;
    background: #e0e0e0;
    border-radius: 3px;
    border: 1px solid #fff;
}

.mute-btn {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.mute-btn.active {
    background: #d32f2f !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

/* === ⏳ 加载遮罩与进度条 (核心功能区) === */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.loading-content {
    background: rgba(20, 20, 20, 0.95);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #444;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.progress-container {
    width: 350px;
    height: 10px;
    background: #1a1a1a;
    border-radius: 5px;
    margin: 20px 0;
    overflow: hidden;
    border: 1px solid #333;
}

#progressBar {
    width: 0%;
    /* JS 动态控制 */
    height: 100%;
    background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.7);
    transition: width 0.3s ease;
}

#loaderText {
    color: #eee;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
}

#loaderDetail {
    color: #888;
    font-size: 13px;
    font-family: monospace;
}

@media (max-width: 768px) {

    /* 1. 强制每行只显示 4 拍，多出来的自动换行 */
    .beat-container {
        /* !important 是为了压制 JS 写入的内联样式 */
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    /* 2. 增加格子高度，方便手指点击 */
    .beat-box {
        height: 55px !important;
    }

    /* 3. 字体稍微缩小，防止和弦名（如 Cmaj7/G）溢出 */
    .beat-input {
        font-size: 0.85rem !important;
    }

    /* 4. 网格整体布局微调，左右留白 */
    .bar-grid {
        padding: 10px;
        grid-template-columns: 1fr !important;
        /* 手机上一行只显示一个小节卡片 */
    }
}

@media (max-width: 600px) {

    /* 1. 强制一行只显示 1 个小节卡片，不再并排 */
    .bar-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        padding: 10px !important;
        gap: 15px !important;
    }

    /* 2. 让每个卡片占满宽度 */
    .bar-card {
        width: 100% !important;
        margin: 0 auto !important;
    }

    /* 3. 强制每行只显示 4 拍，解决“牙签格子” */
    .beat-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }

    /* 4. 增加格子高度，方便触控 */
    .beat-box {
        height: 55px !important;
    }

    /* 5. 调整字体，确保 Cmaj7 这种长名字不溢出 */
    .beat-input {
        font-size: 0.9rem !important;
    }

    /* 6. 额外优化：隐藏不重要的修饰元素，节省空间 */
    .toolbar h3 {
        font-size: 1rem;
    }


}

/* === 侧边栏样式 === */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: #1e1e1e;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.7);
    z-index: 2001;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #252525;
}

.sidebar-menu {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-item {
    background: #2a2a2a;
    color: #eee;
    border: 1px solid #333;
    padding: 12px 15px;
    text-align: left;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 1rem;
}

.menu-item:hover {
    background: #333;
    border-color: #555;
    transform: translateX(5px);
}

/* === 文件列表弹窗 === */
.file-modal-box {
    width: 450px;
    max-width: 90%;
    text-align: left !important;
}

.file-list-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 4px;
    background: #111;
}

.file-item {
    padding: 12px;
    border-bottom: 1px solid #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.file-item:hover {
    background: #1f1f1f;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-name {
    font-weight: bold;
    color: #eee;
}

.file-tag {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.tag-official {
    background: #333;
    color: #888;
}

.tag-user {
    background: #00695c;
    color: #fff;
}

.file-actions {
    display: flex;
    gap: 5px;
}

.icon-btn-sm {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    padding: 4px;
}

.icon-btn-sm:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* 官方预设样式微调 */
.file-item.official .file-name {
    color: #aaa;
}

.file-item.official:hover {
    background: #181818;
}