@import "../loremipsum/style.css";

/* ═══════════════════════════════════════════
   JSON Formatter & Validator — tool-specific CSS
   ═══════════════════════════════════════════ */

/* Language Switcher */
.lang-switcher { position: relative; }
.lang-btn { display: flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.625rem; border-radius: 0.375rem; border: 1px solid var(--border-color); background: var(--bg-panel); color: var(--text-secondary); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
.lang-btn:hover { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-hover); }
.lang-dropdown { position: absolute; top: calc(100% + 6px); right: 0; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 0.5rem; padding: 0.35rem; display: flex; flex-direction: column; gap: 0.2rem; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3); z-index: 100; min-width: 130px; }
.lang-option { background: none; border: none; color: var(--text-secondary); font-size: 0.78rem; font-weight: 500; padding: 0.4rem 0.65rem; border-radius: 0.35rem; text-align: left; cursor: pointer; transition: all 0.15s ease; }
.lang-option:hover { background: var(--bg-hover); color: var(--text-primary); }
.lang-option.active { color: var(--accent-color); background: var(--accent-glow, rgba(205, 92, 62, 0.1)); font-weight: 600; }

.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

/* Input textarea + dropzone */
#dropzone {
  transition: border-color 0.2s ease, background 0.2s ease;
}

#dropzone.dragover {
  border-color: var(--accent-color);
  background: rgba(205, 92, 62, 0.06);
}

.json-input-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--table-header-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.75rem;
  color: var(--text-primary);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease;
}

.json-input-textarea:focus {
  border-color: var(--accent-color);
}

.input-actions-row {
  display: flex;
  gap: 0.5rem;
}

.input-actions-row .btn {
  flex: 1;
}

/* Error / valid banners */
.error-banner,
.valid-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.78rem;
  line-height: 1.4;
}

.error-banner {
  background: rgba(190, 85, 95, 0.1);
  border: 1px solid rgba(190, 85, 95, 0.3);
  color: var(--error-color, #BE555F);
}

.error-banner svg {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.valid-banner {
  background: rgba(108, 142, 108, 0.1);
  border: 1px solid rgba(108, 142, 108, 0.3);
  color: var(--success-color);
}

/* Statistics panel */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--table-header-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stats-types-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.type-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--table-header-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.type-chip b {
  color: var(--text-primary);
  font-weight: 700;
}

.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.type-dot.type-object { background: #6C8E6C; }
.type-dot.type-array { background: #D98C3A; }
.type-dot.type-string { background: #CD5C3E; }
.type-dot.type-number { background: #7d8cc4; }
.type-dot.type-boolean { background: #c48a7d; }
.type-dot.type-null { background: #8a8377; }

/* Tree search input (in output-header) */
.tree-search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--table-header-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  color: var(--text-muted);
  min-width: 220px;
}

.tree-search-wrapper input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  width: 100%;
}

.tree-search-wrapper input::placeholder {
  color: var(--text-muted);
}

/* Code output (Formatted / TypeScript tabs) */
.code-view code#output-formatted,
.code-view code#output-typescript {
  color: var(--text-primary);
}

/* JSON syntax coloring shared between code view (not applied, plain) and tree */
.tree-key {
  color: var(--accent-color);
  font-weight: 600;
}

.tree-punc {
  color: var(--text-muted);
}

.tree-value.type-string { color: #6C8E6C; }
.tree-value.type-number { color: #7d8cc4; }
.tree-value.type-boolean { color: #D98C3A; }
.tree-value.type-null { color: var(--text-muted); font-style: italic; }
.tree-value.type-preview { color: var(--text-muted); }

/* Tree View container */
.tree-view {
  padding: 1.25rem 1.5rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  overflow-x: auto;
}

.tree-root {
  min-width: max-content;
}

.tree-node {
  position: relative;
}

.tree-children {
  margin-left: 1.1rem;
  border-left: 1px dashed var(--border-color);
  padding-left: 0.65rem;
}

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

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.3rem;
  border-radius: 0.3rem;
  cursor: pointer;
  user-select: none;
}

.tree-row:hover {
  background: var(--bg-hover);
}

.tree-row:hover .tree-key,
.tree-row:hover .tree-value {
  text-decoration: underline dotted;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
}

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

.tree-toggle-spacer {
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}

.tree-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.tree-row mark {
  background: rgba(217, 140, 58, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.tree-empty-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: 0.5rem;
}

/* Toast (click-to-copy path confirmation) */
.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-main);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.copy-toast code {
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .tree-search-wrapper {
    min-width: 0;
    flex: 1;
  }
}
