/**
 * 底部快捷栏样式
 */
.dock-container {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9500;
    /* 低于 Modal(10000) */
    /* 关键修复：容器本身不拦截点击，让底层的最大化窗口可以接收点击事件 */
    pointer-events: none;
}

.dock {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;

    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);

    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.15),
        0 10px 20px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);

    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* 关键修复：实际的 dock 栏拦截点击 */
    pointer-events: auto;
}

.dock.auto-hide {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* JavaScript 控制的显示状态 */
.dock.auto-hide.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.dock-item {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.dock-item:hover {
    transform: scale(1.15) translateY(-8px);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.dock-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.dock-icon-wrapper i {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.dock-icon-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* 激活指示圆点 */
.dock-item.active::after,
.dock-folder.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

/* 提示框 */
.dock-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dock-item:hover .dock-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* 分隔符 */
.dock-separator {
    width: 1px;
    height: 42px;
    background: linear-gradient(to bottom,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    flex-shrink: 0;
}

/* ===== 文件夹样式 ===== */
.dock-folder {
    position: relative;
}

.dock-folder .dock-folder-trigger {
    position: relative;
}

/* 文件夹打开时的视觉反馈 */
.dock-folder.open .dock-folder-trigger {
    transform: scale(1.1) translateY(-4px);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ===== 弹出菜单 ===== */
.dock-folder-popup {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);

    min-width: 200px;
    max-width: 320px;

    background: rgba(30, 30, 32, 0.85);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);

    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;

    padding: 12px;

    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.4),
        0 10px 20px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 3000;
}

/* 弹出箭头 */
.dock-folder-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: rgba(30, 30, 32, 0.85);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transform: translateX(-50%) rotate(45deg);
}

.dock-folder-popup.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.folder-popup-header {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.folder-popup-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.folder-app-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: rgba(255, 255, 255, 0.9);
}

.folder-app-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.folder-app-item.active {
    background: rgba(59, 130, 246, 0.3);
}

.folder-app-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.folder-app-title {
    font-size: 13px;
    font-weight: 500;
}

/* ===== 子分组样式 (系统管理等) ===== */
.dock-folder-popup.has-subgroups {
    min-width: 280px;
    max-width: 400px;
}

.folder-subgroup {
    margin-bottom: 12px;
}

.folder-subgroup:last-child {
    margin-bottom: 0;
}

.folder-subgroup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 6px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.subgroup-icon {
    font-size: 14px;
}

.subgroup-title {
    flex: 1;
}

.folder-subgroup-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 浅色主题 Dock 覆盖 */
:root.theme-sunrise .dock {
    /* 增加不透明度，使用混合模式 */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(240, 240, 245, 0.5) 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.15),
        0 10px 20px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

:root.theme-sunrise .dock-item {
    background: rgba(0, 0, 0, 0.02);
}

:root.theme-sunrise .dock-item:hover {
    background: rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

:root.theme-sunrise .dock-separator {
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.15), transparent);
}

/* 浅色模式激活圆点 */
:root.theme-sunrise .dock-item.active::after,
:root.theme-sunrise .dock-folder.active::after {
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}

/* 浅色模式文件夹弹出层 */
:root.theme-sunrise .dock-folder-popup {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.15),
        0 10px 20px rgba(0, 0, 0, 0.08);
}

:root.theme-sunrise .dock-folder-popup::after {
    background: rgba(255, 255, 255, 0.85);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

:root.theme-sunrise .folder-app-item {
    color: rgba(0, 0, 0, 0.85);
}

:root.theme-sunrise .folder-app-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

:root.theme-sunrise .folder-subgroup-header {
    color: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* ===== 移动端适配 (Responsive) ===== */
@media (max-width: 768px) {
    .dock-container {
        bottom: 8px;
        width: 95%;
        /* 稍微留边 */

        /* 关键修复：移除 transform 以确保子元素的 position: fixed 能够相对于视口定位 */
        left: 2.5%;
        /* (100% - 95%) / 2 */
        transform: none;
    }

    .dock {
        position: relative;
        /* 为伪元素定位 */

        padding: 8px 12px;
        gap: 8px;

        justify-content: center;
        /* 图标少时居中 */
        flex-wrap: nowrap;
        /* 不换行 */

        /* 如果图标太多，允许横向滚动（类似iPad） */
        overflow-x: auto;
        justify-content: flex-start;
        /* 滚动时左对齐 */
        width: 100%;

        /* 隐藏滚动条 */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;

        /* 核心修复：将背景和滤镜移至伪元素，防止父级 transform/filter 锁住 fixed 子元素 */
        transform: none !important;
        perspective: none !important;
        /* 如果之前存在且未明确移除，则保留 */
        filter: none !important;
        /* 如果之前存在且未明确移除，则保留 */
        background: transparent !important;
        backdrop-filter: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* 使用伪元素重建毛玻璃背景 */
    .dock::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: 20px;

        /* 毛玻璃效果 */
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);

        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow:
            0 10px 30px rgba(0, 0, 0, 0.1),
            inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    }

    .dock-folder {
        /* 确保父元素没有 transform */
        transform: none !important;
        position: static;
        /* 尝试 static 让 fixed 逃逸? 不，fixed 忽略 relative。主要是 transform */
    }

    .dock::-webkit-scrollbar {
        display: none;
    }

    .dock-item {
        width: 48px;
        height: 48px;
        min-width: 48px;
        /* 只有在滚动时需要 */
        border-radius: 10px;
    }

    .dock-icon {
        font-size: 24px;
    }

    .dock-item:hover {
        /* 移动端移除悬停放大，或者减小幅度 */
        transform: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
    }

    /* 文件夹弹出菜单适配 - 移动端全屏居中或底部动作面板模式 */
    .dock-folder-popup {
        position: fixed;
        /* 脱离父元素定位 */
        bottom: 80px;
        /* Dock 栏上方 */
        left: 50%;
        transform: translateX(-50%) !important;
        /* 强制水平居中 */

        width: 280px;
        max-width: 90vw;
        max-height: 60vh;
        overflow-y: auto;

        z-index: 3000;

        /* 移动端增强阴影 */
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }

    /* 移动端隐藏弹出菜单的小箭头，因为位置不再对齐图标 */
    .dock-folder-popup::after {
        display: none;
    }

    /* 显示时的动画 */
    .dock-folder-popup.show {
        transform: translateX(-50%) translateY(0) scale(1) !important;
        opacity: 1;
        visibility: visible;
    }

    /* 初始隐藏状态调整 */
    .dock-folder-popup:not(.show) {
        transform: translateX(-50%) translateY(20px) scale(0.9) !important;
    }
}