/* ================= 基础样式 ================= */
:root {
    --accent: #0ea5e9;
    --neon-cyan: #0ea5e9;
    --neon-blue: #3b82f6;
    --neon-green: #22c55e;
    --neon-amber: #f59e0b;
    --neon-red: #ef4444;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(14, 165, 233, 0.2);
}

* { user-select: none; box-sizing: border-box; }

body {
    background-color: #020617;
    background-image:
        radial-gradient(circle at 50% 0%, rgba(14, 165, 233, 0.15) 0%, transparent 50%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    color: #e2e8f0;
    font-family: 'Inter', 'Rajdhani', sans-serif;
    overflow: hidden;
    min-height: 100vh;
}

/* ================= 玻璃拟态面板 ================= */
.glass-panel {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.7) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    border-left: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35), inset 0 0 32px rgba(0, 0, 0, 0.2);
}

/* ================= 工业看板组件 - 极简风格 ================= */
/* ================= 工业看板组件 - glass-panel-premium ================= */
.widget {
    position: absolute;
    z-index: 10;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.6) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-top: 1px solid rgba(14, 165, 233, 0.4);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 0 32px rgba(0, 0, 0, 0.2);
    cursor: move;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
/* top glow line */
.widget::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(14, 165, 233, 0.8), transparent);
    opacity: 0.5; z-index: 10; pointer-events: none;
}
/* bottom-right L corner accent */
.widget::after {
    content: '';
    position: absolute; bottom: 0; right: 0;
    width: 10px; height: 10px;
    border-bottom: 2px solid rgba(14, 165, 233, 0.5);
    border-right: 2px solid rgba(14, 165, 233, 0.5);
    pointer-events: none;
}

.widget:hover {
    border-color: rgba(14, 165, 233, 0.35);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), inset 0 0 32px rgba(0, 0, 0, 0.2);
}

.widget.selected {
    border-color: rgba(14, 165, 233, 0.5);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25), 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

/* 多选-主控件 */
.widget.selected.primary-selected {
    border-color: rgba(14, 165, 233, 0.6);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35), 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* 多选-从控件 (不同色) */
.widget.selected.multi-selected {
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), 0 6px 24px rgba(0, 0, 0, 0.3);
}

.widget-transparent {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: none !important;
}
.widget-transparent::before,
.widget-transparent::after {
    display: none !important;
}
.widget-transparent .widget-content {
    padding: 0 !important;
}
.widget-transparent.selected {
    border-color: rgba(14, 165, 233, 0.4) !important;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2) !important;
}

/* 管道端点锚点样式 */
.wp-anchor {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    pointer-events: all;
}
.wp-anchor:hover {
    transform: scale(1.5) !important;
    box-shadow: 0 0 15px #fff !important;
}

/* ================= 画布样式 ================= */
.canvas-area {
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 60%, #020617 100%);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(15, 23, 42, 0.5) 0%, transparent 50%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    border-radius: 16px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

.canvas-area.drag-over {
    box-shadow: inset 0 0 60px rgba(6, 182, 212, 0.2), 0 0 20px rgba(6, 182, 212, 0.15);
}

/* ================= 组件库项 - 简洁风格 ================= */
.component-item {
    cursor: grab;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.component-item:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.08);
}

.component-item i {
    font-size: 20px;
}

.component-item span {
    font-size: 11px;
    color: #cbd5e1;
    text-align: center;
    font-weight: 500;
}

/* ================= 按钮样式 ================= */
.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    color: white;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 50%, #15803d 100%);
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    color: white;
    font-weight: 600;
    transition: all 0.25s;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.5);
}

.btn-secondary {
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.6) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 10px 20px;
    color: #e2e8f0;
    font-weight: 500;
    transition: all 0.25s;
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.25) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
}

.btn-cyan {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #0e7490 100%);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    color: white;
    font-weight: 600;
    transition: all 0.25s;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.btn-cyan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

/* ================= 模态框 ================= */
.modal-bg {
    background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(8px) saturate(150%);
}

.modal-content {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.65) 0%, rgba(15, 23, 42, 0.85) 100%);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    border-left: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 16px;
    box-shadow: 0 20px 48px 0 rgba(0, 0, 0, 0.5), inset 0 0 32px rgba(0, 0, 0, 0.2);
}

/* ================= 提示消息 ================= */
.toast {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 12px 20px;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ================= 分类标题 ================= */
.category-title {
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ================= 动画 ================= */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes slideIn {
    from { transform: translateY(-12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 组件添加动画 */
@keyframes widgetAdd {
    from { opacity: 0; transform: scale(0.8) translateY(-20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.widget-add {
    animation: widgetAdd 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================= 文字发光效果 ================= */
.text-glow-cyan {
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.5), 0 0 20px rgba(6, 182, 212, 0.3);
}

.text-glow-blue {
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5), 0 0 20px rgba(59, 130, 246, 0.3);
}

/* ================= 缩放控制 ================= */
.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    border-radius: 4px;
    cursor: se-resize;
    right: -7px;
    bottom: -7px;
    opacity: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5);
}

.widget:hover .resize-handle,
.widget.selected .resize-handle {
    opacity: 1;
}

/* ================= 调整大小手柄 ================= */
.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 4px;
    cursor: se-resize;
    right: -8px;
    bottom: -8px;
    opacity: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5);
}

.resize-handle::before {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-right: 2px solid rgba(255,255,255,0.5);
    border-bottom: 2px solid rgba(255,255,255,0.5);
}

/* ================= 模板卡片 ================= */
.template-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.6) 100%);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-card:hover {
    transform: translateY(-3px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 8px 24px 0 rgba(59, 130, 246, 0.2);
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.15) 0%, rgba(30, 58, 138, 0.25) 100%);
}

.template-card.selected {
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3), 0 8px 24px rgba(59, 130, 246, 0.25);
}

/* ================= 输入框 ================= */
.input {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    color: #e2e8f0;
    width: 100%;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* ================= 标签按钮 ================= */
.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    transition: all 0.25s;
}

.tab-btn.active {
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.25) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    color: #60a5fa;
}

/* ================= 滚动条 ================= */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ================= 快捷键提示 ================= */
.shortcut-hint {
    font-size: 10px;
    color: #64748b;
    background: rgba(15, 23, 42, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* ================= TabPage 编辑器预览 ================= */
.widget-tabpage {
    background: rgba(10, 15, 25, 0.9) !important;
    border: 2px solid rgba(14, 165, 233, 0.2) !important;
    border-top: 2px solid rgba(14, 165, 233, 0.3) !important;
    cursor: move;
    overflow: visible !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(14, 165, 233, 0.08) !important;
}

.widget-tabpage.selected {
    border-color: rgba(14, 165, 233, 0.5) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(14, 165, 233, 0.25) !important;
}

.widget-tabpage:hover {
    border-color: rgba(14, 165, 233, 0.35) !important;
}

/* TabPage 编辑器内的子控件 */
.tp-edit-child {
    background: rgba(14, 165, 233, 0.06);
    border: 1px dashed rgba(14, 165, 233, 0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    overflow: hidden;
    transition: all 0.2s;
}

.tp-edit-child:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
}

.tp-edit-child.selected {
    background: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(14, 165, 233, 0.4);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);
}

.tp-edit-child-label {
    font-size: 8px;
    color: rgba(148, 163, 184, 0.45);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 4px;
}

/* ================= WYSIWYG Widget Previews ================= */
.widget-preview-content {
    pointer-events: none;
    user-select: none;
}

.widget-preview-content svg {
    display: block;
}

/* Pulse animation for status indicator */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Spin animation for pump/motor */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Slide animations for conveyor */
@keyframes slideright {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}
@keyframes slideleft {
    from { transform: translateX(100%); }
    to { transform: translateX(-100%); }
}

/* ================= 多选对齐工具栏 ================= */
.align-toolbar.hidden {
    display: none !important;
}

.align-toolbar {
    display: flex;
}

.align-btn {
    width: 30px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.align-btn:hover {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.2);
    color: #0ea5e9;
}

.align-btn:active {
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
    transform: scale(0.92);
}

/* ================= 框选矩形 ================= */
.rubber-band {
    border: 1px dashed #0ea5e9 !important;
    background: rgba(14, 165, 233, 0.06) !important;
    pointer-events: none !important;
    z-index: 200 !important;
}

/* ================= 快捷键提示 ================= */
.shortcut-hint {
    font-size: 10px;
    color: #475569;
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* ================= 属性面板折叠 ================= */
#propertyPanelAside.collapsed {
    width: 40px !important;
    min-width: 40px !important;
}
#propertyPanelAside.collapsed #propertyPanel {
    display: none;
}
#propertyPanelAside.collapsed .category-title {
    display: none;
}
#propertyPanelAside.collapsed .p-4.border-b {
    padding: 8px 0 !important;
    display: flex !important;
    justify-content: center;
    border-bottom: none !important;
}
#propertyPanelAside.collapsed #panelCollapseBtn {
    margin: 0;
}

/* ================= 画布抓手模式 ================= */
#canvas.pan-mode {
    cursor: grab;
}
#canvas.pan-mode:active {
    cursor: grabbing;
}
#canvas.pan-active {
    cursor: grabbing !important;
}
#panToolBtn.active {
    background: linear-gradient(145deg, rgba(14, 165, 233, 0.3) 0%, rgba(14, 165, 233, 0.4) 100%) !important;
    border-color: rgba(14, 165, 233, 0.5) !important;
    color: #0ea5e9 !important;
}
