/* ================================
   JSON Tool — Custom Styles
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================================
   Toast
   ================================ */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  font-size: 14px;
  font-weight: 500;
  color: #1E293B;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
}
.toast.show { transform: translateX(0); }
.toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4F46E5;
  flex-shrink: 0;
}

/* ================================
   Tool Section
   ================================ */
.tool-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .tool-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .action-bar {
    flex-direction: row !important;
    flex-wrap: wrap;
    padding: 16px !important;
  }
}

/* ================================
   Panel (Input / Output)
   ================================ */
.panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.output-format-tag {
  font-size: 11px;
  font-weight: 600;
  background: #4F46E5;
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.action-btn:hover {
  color: #4F46E5;
  border-color: #4F46E5;
  background: var(--border);
}
.action-btn--danger:hover {
  color: #ef4444;
  border-color: #ef4444;
  background: #fef2f2;
}

/* ================================
   Editor (Input)
   ================================ */
.editor-wrap {
  position: relative;
  display: flex;
  height: 500px;
  overflow: hidden;
}

.line-numbers {
  width: 44px;
  padding: 16px 8px 16px 12px;
  background: #EEEDEB;
  border-right: 1px solid var(--border);
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: right;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

.json-textarea {
  flex: 1;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  background: #fff;
  tab-size: 2;
  height: 100%;
  overflow-y: auto;
}

.json-textarea::placeholder {
  color: #A1A1AA;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.char-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.validate-status {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.validate-status.valid {
  color: #059669;
}
.validate-status.invalid {
  color: #ef4444;
}

/* ================================
   Output
   ================================ */
.output-wrap {
  height: 500px;
  overflow: auto;
  background: #F8FAFC;
  border-left: 3px solid #4F46E5;
}

.json-output {
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
  margin: 0;
}

.output-placeholder {
  color: #A1A1AA;
  font-style: italic;
}

/* Syntax colors */
.json-key { color: #6366f1; }
.json-string { color: #4F46E5; }
.json-number { color: #f59e0b; }
.json-bool { color: #3b82f6; }
.json-null { color: #71717A; }
.json-bracket { color: #52525B; }

/* ================================
   Action Bar (Center)
   ================================ */
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 0;
  align-self: center;
}

.action-bar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg-alt, #F5F5F4);
  border-radius: 12px;
  border: 1px solid var(--border, #E7E5E4);
}

.action-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.op-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  min-width: 96px;
  justify-content: center;
}

.op-btn--primary {
  background: #4F46E5;
  color: #fff;
  padding: 11px 18px;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.22);
  animation: primary-glow 4s ease-in-out infinite;
}
.op-btn--primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
  transform: translateY(-1px);
  animation-play-state: paused;
}

.op-btn--secondary {
  background: #EEF2FF;
  color: #4F46E5;
  border: 1px solid #C7D2FE;
}
.op-btn--secondary:hover {
  background: #E0E7FF;
  border-color: #4F46E5;
  transform: translateY(-1px);
}

.op-btn--outline {
  background: #fff;
  color: #1E293B;
  border: 1px solid var(--border-strong);
}
.op-btn--outline:hover {
  color: #4F46E5;
  border-color: #4F46E5;
  background: var(--border);
}
.op-btn--outline.active {
  color: #fff;
  background: #4F46E5;
  border-color: #4F46E5;
}

@keyframes primary-glow {
  0%, 100% { box-shadow: 0 2px 10px rgba(79, 70, 229, 0.22); }
  50% { box-shadow: 0 2px 16px rgba(79, 70, 229, 0.32); }
}

/* ================================
   Tree View
   ================================ */
.tree-section {
  margin-top: 24px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.tree-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.tree-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
}

.tree-container {
  padding: 16px 18px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.8;
  max-height: 500px;
  overflow: auto;
}

.tree-node {
  padding-left: 20px;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
}
.tree-toggle:hover { color: #4F46E5; }

.tree-arrow {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  transition: transform 0.15s;
  color: var(--text-muted);
}
.tree-arrow.collapsed { transform: rotate(-90deg); }

.tree-key { color: #6366f1; font-weight: 500; }
.tree-string { color: #4F46E5; }
.tree-number { color: #f59e0b; }
.tree-boolean { color: #3b82f6; }
.tree-null { color: #94a3b8; font-style: italic; }
.tree-type {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

.tree-children {
  border-left: 1px dashed var(--border);
  margin-left: 6px;
  padding-left: 14px;
}

.tree-children.collapsed {
  display: none;
}

/* ================================
   Features
   ================================ */
.features-section {
  margin-top: 40px;
  margin-bottom: 40px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .features-grid { grid-template-columns: 1fr; }
}

.feature-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  transition: all 0.25s;
}
.feature-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.feature-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.feature-icon--green { background: #d1fae5; color: #10B981; }
.feature-icon--blue { background: #eff6ff; color: #3b82f6; }
.feature-icon--orange { background: #fffbeb; color: #f59e0b; }
.feature-icon--purple { background: #f5f3ff; color: #8b5cf6; }

.feature-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.feature-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ================================
   Selection & Scrollbar
   ================================ */
::selection {
  background: rgba(79, 70, 229, 0.2);
  color: #1E293B;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

/* ================================
   Mobile menu
   ================================ */
#mobileMenu {
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}
#mobileMenu.open {
  max-height: 300px;
  opacity: 1;
}

/* ================================
   Guide Section (accordion)
   ================================ */
.guide-section {
  margin-top: 16px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover {
  background: var(--bg-alt);
}
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list {
  padding: 0 20px 20px;
}
.guide-list.hidden {
  display: none;
}
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child {
  border-top: 1px solid var(--border);
}
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.guide-item-body kbd {
  padding: 1px 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}
