/* ===== 无风工具箱 - Premium Design System ===== */

/* ===== Dark Theme (Default) ===== */
:root, [data-theme="dark"] {
  --bg-0: #08080d;
  --bg-1: #0e0e16;
  --bg-2: #16161f;
  --bg-3: #1e1e2a;
  --bg-4: #262636;
  --bg-hover: #2a2a3d;
  --bg-input: #131320;
  --border: #2a2a40;
  --border-subtle: #1f1f35;
  --border-focus: #6366f1;
  --text-0: #f0f0f8;
  --text-1: #c8c8d8;
  --text-2: #8888a0;
  --text-3: #555570;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-bg: rgba(99,102,241,0.08);
  --accent-bg-strong: rgba(99,102,241,0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --terminal-bg: #0a0a12;
  --terminal-text: #4ade80;
  --terminal-cyan: #22d3ee;
  --terminal-yellow: #facc15;
  --terminal-dim: #3a6050;
  --terminal-border: #1a1a2a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --glass: rgba(22,22,35,0.85);
  --glass-border: rgba(255,255,255,0.06);
}

/* ===== Light Theme ===== */
[data-theme="light"] {
  --bg-0: #f5f5f9;
  --bg-1: #ffffff;
  --bg-2: #f0f0f5;
  --bg-3: #e8e8f0;
  --bg-4: #dddde8;
  --bg-hover: #ececf5;
  --bg-input: #ffffff;
  --border: #d8d8e8;
  --border-subtle: #e8e8f0;
  --border-focus: #6366f1;
  --text-0: #1a1a2e;
  --text-1: #333350;
  --text-2: #666680;
  --text-3: #9999aa;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-bg: rgba(99,102,241,0.06);
  --accent-bg-strong: rgba(99,102,241,0.12);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --terminal-bg: #1a1a2e;
  --terminal-text: #4ade80;
  --terminal-cyan: #22d3ee;
  --terminal-yellow: #facc15;
  --terminal-dim: #3a6050;
  --terminal-border: #2a2a40;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --glass: rgba(255,255,255,0.92);
  --glass-border: rgba(0,0,0,0.06);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(99,102,241,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(139,92,246,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(34,197,94,0.04) 0%, transparent 60%);
}

.login-card {
  position: relative;
  width: 400px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.6s ease;
}

.login-brand { text-align: center; margin-bottom: 32px; }
.brand-icon { margin-bottom: 16px; }
.brand-icon svg { filter: drop-shadow(0 0 12px rgba(99,102,241,0.3)); }

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-ver {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: 1px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; text-align: left; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-0);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg-strong);
}

.form-group textarea { resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.font-mono { font-family: 'JetBrains Mono', monospace !important; font-size: 13px !important; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text-0); background: var(--bg-hover); }

.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: transparent; border: none;
  color: var(--text-3); cursor: pointer; font-size: 14px;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--text-0); background: var(--bg-hover); }
.btn-icon.danger:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-copy:hover { background: var(--accent-dark); }
.btn-copy svg { flex-shrink: 0; }

.btn-theme {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.btn-theme:hover { border-color: var(--accent); transform: rotate(15deg); }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-left, .topbar-right, .topbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-0);
}

.logo-icon { font-size: 20px; }

.version-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg-strong);
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.install-cmd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cmd-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.install-cmd code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-light);
  font-size: 13px;
  font-weight: 500;
}

/* ===== Main Layout ===== */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 60px);
}

.editor-panel, .preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel { border-right: 1px solid var(--border); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  min-height: 52px;
}

.panel-title { display: flex; align-items: center; gap: 10px; }

.panel-title h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.2px;
}

.menu-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.panel-actions { display: flex; gap: 8px; }

.panel-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}

.btn-save { min-width: 140px; justify-content: center; }

.save-status {
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
}
.save-status.show { opacity: 1; }

/* ===== Menu Tree ===== */
.menu-tree {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.menu-tree::-webkit-scrollbar { width: 5px; }
.menu-tree::-webkit-scrollbar-track { background: transparent; }
.menu-tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.menu-tree::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.tree-item { margin-bottom: 4px; }

.tree-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--accent);
  transition: all 0.15s;
  cursor: default;
}

.tree-item-row:hover {
  border-color: var(--accent-light);
  border-left-color: var(--accent-light);
  background: var(--bg-hover);
}

/* Child items get a different left-border color */
.tree-children .tree-item-row {
  border-left: 3px solid #22c55e;
}

.tree-children .tree-item-row:hover {
  border-color: #4ade80;
  border-left-color: #4ade80;
}

.tree-item-row .item-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  min-width: 26px;
  text-align: center;
  padding: 3px 5px;
  background: var(--accent-bg-strong);
  border-radius: 6px;
  font-weight: 600;
}

.tree-children .tree-item-row .item-number {
  color: #22c55e;
  background: rgba(34,197,94,0.12);
}

.tree-item-row .item-icon { font-size: 16px; width: 22px; text-align: center; }

.tree-item-row .item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item-row .item-type {
  font-size: 10px;
  color: var(--text-3);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tree-item-row .item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.tree-item-row:hover .item-actions { opacity: 1; }

.tree-children {
  margin-left: 24px;
  padding-left: 14px;
  border-left: 2px solid rgba(34,197,94,0.25);
  margin-top: 4px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.tree-children.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

.tree-children.expanded {
  max-height: 5000px;
  opacity: 1;
}

/* Chevron toggle */
.item-chevron {
  font-size: 10px;
  color: var(--text-3);
  transition: transform 0.2s ease;
  display: inline-block;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.item-chevron.expanded {
  transform: rotate(90deg);
  color: var(--accent);
}

/* Submenu row clickable */
.tree-item-row.is-script {
  cursor: pointer;
}
.tree-item-row.is-script:hover {
  border-color: #22c55e;
  border-left-color: #22c55e;
}

.tree-item-row.is-submenu {
  cursor: pointer;
  border-left: 3px solid var(--accent);
}

.tree-item-row.is-submenu:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
}

.tree-item-row.is-expanded {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 2px 8px rgba(99,102,241,0.1);
}

.add-child-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  margin-top: 4px;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-weight: 500;
}
.add-child-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ===== Terminal Preview ===== */
.terminal-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--terminal-bg);
  overflow: hidden;
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--terminal-border);
}

.dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.terminal-title {
  margin-left: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.terminal {
  flex: 1;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-y: auto;
  color: var(--terminal-text);
  white-space: pre;
  letter-spacing: 0.3px;
}

.terminal::-webkit-scrollbar { width: 5px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.terminal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* Terminal color classes */
.terminal .t-cyan { color: #67e8f9; }
.terminal .t-green { color: #4ade80; }
.terminal .t-yellow { color: #facc15; }
.terminal .t-dim { color: #6b7280; }
.terminal .t-num { color: #818cf8; font-weight: 600; }
.terminal .t-line { color: #374151; }
.terminal .t-cursor {
  color: #4ade80;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  width: 460px;
  max-height: 85vh;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.25s ease;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none; border: none;
  color: var(--text-3); font-size: 18px; cursor: pointer;
  padding: 4px; border-radius: 6px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text-0); background: var(--bg-hover); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ===== Mobile Tabs ===== */
.mobile-tabs {
  display: none; /* hidden on desktop */
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .mobile-tabs {
    display: flex;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    padding: 0;
  }
  .mobile-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
  }
  .mobile-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--accent-bg);
  }

  .main-content {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr;
  }
  .editor-panel { border-right: none; }

  /* Tab visibility */
  .preview-panel { display: none; }
  .preview-panel.tab-active { display: flex; }
  .editor-panel.tab-hidden { display: none; }

  .topbar {
    flex-wrap: nowrap;
    gap: 6px;
    height: 48px;
    padding: 0 12px;
  }
  .topbar-center { display: none; }
  .logo { font-size: 14px; }
  .version-tag { font-size: 9px; padding: 1px 5px; }
  .btn-theme { width: 30px; height: 30px; font-size: 14px; }
  .panel-header { padding: 10px 12px; }
  .panel-header h2 { font-size: 13px; }
  .panel-footer { padding: 8px 12px; }
  .btn-save { min-width: auto; font-size: 12px; padding: 6px 12px; }
  .panel-actions .btn { font-size: 11px; padding: 5px 8px; }
  .tree-item-row { padding: 8px 10px; gap: 6px; }
  .tree-item-row .item-name { font-size: 12px; }
  .tree-item-row .item-number { font-size: 10px; min-width: 22px; }
  .tree-item-row .item-type { font-size: 9px; padding: 1px 5px; }
  .tree-children { margin-left: 18px; padding-left: 10px; }
  .terminal { font-size: 11px; padding: 12px; }
  .terminal-dots { padding: 6px 10px; }
  .menu-count { font-size: 9px; }
  .modal-content { width: 92vw; }
}

/* ===== 拖拽排序样式 ===== */
.drag-handle {
  cursor: grab;
  font-size: 16px;
  color: var(--text-secondary, #71717a);
  user-select: none;
  padding: 0 4px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
.drag-handle:hover { opacity: 1; color: var(--accent, #6366f1); }
.drag-handle:active { cursor: grabbing; }
.tree-item.dragging { opacity: 0.4; }
.tree-item.drag-over > .tree-item-row {
  border-top: 2px solid var(--accent, #6366f1);
  margin-top: -2px;
}
/* 脚本项不显示指针 */
.tree-item-row.is-script { cursor: default; }
