* {
  margin: 0;
}

/* Canvas性能优化样式 */
.optimized-canvas {
  /* 启用硬件加速 */
  will-change: transform;
  transform: translateZ(0);
  
  /* 优化触摸事件 */
  touch-action: none;
  
  /* 减少重绘 */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  
  /* 平滑渲染 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* 优化合成层 */
  transform-style: preserve-3d;
  backface-visibility: hidden;
  perspective: 1000px;
  
  /* 确保canvas不会覆盖其他UI元素 */
  z-index: 1;
  position: relative;
}

/* 移动设备特定优化 */
@media (max-width: 768px) {
  .optimized-canvas {
    /* 在移动设备上进一步优化性能 */
    image-rendering: auto;
    
    /* 减少重绘区域 */
    contain: layout style paint;
  }
}

/* 高分辨率显示屏优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .optimized-canvas {
    /* 在高分辨率屏幕上启用更好的抗锯齿 */
    image-rendering: auto;
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* 主题变量 */
:root {
  --bg-color: #181818;
  --control-bg: #222222;
  --border-color: #404040;
  --input-bg: #3d3d3d;
  --text-color: #fff;
  --default-brush-color: #ffffff;
}

/* 亮色模式 */
body.light-mode {
  --bg-color: #f8f8f8;
  --control-bg: #ffffff;
  --border-color: #e0e0e0;
  --input-bg: #f0f0f0;
  --text-color: #333;
  --default-brush-color: #000000;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
#canvas-container {
  width: 100%;
  height: 100vh;
  position: relative;
  z-index: 0; /* 确保canvas容器在UI元素下方 */
}

.dt-control-container {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-top-right-radius: 8px;
  border-top-left-radius: 8px;
  border: 1px solid var(--border-color);
  border-bottom: 1px solid transparent;
  background: var(--control-bg);
  display: flex;
  align-items: center;
  padding: 10px 12px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000; /* 确保工具栏在最上层 */
}

/* 为所有模式增加透明度 */
.dt-control-container {
  background: rgba(34, 34, 34, 0.7);
  backdrop-filter: blur(2px);
}

/* 亮色模式下增强阴影效果 */
body.light-mode .dt-control-container {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15), 0 -1px 4px rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
}
.dt-dc-container {
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
}
.dt-default-colors {
  position: relative;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  border: solid 2px transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dt-default-colors div {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-sizing: border-box;
  box-shadow: none;
}


.hide {
  display: none;
}

.dt-tools-container {
  position: relative;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 3px;
}

/* 快捷键显示样式 */
.shortcut-key {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--text-color);
  color: var(--bg-color);
  font-size: 10px;
  font-weight: bold;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}

/* 快捷键按下效果 */
.shortcut-key.pressed {
  background: #ff6b6b;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.5);
}

/* 亮色模式下的快捷键样式 */
body.light-mode .shortcut-key {
  background: rgba(0, 0, 0, 0.4);
  color: var(--bg-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 亮色模式下的按下效果 */
body.light-mode .shortcut-key.pressed {
  background: #ff6b6b;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.5);
}

/* 颜色切换快捷键样式 */
.color-shortcut-key {
  position: absolute;
  background: #ffffffb0 !important;
  color: var(--bg-color) !important;
  font-size: 10px;
  font-weight: bold;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}



/* 左侧颜色切换快捷键位置 */
.color-shortcut-left {
  bottom: -3px;
  left: -3px;
}

/* 右侧颜色切换快捷键位置 */
.color-shortcut-right {
  bottom: -3px;
  right: -3px;
}



/* 亮色模式下的颜色切换快捷键样式 */
body.light-mode .color-shortcut-key {
  background: rgba(0, 0, 0, 0.4) !important;
  color: var(--bg-color) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 亮色模式下的颜色快捷键按下效果 - 提高优先级 */
body.light-mode .color-shortcut-key.pressed,
.color-shortcut-key.pressed {
  background: #4ecdc4 !important;
  color: white !important;
  transform: scale(1.1) !important;
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.5) !important;
}

/* 现代化扁平图标样式 */
.tool-icon {
  position: absolute;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  opacity: 0.8;
  background: transparent;
  border: none;
}

.tool-icon:hover {
  opacity: 1;
}

.tool-icon.selected {
  background: #6c6c6c;
}



/* SVG图标样式 */
.tool-svg {
  width: 20px;
  height: 20px;
  transition: all 0.3s ease;
}

/* 悬停时SVG图标放大效果 */
.tool-icon:hover .tool-svg,
.dt-download-container:hover .tool-svg,
.dt-fullscreen-container:hover .tool-svg {
  transform: scale(1.2);
}

/* undo和redo按钮的独立悬停效果 */
.dt-undo-redo-container img:hover {
  transform: scale(1.2);
}

/* 暗色模式下的SVG图标 */
.tool-svg {
  filter: invert(1) brightness(1);
}

/* 亮色模式下的SVG图标 */
body.light-mode .tool-svg {
  filter: invert(0) brightness(0.2);
}

/* 选中状态下的SVG图标颜色反转 */
.tool-icon.selected .tool-svg {
  filter: invert(0) brightness(1);
}

body.light-mode .tool-icon.selected .tool-svg {
  filter: invert(1) brightness(1);
}




/* 橡皮擦尺寸选择器 */
.eraser-size-container {
  display: flex;
  align-items: center;
  margin: 0 0.8rem;
  gap: 4px;
  width: 85px;
  justify-content: space-between;
}

.eraser-size-option {
  width: 26px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.eraser-size-option:hover {
  background: var(--border-color);
}

.eraser-size-option.selected {
  background: var(--text-color);
  color: var(--input-bg);
}

/* 画笔尺寸选择器 */
.brush-size-container {
  display: flex;
  align-items: center;
  margin: 0 0.8rem;
  gap: 4px;
  width: 85px;
  justify-content: space-between;
}

.brush-size-option {
  width: 26px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.brush-size-option:hover {
  background: var(--border-color);
}

.brush-size-option.selected {
  background: var(--text-color);
  color: var(--input-bg);
}

/* 形状工具尺寸选择器 */
.shape-size-container {
  display: flex;
  align-items: center;
  margin: 0 0.8rem;
  gap: 4px;
  width: 85px;
  justify-content: space-between;
}

.shape-size-option {
  width: 26px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.shape-size-option:hover {
  background: var(--border-color);
}

.shape-size-option.selected {
  background: var(--text-color);
  color: var(--input-bg);
}

/* 选框类型选择器样式 */
.selection-type-container {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  margin: 0 0.8rem;
  width: 85px;
}

.selection-type-option {
  width: 32px;
  height: 27.99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--input-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-color);
}

.selection-type-option:hover {
  background-color: #3a7bd5;
  border-color: #3a7bd5;
  color: white;
}

.selection-type-option.selected {
  background-color: var(--text-color);
  border-color: var(--text-color);
  color: white;
}

/* 清除确认拖动条 */
.clear-confirm-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 0.8rem;
  width: 85px;
  gap: 4px;
}

.clear-track {
  width: 100%;
  height: 28px;
  background: var(--input-bg);
  border-radius: 14px;
  position: relative;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.clear-slider {
  width: 28px;
  height: 26px;
  background: #ff4444;
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 1px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
  user-select: none;
}

.clear-slider:active {
  cursor: grabbing;
}

.clear-slider.animate-back {
  animation: slideBack 0.3s ease-out;
}

@keyframes slideBack {
  from {
    left: var(--slide-position);
  }
  to {
    left: 1px;
  }
}

.clear-hint {
  font-size: 10px;
  color: var(--text-color);
  opacity: 0.7;
  margin-left:16px;
  white-space: nowrap;
}

.dt-undo-redo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border-color);
  padding: 0 0.8rem;
  gap: 8px;
}

.dt-undo-redo-container img {
  width: 20px;
  cursor: pointer;
}
.dt-download-container {
  border-left: 1px solid var(--border-color);
  padding: 0 0.8rem;
}
.dt-download-container img {
  width: 20px;
  cursor: pointer;
}

.dt-fullscreen-container {
  border-left: 1px solid var(--border-color);
  padding: 0 0.8rem;
}
.dt-fullscreen-container img {
  width: 20px;
  cursor: pointer;
}

/* 亮色模式下的功能按钮 */
body.light-mode .dt-undo-redo-container img,
body.light-mode .dt-download-container img,
body.light-mode .dt-fullscreen-container img {
  filter: brightness(0.3);
}


/* 主题切换开关样式 */
.theme-toggle-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1001; /* 确保主题切换按钮在最上层 */
}

.theme-toggle {
  width: 60px;
  height: 30px;
  background: var(--border-color);
  border-radius: 15px;
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border-color);
}



.toggle-slider {
  width: 24px;
  height: 24px;
  background: var(--text-color);
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.light-mode .toggle-slider {
  transform: translateX(28px);
}





/* 添加颜色按钮样式 */
.dt-add-color {
  position: relative;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 8px;
}

.dt-add-color:hover {
  border-color: var(--text-color);
}

.dt-add-color div {
  color: var(--text-color);
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
}

/* 自定义颜色删除按钮 */
.dt-custom-color {
  position: relative;
}

.color-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  border: 1px solid var(--border-color);
}



.color-delete-btn::before {
  content: '×';
  color: var(--text-color);
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.dt-custom-color:hover .color-delete-btn {
  display: flex;
}

/* 亮色模式下删除按钮的背景 */
body.light-mode .color-delete-btn {
  background: rgba(0, 0, 0, 0.1);
  border-color: var(--border-color);
}

/* 隐藏颜色样式 */
.dt-default-colors.hidden {
  display: none;
}
