/* Editor de código */
.editor-wrap {
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    transition: border-color 0.18s;
    margin-bottom: 0.75rem;
}

.editor-wrap.valid {
    border-color: #22c55e;
}

.editor-wrap.invalid {
    border-color: #ef4444;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
}

.editor-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 0.25rem;
}

.editor-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.18rem 0.55rem;
    border-radius: 20px;
    transition: all 0.2s;
}

.editor-status.idle {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

.editor-status.valid {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.editor-status.invalid {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.editor-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.tb-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    white-space: nowrap;
}

.tb-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.tb-btn:first-of-type {
    margin-left: auto;
}

.tb-btn+.tb-btn {
    margin-left: 0;
}

.json-textarea {
    width: 100%;
    min-height: 260px;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.85rem;
    color: #e2e8f0;
    padding: 0.9rem 1rem;
    resize: vertical;
    box-sizing: border-box;
    line-height: 1.7;
    tab-size: 2;
}

.json-textarea::placeholder {
    color: #334155;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.85rem;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-meta {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.7rem;
    color: #475569;
}

/* Barra de acciones */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 2px solid var(--border, #e2e8f0);
    background: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text, #1e293b);
    cursor: pointer;
    transition: all 0.14s;
    white-space: nowrap;
}

.action-btn:hover {
    border-color: var(--primary, #2563eb);
    color: var(--primary, #2563eb);
    background: rgba(37, 99, 235, 0.04);
}

.action-btn.btn-primary-action {
    background: var(--primary, #2563eb);
    border-color: var(--primary, #2563eb);
    color: #fff;
}

.action-btn.btn-primary-action:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* Panel de error */
.error-panel {
    display: none;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.84rem;
    color: #dc2626;
}

.error-panel.show {
    display: block;
}

.error-panel .error-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.error-panel .error-detail {
    line-height: 1.6;
}

.error-location {
    display: inline-block;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
}

/* Panel de éxito */
.success-panel {
    display: none;
    background: rgba(34, 197, 94, 0.07);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #16a34a;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.success-panel.show {
    display: flex;
}

/* Resultado formateado / minificado */
.output-block {
    display: none;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.output-block.show {
    display: block;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.9rem;
    background: #1e293b;
}

.output-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.output-copy-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.13s;
}

.output-copy-btn:hover {
    color: #e2e8f0;
}

.output-copy-btn.copied {
    color: #4ade80;
}

.output-pre {
    margin: 0;
    padding: 0.9rem 1rem;
    background: #0f172a;
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.82rem;
    color: #e2e8f0;
    overflow-x: auto;
    max-height: 340px;
    overflow-y: auto;
    line-height: 1.7;
    white-space: pre;
}

/* Syntax highlight colores */
.jk {
    color: #93c5fd;
}

/* key */
.js {
    color: #86efac;
}

/* string value */
.jn {
    color: #fbbf24;
}

/* number */
.jb {
    color: #f472b6;
}

/* boolean */
.jnu {
    color: #94a3b8;
}

/* null */
.jp {
    color: #64748b;
}

/* punctuation */

/* Estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    padding: 0.85rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border, #e2e8f0);
    background: #fff;
    text-align: center;
}

.stat-card .stat-val {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary, #2563eb);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

/* Árbol de estructura */
.tree-block {
    display: none;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.tree-block.show {
    display: block;
}

.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: var(--primary, #2563eb);
    color: #fff;
}

.tree-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
}

.tree-toggle-btn {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.13s;
}

.tree-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.tree-content {
    padding: 0.85rem 1rem;
    background: var(--bg-alt, #f8fafc);
    max-height: 320px;
    overflow-y: auto;
}

.tree-node {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.8rem;
    line-height: 1.8;
}

.tree-node .tn-key {
    color: #2563eb;
    font-weight: 700;
}

.tree-node .tn-str {
    color: #16a34a;
}

.tree-node .tn-num {
    color: #d97706;
    font-weight: 700;
}

.tree-node .tn-bool {
    color: #7c3aed;
    font-weight: 700;
}

.tree-node .tn-null {
    color: #94a3b8;
    font-style: italic;
}

.tree-node .tn-type {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-left: 0.3rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

.tree-node details>summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.tree-node details>summary::before {
    content: '▶ ';
    font-size: 0.65rem;
    color: #94a3b8;
}

.tree-node details[open]>summary::before {
    content: '▼ ';
}

.tree-node details>div {
    padding-left: 1.25rem;
    border-left: 2px solid var(--border, #e2e8f0);
    margin-left: 0.35rem;
}

/* Tabla de tipos JSON */
.ref-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border, #e2e8f0);
}

.ref-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    min-width: 420px;
}

.ref-table-wrap thead {
    background: var(--primary, #2563eb);
    color: #fff;
}

.ref-table-wrap thead th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.ref-table-wrap tbody tr:nth-child(even) {
    background: var(--bg-alt, #f8fafc);
}

.ref-table-wrap tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

.ref-table-wrap tbody td {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-family: 'Montserrat', sans-serif;
    color: var(--text, #1e293b);
    vertical-align: top;
    line-height: 1.55;
}

.ref-table-wrap tbody td code {
    font-family: 'Ubuntu', monospace, sans-serif;
    font-size: 0.82rem;
    background: var(--bg-alt, #f1f5f9);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    color: #2563eb;
}

.ref-table-wrap tbody tr:last-child td {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-bar {
        gap: 0.4rem;
    }

    .action-btn {
        font-size: 0.72rem;
        padding: 0.4rem 0.7rem;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}