﻿/* 菜单弹层与控制 */
html,
body {
  overflow-x: hidden;
}

.menus {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 100; /* 默认较低，避免遮挡其它交互 */
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

/* 菜单激活时提升优先级，覆盖透明层等 */
.menus.active {
  z-index: 20020;
}

.hamburger {
  width: 48px;
  height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.36);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.hamburger:hover,
.hamburger:focus-visible,
.hamburger.active {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: #fff;
  margin: 2px 0;
  border-radius: 2px;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.menu-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.menu-backdrop[hidden] {
  display: none !important;
}

.menu-dropdown {
  position: fixed;
  left: 8px;
  min-width: 240px;
  max-width: 420px;
  padding: 16px 18px 18px;
  display: none;
  background: rgba(11, 15, 20, 0.98);
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55);
  z-index: 10001;
  box-sizing: border-box;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  overflow-x: hidden;
}

.menu-dropdown.show {
  display: block;
}

.menu-dropdown[hidden] {
  display: none !important;
}

.menu-dropdown,
.menu-dropdown * {
  box-sizing: border-box;
  color: #fff;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.menu-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.menu-close {
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.menu-close:hover,
.menu-close:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

.menu-section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-group,
.menu-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.menu-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease;
}

.menu-group-toggle::after {
  content: "▾";
  font-size: 12px;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.menu-group.open .menu-group-toggle {
  background: rgba(255, 255, 255, 0.08);
}

.menu-group.open .menu-group-toggle::after {
  transform: rotate(-180deg);
}

.menu-group .group-content {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.menu-group .group-content[hidden] {
  display: none !important;
}

.menu-action {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.menu-action:hover,
.menu-action:focus-visible {
  background: rgba(255, 255, 255, 0.14);
}

.menu-dropdown .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: center;
}

.menu-dropdown .row.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.menu-dropdown .label {
  font-size: 12px;
  color: #cfd8dc;
  margin-right: 6px;
}

.menu-dropdown select,
.menu-dropdown button,
.menu-dropdown input[type=file] {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

/* 桌面端文件上传输入框优化 */
.menu-dropdown input[type=file] {
  width: 100%;
  min-height: 36px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.menu-dropdown input[type=file]:hover,
.menu-dropdown input[type=file]:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.menu-dropdown button:not(.menu-group-toggle):not(.menu-action):not(.menu-close) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-dropdown select {
  padding-right: 26px;
}

.menu-dropdown option {
  color: #111;
  background: #fff;
}

.menu-dropdown select:focus,
.menu-dropdown button:focus,
.menu-dropdown input[type=file]:focus {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.menu-dropdown .row > * {
  width: 100%;
}

.menu-dropdown [hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .menu-dropdown {
    left: 8px;
    right: 8px;
    bottom: auto;
    top: 64px;
    min-width: unset;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 112px);
    border-radius: 16px;
    padding: 18px 18px 22px;
  }

  .menu-section-list {
    gap: 16px;
  }

  .menu-group,
  .menu-item {
    border-radius: 14px;
  }

  .menu-group-toggle,
  .menu-action {
    font-size: 16px;
    padding: 14px 18px;
  }

  .menu-dropdown select,
  .menu-dropdown button,
  .menu-dropdown input[type=file] {
    font-size: 15px;
    padding: 10px 12px;
  }

  /* 手机端文件上传输入框特殊优化 */
  .menu-dropdown input[type=file] {
    width: 100%;
    min-height: 44px; /* 触摸友好的最小高度 */
    font-size: 16px; /* 增大字体便于触摸 */
    padding: 12px 14px; /* 增加内边距 */
    border: 2px solid rgba(255, 255, 255, 0.2); /* 更明显的边框 */
    background: rgba(255, 255, 255, 0.1); /* 更明显的背景 */
    border-radius: 8px; /* 圆角 */
    cursor: pointer; /* 手型光标 */
    transition: all 0.2s ease; /* 过渡动画 */
  }

  .menu-dropdown input[type=file]:hover,
  .menu-dropdown input[type=file]:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: 2px;
  }

  /* 确保文件上传输入框在菜单组内有正确的布局 */
  .menu-group .group-content input[type=file] {
    margin: 0;
    display: block;
  }

  .menu-dropdown .row {
    gap: 10px;
  }
}
