/* ============================================
   JSONON - Premium JSON Editor
   Modern Design with High Contrast
   ============================================ */

/* --- CSS Variables - Dark Theme (Default) --- */
:root {
  /* Backgrounds */
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-tertiary: #1a1a24;
  --bg-elevated: #1e1e2a;
  --bg-input: #0d0d14;

  /* Borders */
  --border-subtle: #2a2a3a;
  --border-medium: #3a3a4a;
  --border-focus: #4f8aff;

  /* Text - High Contrast */
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;

  /* Accents - Vibrant */
  --accent-blue: #4f8aff;
  --accent-green: #4ade80;
  --accent-orange: #fbbf24;
  --accent-red: #f87171;
  --accent-purple: #c084fc;
  --accent-pink: #f472b6;

  /* Syntax Colors - Enhanced */
  --syntax-key: #60a5fa;
  --syntax-string: #a5d6ff;
  --syntax-number: #7dd3fc;
  --syntax-boolean: #fb923c;
  --syntax-null: #94a3b8;
  --syntax-link: #4f8aff;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-code: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow-blue: 0 0 20px rgba(79, 138, 255, 0.3);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Scroller */
  --scroller-track: transparent;
  --scroller-thumb: var(--border-medium);
  --scroller-thumb-hover: var(--text-secondary);
}

/* --- Light Theme - Premium Bright --- */
:root[data-theme="light"] {
  /* Backgrounds */
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef0f6;
  --bg-elevated: #ffffff;
  --bg-input: #f8f9fc;

  /* Borders */
  --border-subtle: #e2e4ed;
  --border-medium: #d0d4e0;
  --border-focus: #3366ff;

  /* Text - High Contrast */
  --text-primary: #0a0a14;
  --text-secondary: #4a4a5a;
  --text-muted: #7a7a8a;

  /* Accents - Rich */
  --accent-blue: #3366ff;
  --accent-green: #00a651;
  --accent-orange: #ff8800;
  --accent-red: #ee3344;
  --accent-purple: #8855ff;
  --accent-pink: #ff5588;

  /* Syntax Colors - Enhanced */
  --syntax-key: #d63355;
  --syntax-string: #0a4a8a;
  --syntax-number: #0066cc;
  --syntax-boolean: #d63355;
  --syntax-null: #7a8a9a;
  --syntax-link: #0066cc;

  /* Scroller */
  --scroller-track: var(--bg-tertiary);
  --scroller-thumb: var(--border-medium);
  --scroller-thumb-hover: var(--text-secondary);
}

/* --- Reset & Base --- */
html, body {
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-ui);
  overflow: hidden;
  background: var(--bg-primary);
  transition: background var(--transition-normal), color var(--transition-normal);
}

* {
  box-sizing: border-box;
}

[v-show] {
  display: none;
}

[v-cloak] {
  opacity: 0;
}

/* --- Typography & Links --- */
a, svg {
  transition: color var(--transition-fast), fill var(--transition-fast);
  text-decoration: none;
}

a:link, a:visited {
  color: var(--text-secondary);
}

a:hover {
  color: var(--accent-blue);
}

/* --- Layout Containers --- */
.pull-right {
  float: right;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.pull-left {
  display: flex;
  align-items: center;
  flex-grow: 1;
  gap: var(--space-md);
}

/* --- Header - Premium Design --- */
.side-top {
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.side-top::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    var(--border-focus) 20%,
    var(--border-focus) 80%,
    transparent
  );
  opacity: 0.5;
}

/* --- Logo - Modern --- */
.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  text-decoration: none;
  font-weight: 800;
  font-size: 24px;
  color: var(--text-primary);
  padding: 0;
  font-family: var(--font-code);
  letter-spacing: -1.5px;
  position: relative;
  transition: all var(--transition-normal);
}

.logo .on {
  color: var(--accent-blue);
  position: relative;
  text-shadow: 0 0 20px rgba(79, 138, 255, 0.5);
}

.logo .on + span {
  color: var(--text-primary);
}

.logo:hover {
  transform: translateX(2px);
}

.logo:hover .on {
  text-shadow: 0 0 30px rgba(79, 138, 255, 0.8);
}

/* --- Slogan --- */
.slogan {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: var(--space-xl);
  padding-left: var(--space-md);
  border-left: 1px solid var(--border-subtle);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: color var(--transition-normal), border-color var(--transition-normal);
}

/* --- Top Right --- */
.top-right {
  margin-left: auto;
}

.top-right a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.top-right a:hover {
  background: var(--bg-tertiary);
  color: var(--accent-blue);
  transform: translateY(-2px);
}

/* --- Left Panel (Editor) --- */
.side-left {
  position: absolute;
  left: 0;
  top: 60px;
  bottom: 0;
  width: 40%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-subtle);
}

.left-panel {
  flex: 1;
  position: relative;
  min-height: 0;
}

.side-view-diff .left-panel {
  height: 50%;
  border-top: 1px solid var(--border-subtle);
}

.side-view-diff .left-panel:first-child {
  border-top: none;
}

/* --- Textarea - Premium --- */
textarea {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  border: none;
  resize: none;
  padding: var(--space-lg) var(--space-xl);
  font-size: 14px;
  font-family: var(--font-code);
  line-height: 1.7;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: background var(--transition-fast), color var(--transition-normal);
}

textarea::placeholder {
  color: var(--text-muted);
}

textarea:focus {
  background: var(--bg-primary);
}

/* --- Splitter --- */
.splitx {
  width: 2px;
  background: linear-gradient(180deg,
    transparent,
    var(--border-subtle) 20%,
    var(--border-subtle) 80%,
    transparent
  );
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 40%;
  z-index: 100;
  cursor: col-resize;
  transition: all var(--transition-fast);
}

.splitx:hover {
  background: var(--accent-blue);
  width: 3px;
  left: calc(40% - 0.5px);
  box-shadow: var(--shadow-glow-blue);
}

/* --- Right Panel (Preview) --- */
.side-right {
  position: absolute;
  left: 40%;
  top: 60px;
  right: 0;
  bottom: 0;
  background: var(--bg-secondary);
}

.right-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.right-main {
  flex: 1;
  overflow: hidden;
}

/* --- View Code --- */
.view-code {
  width: 100%;
  height: 100%;
  padding: var(--space-xl);
  overflow-y: auto;
  font-family: var(--font-code);
  font-size: 14px;
  line-height: 1.7;
}

.view-code::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.view-code::-webkit-scrollbar-track {
  background: var(--scroller-track);
}

.view-code::-webkit-scrollbar-thumb {
  background: var(--scroller-thumb);
  border-radius: var(--radius-sm);
}

.view-code::-webkit-scrollbar-thumb:hover {
  background: var(--scroller-thumb-hover);
}

.view-code > ul {
  padding: 0;
}

/* --- Error View --- */
.view-error {
  padding: var(--space-xl);
  color: var(--accent-red);
  line-height: 1.7;
  height: 100%;
  overflow-y: auto;
}

.view-error pre {
  margin: 0;
  font-family: var(--font-code);
  font-size: 14px;
  font-weight: 500;
}

/* --- Toolbar - Premium --- */
.right-bar {
  height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  position: relative;
  z-index: 50;
  box-shadow: inset 0 -1px 0 var(--border-subtle);
}

.right-bar::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    var(--border-medium) 50%,
    transparent
  );
}

.right-bar > div {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.right-bar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  position: relative;
  transition: all var(--transition-fast);
}

.right-bar a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.right-bar a:active {
  transform: translateY(0);
}

.right-bar svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* --- Icons --- */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  fill: currentColor;
}

.icon-square {
  width: 16px;
  height: 16px;
  display: inline-block;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.icon-square:hover {
  transform: scale(1.1);
}

.icon-square-plus {
  display: none;
  user-select: none;
}

/* --- JSON Syntax Highlighting --- */
.keyval {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  line-height: 1.7;
}

.keyval .key {
  font-weight: 600;
  color: var(--syntax-key);
}

.keyval .val {
  font-weight: 400;
}

.keyval .val-String {
  color: var(--syntax-string);
}

.keyval .val-Number {
  color: var(--syntax-number);
}

.keyval .val-Boolean {
  color: var(--syntax-boolean);
}

.keyval .val-Null {
  color: var(--syntax-null);
}

/* --- Expand/Collapse --- */
.fold-view {
  display: none;
}

.ex-alia {
  cursor: pointer;
  display: inline-block;
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-weight: 500;
}

.ex-alia:hover {
  background: rgba(79, 138, 255, 0.15);
  box-shadow: 0 0 12px rgba(79, 138, 255, 0.2);
}

/* --- Links --- */
.json-link {
  color: var(--syntax-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all var(--transition-fast);
}

.json-link:hover {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

/* --- Popups & Dropdowns --- */
.pop {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
  overflow: visible;
  z-index: 200;
  animation: dropdownFadeIn 0.15s ease-out;
  margin-top: 4px;
}

/* 大桥接区域 - 确保鼠标移动顺畅 */
.pop::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: 0;
  background: transparent;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pop-btn {
  display: inline-flex;
  align-items: center;
  position: relative;
}

/* 按钮悬停时显示 */
.pop-btn:hover .pop {
  display: block;
}

/* 弹出框悬停时保持显示 */
.pop:hover {
  display: block !important;
}

/* --- History Dropdown --- */
.historys {
  margin: 0;
  padding: var(--space-sm);
  min-width: 220px;
  max-width: 300px;
  background: var(--bg-elevated);
}

.historys li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.historys li:hover {
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

/* 添加桥接区域到历史下拉框 */
.historys::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: transparent;
}

.historys li a {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-weight: 500;
}

.historys svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.historys svg:hover {
  color: var(--accent-red);
  transform: scale(1.1);
}

.historys .li_css {
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
}

.icon_text {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.icon_top, .icon_end {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
}

.icon_top:hover, .icon_end:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* --- Theme Selector --- */
.themes {
  padding: var(--space-sm);
  min-width: 160px;
  background: var(--bg-elevated);
}

/* 添加桥接区域到换肤下拉框 */
.themes::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: transparent;
}

.themes .theme-item {
  cursor: pointer;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
}

.themes .theme-item:hover {
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

.themes .theme-item.true {
  background: var(--bg-tertiary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.themes .theme-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

/* --- Modal/Save Box --- */
.save-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  z-index: 300;
  box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
  min-width: 360px;
  transition: all var(--transition-normal);
}

.save-box .close-icon {
  position: absolute;
  right: var(--space-lg);
  top: var(--space-lg);
  cursor: pointer;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  transition: all var(--transition-fast);
}

.save-box .close-icon:hover {
  color: var(--accent-red);
  transform: rotate(90deg);
}

.save-box input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
}

.save-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 138, 255, 0.1);
}

.save-box button {
  width: 100%;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), #3d7aff);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.save-box button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 138, 255, 0.4);
}

.save-box button:active {
  transform: translateY(0);
}

.save-box label {
  position: absolute;
  right: 130px;
  top: 48px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Labels --- */
.label {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-block;
  height: 22px;
  padding: 0 var(--space-sm);
  line-height: 20px;
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  z-index: 30;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: var(--shadow-sm);
}

/* --- Alerts --- */
.alert {
  position: fixed;
  top: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: auto;
  max-width: 90%;
  z-index: 1000;
  animation: slideDown var(--transition-normal);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.alert-inner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.alert-success {
  background: linear-gradient(135deg, #064e3b, #065f46);
  border: 1px solid #059669;
  color: #6ee7b7;
}

.alert-danger {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  border: 1px solid #dc2626;
  color: #fca5a5;
}

.alert-warning {
  background: linear-gradient(135deg, #78350f, #92400e);
  border: 1px solid #f59e0b;
  color: #fcd34d;
}

.alert-info {
  background: linear-gradient(135deg, #1e3a5f, #1e40af);
  border: 1px solid #3b82f6;
  color: #93c5fd;
}

/* --- Loading Spinner --- */
.loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ball-pulse-sync {
  display: flex;
  gap: 6px;
}

.ball-pulse-sync div {
  width: 10px;
  height: 10px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: pulse 0.6s ease-in-out infinite;
  box-shadow: 0 0 10px var(--accent-blue);
}

.ball-pulse-sync div:nth-child(2) {
  animation-delay: 0.1s;
}

.ball-pulse-sync div:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* --- Window Cover --- */
.widnow-cover {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: none;
}

/* --- Hints (tooltips) --- */
.hint--top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* --- Active States --- */
.icon.active-true {
  fill: var(--accent-blue);
  color: var(--accent-blue);
}

/* --- Lists --- */
ul {
  margin: 0;
  padding-left: 28px;
  line-height: 1.7;
}

.side-right > ul {
  padding: 0;
}

li {
  list-style: none;
}

/* --- Diff View --- */
#diffoutput {
  height: 100%;
  overflow-y: auto;
  padding: var(--space-xl);
  font-family: var(--font-code);
}

/* --- Error Highlight --- */
.error-position {
  background-color: rgba(248, 113, 113, 0.2);
  color: var(--accent-red);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
