/* 
 * Premium JSON Validator & Formatter - Sophisticated Edition
 * 다크 모드, 고도화된 글래스모피즘 및 동적 배경 효과 적용
 */

:root {
  --bg-color: #030712;
  --card-bg: rgba(17, 24, 39, 0.7);
  --accent-color: #2dd4bf;
  --accent-glow: rgba(45, 212, 191, 0.5);
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --success-color: #10b981;
  --error-color: #ef4444;
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-effect: blur(20px);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem; /* 상하 패딩 제거/축소 */
  overflow-x: hidden;
  position: relative;
}

/* --- Animated Background Decoration --- */
.bg-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #111827, #030712);
}

.blob {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: moveBlob 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
}

.blob-1 { top: -10%; left: -10%; animation-duration: 25s; }
.blob-2 { bottom: -10%; right: -10%; background: radial-gradient(circle, rgba(45, 212, 191, 0.4) 0%, transparent 70%); animation-duration: 30s; animation-delay: -5s; }
.blob-3 { top: 40%; left: 30%; background: radial-gradient(circle, rgba(20, 184, 166, 0.2) 0%, transparent 70%); animation-duration: 20s; animation-delay: -10s; }

@keyframes moveBlob {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(100px, 50px) scale(1.1); }
  66% { transform: translate(-50px, 150px) scale(0.9); }
  100% { transform: translate(50px, -100px) scale(1); }
}

/* --- Header & Typography --- */
header {
  text-align: center;
  margin-top: 2rem;
  margin-bottom: 2rem;
  z-index: 10;
}

header h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, #fff 0%, #99f6e4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2rem;
  filter: drop-shadow(0 0 20px rgba(45, 212, 191, 0.3));
}

/* --- Main Layout --- */
main {
  width: 100%;
  max-width: 1600px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
  z-index: 10;
}

@media (max-width: 1024px) {
  main { grid-template-columns: 1fr; }
}

/* --- Premium Cards --- */
.section-card {
  background: var(--card-bg);
  backdrop-filter: var(--glass-effect);
  -webkit-backdrop-filter: var(--glass-effect);
  border: 1px solid var(--border-color);
  border-radius: 2rem;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
              inset 0 1px 1px rgba(255, 255, 255, 0.05);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.section-card:hover {
  border-color: rgba(45, 212, 191, 0.3);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0 0.5rem;
  gap: 1rem;
}

/* --- Status Badge (New Location & Animation) --- */
.badge {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  animation: slideInBadge 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.badge-valid {
  background: rgba(16, 185, 129, 0.9);
  color: white;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  animation: slideInBadge 0.4s, pulseValid 2s infinite;
}

.badge-invalid {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
  animation: slideInBadge 0.4s, pulseInvalid 2s infinite;
}

@keyframes slideInBadge {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulseValid {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseInvalid {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- Editors --- */
textarea, .output-area {
  width: 100%;
  height: calc(100vh - 380px); /* 화면 전체 높이에 맞춰 유동적으로 조절 */
  min-height: 400px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 1.5rem;
  color: #e2e8f0;
  font-family: 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  resize: none;
  transition: all 0.3s ease;
  overflow-y: auto; /* 필요할 때만 스크롤바 표시 */
}

textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.15);
}

.output-area {
  overflow-y: auto;
  white-space: pre;
}

/* --- Buttons --- */
.button-group {
  margin-bottom: 1.25rem;
  display: flex;
  gap: 1rem;
}

button {
  padding: 0.875rem 1.75rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

button.primary {
  background: linear-gradient(135deg, #2dd4bf 0%, #14b8a6 100%);
  color: #000;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

button.primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.5),
              0 0 0 4px rgba(45, 212, 191, 0.2);
}

button.secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  border-color: var(--border-color);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-secondary);
  transform: translateY(-2px);
}

/* --- Search Box --- */
.search-box {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 4px 2px 12px;
  transition: all 0.3s ease;
  flex: 1;
  max-width: 300px;
}

.search-box:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.1);
}

.search-box input {
  background: transparent;
  border: none;
  color: white;
  font-size: 0.85rem;
  padding: 6px 0;
  width: 100%;
  outline: none;
}

.search-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: monospace;
  white-space: nowrap;
  margin: 0 8px;
}

.search-mini-btn {
  padding: 4px 8px !important;
  border-radius: 50% !important;
  font-size: 0.7rem !important;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Search Highlight */
.search-match {
  background-color: rgba(251, 191, 36, 0.4);
  color: #fff;
  border-bottom: 2px solid #fbbf24;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.search-match.current {
  background-color: #fbbf24;
  color: #000;
  box-shadow: 0 0 15px #fbbf24;
}

/* --- JSON Tree & Folding --- */
.json-tree {
  font-family: 'Fira Code', monospace;
}

.json-group {
  position: relative;
}

.json-line {
  display: flex;
  padding-left: 1.75rem;
  position: relative;
}

/* Vertical Guide Line */
.json-content {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  margin-left: 0.45rem;
  transition: all 0.3s ease;
}

.json-toggle {
  position: absolute;
  left: -0.8rem;
  top: 0.35rem;
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
  z-index: 5;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.json-toggle:hover {
  background: rgba(45, 212, 191, 0.2);
  color: var(--text-primary);
}

.json-toggle::before {
  content: '→';
  font-size: 0.7rem;
  transform: rotate(90deg);
  transition: transform 0.2s;
}

.json-toggle.collapsed::before {
  transform: rotate(-90deg);
}

.json-placeholder {
  display: none;
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.15);
  padding: 0 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  margin: 0 0.5rem;
  cursor: pointer;
  vertical-align: middle;
  border: 1px dashed rgba(45, 212, 191, 0.3);
}

.json-toggle.collapsed ~ .json-placeholder {
  display: inline-block;
}

.json-toggle.collapsed ~ .json-content,
.json-toggle.collapsed ~ .json-bracket:not(:first-of-type) {
  display: none;
}

/* --- Syntax Highlights --- */
.json-key { color: #99f6e4; }
.json-string { color: #34d399; }
.json-number { color: #fbbf24; }
.json-boolean { color: #f472b6; }
.json-null { color: #94a3b8; }
.json-bracket { color: #e2e8f0; font-weight: 500; }
.json-comma { color: #64748b; }

/* --- Footer --- */
footer {
  margin-top: auto;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-align: center;
  z-index: 10;
}
