/* 右键菜单样式 */
.context-menu {
    position: fixed;  /* 改为 fixed，相对于视口定位，确保菜单显示在正确位置 */
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10000;  /* 提高 z-index，确保在最上层 */
    min-width: 120px;
    display: none;
}

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

.context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
}

.context-menu-item.context-menu-danger {
    color: #e74c3c;
}

.context-menu-item.context-menu-danger:hover {
    background-color: #fee;
}

.context-menu-separator {
    height: 1px;
    background-color: #e0e0e0;
    margin: 4px 0;
}

/* 拖拽状态指示器样式 */
.drag-status-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.drag-status-indicator.show {
    opacity: 1;
}

.drag-status-indicator.info {
    background: rgba(33, 150, 243, 0.9);
}

.drag-status-indicator.success {
    background: rgba(76, 175, 80, 0.9);
}

.drag-status-indicator.warning {
    background: rgba(255, 152, 0, 0.9);
}

.drag-status-indicator.error {
    background: rgba(244, 67, 54, 0.9);
}

/* 拖放样式 */
.drag-over {
    background-color: rgba(52, 152, 219, 0.1) !important;
    border: 2px dashed #3498db !important;
}

/* 移动端布局 */
.mobile-layout {
    flex-direction: column;
}

.mobile-layout #left-panel,
.mobile-layout #right-panel {
    display: none !important;
}

.mobile-layout #editor-container {
    width: 100% !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    #left-panel,
    #right-panel {
        display: none;
    }
    
    #editor-container {
        width: 100%;
    }
    
    .toolbar {
        flex-wrap: wrap;
        height: auto;
        padding: 5px;
    }
    
    .toolbar-group {
        margin: 2px;
    }
    
    .nav-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .bottom-controls {
        flex-wrap: wrap;
        height: auto;
        padding: 5px;
    }
    
    .page-controls {
        flex-wrap: wrap;
    }
    
    .layout-controls {
        margin-top: 5px;
    }
}

@media (max-width: 480px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-group {
        margin: 2px 0;
        justify-content: center;
    }
    
    .nav-btn {
        flex: 1;
        margin: 1px;
    }
    
    .bottom-controls {
        flex-direction: column;
    }
    
    .page-controls {
        justify-content: center;
        margin-bottom: 5px;
    }
    
    .layout-controls {
        justify-content: center;
    }
}

/* 打印样式 */
@media print {
    .toolbar,
    .bottom-controls,
    #left-panel,
    #right-panel,
    .nav-btn {
        display: none !important;
    }
    
    #editor-container {
        width: 100% !important;
        height: auto !important;
        border: none !important;
    }
    
    #editor-canvas {
        border: none !important;
        box-shadow: none !important;
    }
    
    .editable-element {
        border: none !important;
        box-shadow: none !important;
    }
    
    .editable-element.selected {
        outline: none !important;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes flipIn {
    from {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

@keyframes lightSpeedIn {
    from {
        opacity: 0;
        transform: translateX(100%) skewX(-30deg);
    }
    60% {
        opacity: 1;
        transform: skewX(20deg);
    }
    80% {
        transform: skewX(-5deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) skewX(0);
    }
}

/* 动画类 */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

.animate-zoom-in {
    animation: zoomIn 0.5s ease-out;
}

.animate-bounce-in {
    animation: bounceIn 0.8s ease-out;
}

.animate-rotate-in {
    animation: rotateIn 0.8s ease-out;
}

.animate-flip-in {
    animation: flipIn 0.8s ease-out;
}

.animate-light-speed-in {
    animation: lightSpeedIn 0.8s ease-out;
}

/* 页面过渡效果 */
.page-transition {
    position: relative;
    overflow: hidden;
}

.transition-left .editor-canvas {
    animation: slideOutLeft 0.3s ease-in-out;
}

.transition-right .editor-canvas {
    animation: slideOutRight 0.3s ease-in-out;
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 状态指示器 */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-indicator.success {
    background-color: #27ae60;
}

.status-indicator.warning {
    background-color: #f39c12;
}

.status-indicator.error {
    background-color: #e74c3c;
}

.status-indicator.info {
    background-color: #3498db;
}

/* 游戏树样式增强 */
.game-tree {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #fafafa;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.game-tree-node {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    border: 1px solid transparent;
    position: relative;
    user-select: none;
}

.game-tree-node:hover {
    background: #f0f7ff;
    border-color: #c6e0ff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-tree-node.active {
    background: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.3);
}

.game-tree-branch {
    margin: 4px 0;
    border-left: 2px solid #e0e0e0;
    padding-left: 10px;
    position: relative;
}

.game-tree-branch::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    width: 2px;
    height: 100%;
    background: #e0e0e0;
}

.game-tree-branch-header {
    display: flex;
    align-items: center;
    padding: 6px 0;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: color 0.2s ease;
}

.game-tree-branch-header:hover {
    color: #333;
}

.game-tree-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    margin-right: 8px;
    font-size: 12px;
    color: #666;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.game-tree-toggle:hover {
    background: #e0e0e0;
    color: #333;
}

.game-tree-toggle:focus {
    outline: none;
    background: #d0d0d0;
}

.toggle-icon {
    transition: transform 0.2s ease;
    font-size: 10px;
}

.game-tree-branch-content {
    margin-left: 28px;
    transition: all 0.3s ease;
}

.game-tree-branch-label {
    font-weight: 600;
    color: #666;
    padding: 4px 0;
    margin: 2px 0;
}

.branch-number {
    color: #999;
    font-size: 12px;
    font-weight: 500;
}

.move-number {
    font-weight: 600;
    color: #666;
    margin-right: 8px;
    font-size: 12px;
    min-width: 24px;
    text-align: right;
}

.move-color {
    margin-right: 8px;
    font-size: 16px;
}

.move-color.black {
    color: #333;
}

.move-color.white {
    color: #fff;
    text-shadow: 0 0 1px #333;
}

.move-coord {
    color: #555;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

/* 暗色主题下的游戏树样式 */
@media (prefers-color-scheme: dark) {
    .game-tree {
        background: #2d2d2d;
        color: #e0e0e0;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    }
    
    .game-tree-node {
        background: #3a3a3a;
        color: #e0e0e0;
    }
    
    .game-tree-node:hover {
        background: #4a4a4a;
        border-color: #555;
    }
    
    .game-tree-node.active {
        background: #2c5282;
        border-color: #3182ce;
    }
    
    .game-tree-branch {
        border-left-color: #444;
    }
    
    .game-tree-branch::before {
        background: #444;
    }
    
    .game-tree-branch-header {
        color: #aaa;
    }
    
    .game-tree-branch-header:hover {
        color: #e0e0e0;
    }
    
    .game-tree-toggle {
        color: #aaa;
    }
    
    .game-tree-toggle:hover {
        background: #444;
        color: #e0e0e0;
    }
    
    .game-tree-toggle:focus {
        background: #555;
    }
    
    .branch-number {
        color: #aaa;
    }
    
    .move-number {
        color: #aaa;
    }
    
    .move-coord {
        color: #ccc;
    }
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 4px;
    background-color: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: #3498db;
    transition: width 0.3s ease;
}

/* 消息提示样式增强 */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 300px;
}

.message {
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    animation: messageSlideIn 0.3s ease-out;
    border-left: 4px solid #3498db;
}

.message.success {
    border-left-color: #27ae60;
}

.message.error {
    border-left-color: #e74c3c;
}

.message.warning {
    border-left-color: #f39c12;
}

.message.info {
    border-left-color: #3498db;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-icon {
    margin-right: 10px;
    font-size: 16px;
}

.message-content {
    flex: 1;
    font-size: 14px;
}

.message-close {
    margin-left: 10px;
    cursor: pointer;
    font-size: 16px;
    color: #999;
}

.message-close:hover {
    color: #333;
}

/* 全屏模式样式 */
.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: white;
}

.fullscreen-mode .toolbar,
.fullscreen-mode .bottom-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.fullscreen-mode .bottom-controls {
    top: auto;
    bottom: 0;
}

.fullscreen-mode #left-panel,
.fullscreen-mode #right-panel {
    position: absolute;
    top: 50px;
    bottom: 50px;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.fullscreen-mode #left-panel {
    left: 0;
}

.fullscreen-mode #right-panel {
    right: 0;
}

.fullscreen-mode #editor-container {
    position: absolute;
    top: 50px;
    left: 250px;
    right: 250px;
    bottom: 50px;
    z-index: 9999;
}

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .toolbar,
    .bottom-controls {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .nav-btn {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .nav-btn:hover {
        background: #4a4a4a;
    }
    
    .nav-btn.active {
        background: #3498db;
    }
    
    #left-panel,
    #right-panel {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    #editor-container {
        background: #1a1a1a;
        border-color: #444;
    }
    
    #editor-canvas {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .chapter-item,
    .page-item {
        background: #3a3a3a;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .chapter-item:hover,
    .page-item:hover {
        background: #4a4a4a;
    }
    
    .chapter-item.active,
    .page-item.active {
        background: #3498db;
        color: white;
    }
    
    .modal-content {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .context-menu {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .context-menu-item {
        color: #e0e0e0;
        border-color: #444;
    }
    
    .context-menu-item:hover {
        background: #3a3a3a;
    }
    
    .message {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #555;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .nav-btn {
        border-width: 2px;
    }
    
    .editable-element.selected {
        outline-width: 3px;
        outline-color: #000;
    }
    
    .go-board {
        border-width: 3px;
        border-color: #000;
    }
    
    .go-board-line {
        stroke-width: 2;
        stroke: #000;
    }
    
    .go-board-star {
        fill: #000;
    }
    
    .go-stone-black {
        fill: #000;
        stroke: #fff;
        stroke-width: 2;
    }
    
    .go-stone-white {
        fill: #fff;
        stroke: #000;
        stroke-width: 2;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .message {
        animation: none;
    }
    
    .page-transition {
        animation: none;
    }
}