/* 新的现代 UI 样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f172a;
    color: #f8fafc;
    overflow: hidden;
    height: 100vh;
}

/* CSS变量 - 主题色 */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --accent-color: #f43f5e;
    --accent-hover: #e11d48;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* 主容器 */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    gap: 1px;
    background: var(--border);
}

/* 左侧工具栏 */
.toolbar {
    width: 220px;
    background: var(--surface);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-lg);
}

/* 工具栏标题 */
.toolbar-title {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.toolbar-title div {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 4px;
}

/* 工具区域 */
.tool-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tool-section h4 {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

/* 工具按钮 */
.tool-btn {
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.tool-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

/* 楼层管理 */
.layer-section {
    background: rgba(59, 130, 246, 0.05);
    border-radius: var(--border-radius);
    padding: 12px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.layer-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition);
    text-align: center;
}

.layer-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.layer-list {
    max-height: none;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 6px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
    gap: 4px;
    min-height: 32px;
}

.layer-item:hover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.layer-item.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.layer-name {
    flex: 1;
    cursor: text;
    outline: none;
    min-width: 80px;
    font-weight: 500;
}

.layer-name:focus {
    background: var(--background);
    border-radius: 4px;
    padding: 4px 8px;
}

.layer-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.layer-up,
.layer-down,
.layer-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

.layer-up:hover,
.layer-down:hover {
    background: var(--primary-color);
    color: white;
}

.layer-delete:hover {
    background: var(--accent-color);
    color: white;
}

/* 实战模式开关 */
.combat-mode-toggle {
    background: rgba(244, 63, 94, 0.05);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.combat-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--accent-color);
    cursor: pointer;
    font-weight: 600;
}

.combat-mode-toggle input[type="checkbox"] {
    accent-color: var(--accent-color);
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.combat-hint {
    font-size: 12px;
    opacity: 0.7;
    font-weight: normal;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 智能对齐开关 */
.align-toggle {
    background: rgba(16, 185, 129, 0.05);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.align-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--secondary-color);
    cursor: pointer;
    font-weight: 500;
}

.align-toggle input[type="checkbox"] {
    accent-color: var(--secondary-color);
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* 遮挡物工具组合框 */
.obstacle-tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.obstacle-shape-select {
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.obstacle-shape-select:hover {
    border-color: var(--primary-color);
}

/* 主画布区域 */
.canvas-container {
    flex: 1;
    position: relative;
    background: var(--background);
    overflow: hidden;
}

#tacticalCanvas {
    display: block;
    cursor: crosshair;
}

/* 坐标显示 */
.coordinates {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(30, 41, 59, 0.9);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    font-size: 13px;
    color: var(--primary-color);
    border: 1px solid var(--border);
    font-family: monospace;
    box-shadow: var(--shadow);
}

/* 对齐提示 */
.snap-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(59, 130, 246, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    animation: fadeInOut 1.5s ease-in-out;
    z-index: 100;
    box-shadow: var(--shadow);
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 实战模式提示 */
.mode-indicator {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(244, 63, 94, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    animation: modePulse 2s ease-in-out infinite;
    box-shadow: var(--shadow);
}

@keyframes modePulse {
    0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* 右侧属性面板 */
.properties-panel {
    width: 300px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}

.panel-title {
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* 属性区域 */
.property-section {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.property-section h4 {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.settings-section {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.2);
}

.hint-text {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    font-style: italic;
    line-height: 1.6;
}

/* 属性组 */
.property-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-group label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.property-group input[type="number"],
.property-group input[type="text"] {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.property-group input[type="number"]:focus,
.property-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.property-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.property-group select:hover {
    border-color: var(--primary-color);
}

.property-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.property-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    background: transparent;
    transition: var(--transition);
}

.property-group input[type="color"]:hover {
    border-color: var(--primary-color);
}

.property-group span {
    color: var(--primary-color);
    font-size: 13px;
    text-align: right;
    font-family: monospace;
    font-weight: 500;
}

#propType {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 16px;
}

/* 主题颜色选择器 */
.theme-colors {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.theme-btn {
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px currentColor;
}

.theme-btn.active {
    border-color: white;
    box-shadow: 0 0 15px currentColor;
    transform: scale(1.1);
}

#customThemeColor {
    width: 36px !important;
    height: 36px !important;
    border: 2px dashed var(--border) !important;
    border-radius: 50% !important;
    padding: 0 !important;
    cursor: pointer;
}

/* 操作按钮 */
.action-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    margin-top: 12px;
}

.delete-btn {
    background: var(--accent-color);
    color: white;
}

.delete-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
    transform: translateY(-1px);
}

.apply-btn {
    background: var(--primary-color);
    color: white;
}

.apply-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* 铰链位置选择器 */
.hinge-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.hinge-opt {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: var(--transition);
    font-weight: 500;
}

.hinge-opt:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
    background: var(--surface-hover);
}

.hinge-opt.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* 门状态按钮 */
.door-state-btns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.door-state-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    transition: var(--transition);
    font-weight: 500;
}

.door-state-btn:hover {
    border-color: var(--secondary-color);
    color: var(--text-primary);
    background: var(--surface-hover);
}

.door-state-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* 快速操作 */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 画板工具样式 */
.draw-tool-group {
    margin-top: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--border);
}

.draw-tool-group label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.draw-tool-group input[type="color"] {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
}

.draw-tool-group input[type="range"] {
    flex: 1;
    min-width: 100px;
}

.draw-tool-group span {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 50px;
    font-weight: 500;
}

.draw-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.draw-actions .tool-btn {
    flex: 1;
    min-width: 120px;
}

/* 图例说明 */
.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
}

.legend-color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow);
}

/* 快捷键说明 */
.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

kbd {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 4px 10px;
    font-family: monospace;
    font-size: 12px;
    color: var(--primary-color);
    box-shadow: var(--shadow);
    font-weight: 600;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 移动端切换按钮 */
.mobile-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    z-index: 1001;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-toggle-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.mobile-toggle-btn.mobile {
    background: var(--secondary-color);
}

.mobile-toggle-btn.mobile:hover {
    background: var(--secondary-hover);
}

/* 人员信息浮窗 */
.person-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
}

.tooltip-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.tooltip-body {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.tooltip-label {
    color: var(--text-muted);
    font-weight: 500;
}

.tooltip-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* 枪线拖拽提示 */
.gunline-hint {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(244, 63, 94, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    animation: pulse 1s ease-in-out infinite;
    box-shadow: var(--shadow);
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .toolbar {
        width: 200px;
    }
    
    .properties-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .toolbar {
        width: 100%;
        height: 70px;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px 16px;
        gap: 10px;
    }
    
    .toolbar-title {
        font-size: 16px;
        padding-bottom: 0;
        border-bottom: none;
        margin-bottom: 0;
        white-space: nowrap;
    }
    
    .tool-section {
        flex-direction: row;
        gap: 8px;
        white-space: nowrap;
    }
    
    .tool-section h4 {
        display: none;
    }
    
    .tool-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 90px;
    }
    
    .layer-section {
        padding: 8px !important;
    }
    
    .layer-controls {
        flex-direction: row;
    }
    
    .layer-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 90px;
    }
    
    .layer-list {
        flex-direction: row;
        max-height: 45px;
        max-width: 220px;
    }
    
    .layer-item {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 90px;
    }
    
    .properties-panel {
        position: fixed;
        right: -320px;
        top: 70px;
        bottom: 70px;
        width: 280px;
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    .properties-panel.mobile-open {
        right: 0;
    }
    
    .canvas-container {
        flex: 1;
        height: calc(100vh - 80px);
    }
    
    .draw-tool-group {
        display: none;
    }
    
    .draw-actions {
        display: none;
    }
    
    .legend-section,
    .shortcuts-section {
        display: none;
    }
}

/* 移动端底部操作栏 - 独立小圆圈图标 */
.mobile-bottom-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    height: auto;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 0;
    z-index: 1000;
}

.mobile-bottom-bar button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.mobile-undo-btn {
    background: var(--primary-color);
    color: white;
}

.mobile-undo-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.mobile-redo-btn {
    background: var(--secondary-color);
    color: white;
}

.mobile-redo-btn:hover {
    background: var(--secondary-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

/* 移动端手势提示 */
.mobile-gesture-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 24px;
    border-radius: var(--border-radius);
    font-size: 14px;
    text-align: center;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    animation: fadeInOut 3s ease-in-out;
    max-width: 80%;
}

/* 加载动画 */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2000;
}

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