/* JSON Formatter — tool-specific styles
   Layout, panels, buttons, tree viewer.
   shared.css handles: navbar, container, page-header, footer.
   ─────────────────────────────────────────────────────────── */

/* Ensure [hidden] always wins over component display values (flex/block/etc.) */
[hidden] { display: none !important; }

/* Visually hidden, available to screen readers (semantic H2 for tree view) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ══════════════════════════════════════════════════════════
   TOOL GRID — 2-column layout
   ══════════════════════════════════════════════════════════ */

.jf-tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}

@media (max-width: 768px) {
    .jf-tool-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   PANEL — white card with border + shadow
   ══════════════════════════════════════════════════════════ */

.jf-panel {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Output panel: clip inner dark blocks to rounded corners */
.jf-panel--output {
    overflow: hidden;
}

/* ── Panel header ── */
.jf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #F1F5F9;
    flex-shrink: 0;
}

.jf-panel-header h2 {
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    color: #0F172A !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    line-height: 1 !important;
}

/* ── Panel body (input panel content area) ── */
.jf-panel-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

/* ══════════════════════════════════════════════════════════
   UPLOAD ZONE
   ══════════════════════════════════════════════════════════ */

.upload-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1.5px dashed #CBD5E1;
    border-radius: 8px;
    background: #F8FAFC;
    color: #94A3B8;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: border-color 150ms, background 150ms, color 150ms;
}
.upload-zone:hover {
    border-color: #6366F1;
    border-style: dashed;
    background: #EEF2FF;
    color: #6366F1;
}
.upload-zone.drag-over {
    border-color: #6366F1;
    border-style: solid;
    background: #EEF2FF;
    color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.upload-zone-icon { flex-shrink: 0; }
.upload-zone:hover .upload-zone-icon { transform: translateY(-1px); transition: transform 150ms; }
.upload-zone-hint { font-size: 0.72rem; opacity: 0.7; }

/* ── File notice bar ── */
.file-notice {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #64748B;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    line-height: 1.5;
    margin: 0;
}
.file-notice.warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; font-weight: 500; }
.file-notice.error   { background: #FEF2F2; border-color: #FECACA; color: #991B1B; font-weight: 500; }

/* ══════════════════════════════════════════════════════════
   TEXTAREA (JSON input)
   ══════════════════════════════════════════════════════════ */

#json-input {
    width: 100%;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13.5px;
    color: #1E293B;
    background: #F8FAFC;
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    padding: 14px;
    min-height: 260px;
    resize: vertical;
    line-height: 1.65;
    transition: border-color 150ms, box-shadow 150ms;
    margin: 0;
}
#json-input:focus {
    outline: none;
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: #ffffff;
}
#json-input::placeholder { color: #CBD5E1; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */

.jf-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.jf-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 150ms, color 150ms, border-color 150ms, box-shadow 150ms;
    white-space: nowrap;
}
.jf-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Primary — indigo */
.jf-btn--primary {
    background: #6366F1;
    color: #ffffff;
    border-color: #6366F1;
}
.jf-btn--primary:hover:not(:disabled) {
    background: #4F46E5;
    border-color: #4F46E5;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Secondary — slate */
.jf-btn--secondary {
    background: #F1F5F9;
    color: #475569;
    border-color: #E2E8F0;
}
.jf-btn--secondary:hover:not(:disabled) {
    background: #E2E8F0;
    color: #1E293B;
}

/* Ghost — clear/danger */
.jf-btn--ghost {
    background: transparent;
    color: #64748B;
    border-color: #E2E8F0;
}
.jf-btn--ghost:hover:not(:disabled) {
    background: #FEF2F2;
    color: #DC2626;
    border-color: #FCA5A5;
}

/* Large file notice (> 5MB) */
.jf-large-file-notice {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    background: #FEF3C7;
    border: 1px solid #FCD34D;
    border-radius: 8px;
    font-size: 0.83rem;
    color: #92400E;
}
.jf-large-file-warn { font-weight: 600; }
.jf-large-file-cta { display: flex; align-items: center; gap: 4px; }
.jf-large-file-btn {
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    color: #6366F1;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}
.jf-large-file-btn:hover { color: #4F46E5; }

/* ══════════════════════════════════════════════════════════
   OUTPUT PANEL ACTIONS (download + copy)
   ══════════════════════════════════════════════════════════ */

.jf-output-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.download-btn,
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    border: 1.5px solid #E2E8F0;
    cursor: pointer;
    transition: background 150ms, color 150ms, border-color 150ms, box-shadow 150ms;
}

/* Download: gray when disabled, green when enabled */
.download-btn {
    background: #F8FAFC;
    color: #94A3B8;
}
.download-btn:not(:disabled) {
    background: #F0FDF4;
    border-color: #86EFAC;
    color: #16A34A;
}
.download-btn:not(:disabled):hover {
    background: #DCFCE7;
    border-color: #4ADE80;
    color: #15803D;
    box-shadow: 0 1px 4px rgba(22, 163, 74, 0.2);
}
.download-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Copy: slate default, green when copied */
.copy-btn {
    background: #F8FAFC;
    color: #64748B;
}
.copy-btn:hover {
    background: #EEF2FF;
    border-color: #A5B4FC;
    color: #6366F1;
}
.copy-btn.copied {
    background: #D1FAE5;
    border-color: #6EE7B7;
    color: #059669;
}

/* ══════════════════════════════════════════════════════════
   TEXT VIEW — controls + code output
   ══════════════════════════════════════════════════════════ */

.jf-text-view {
    padding: 14px 16px;
}

.jf-output-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.jf-control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.83rem;
    color: #64748B;
    cursor: pointer;
    font-weight: normal;
    margin: 0;
    line-height: 1.4;
}

/* Override shared.css label margin/size */
.jf-control-label input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: none;
    margin: 0;
    cursor: pointer;
    accent-color: #6366F1;
}

.jf-select {
    font-size: 0.83rem;
    padding: 3px 28px 3px 8px;
    border: 1.5px solid #E2E8F0;
    border-radius: 6px;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    outline: none;
    width: auto;
    margin: 0;
    transition: border-color 150ms;
    /* Custom arrow via shared.css is fine */
}
.jf-select:focus { border-color: #6366F1; }

/* ── JSON output code block ── */
#json-output {
    background: #1E293B;
    color: #E2E8F0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.65;
    min-height: 220px;
    max-height: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: none;
    margin: 0;
}

/* Line numbers (exclude from selection/copy) */
.line-number {
    user-select: none;
    opacity: 0.35;
    font-size: 0.8em;
    min-width: 2ch;
    display: inline-block;
    text-align: right;
    margin-right: 5px;
}

/* ── Result info footer ── */
.result-info {
    display: flex;
    gap: 14px;
    padding: 10px 16px;
    flex-wrap: wrap;
    color: #94A3B8;
    font-size: 0.78rem;
    border-top: 1px solid #F1F5F9;
}
#result-size, #result-time { color: #94A3B8; }

/* Status text */
.valid   { color: #10B981; font-weight: 500; }
.invalid { color: #EF4444; font-weight: 500; }

/* Enhanced error display (line/column, context, suggestion) */
#json-output code.error { display: block; line-height: 1.6; }
#json-output .error-loc  { color: #94A3B8; font-size: 0.9em; }
#json-output .error-ctx  { color: #FCD34D; font-family: monospace; word-break: break-all; }
#json-output .error-hint  { color: #6EE7B7; font-size: 0.95em; }


/* ══════════════════════════════════════════════════════════
   JSON Tree Viewer
   ROW_H in json-tree.js MUST stay in sync with .jt-row (22px)
   ══════════════════════════════════════════════════════════ */

#json-tree {
    background: #1E293B;
    color: #E2E8F0;
    /* outer panel overflow:hidden clips; only bottom corners needed */
    border-radius: 0 0 12px 12px;
    overflow: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 22px;   /* SYNC with ROW_H = 22 in json-tree.js */
    min-height: 220px;
    max-height: 70vh;
    border: none;
    position: relative;
}

.jt-row {
    height: 22px;        /* SYNC with ROW_H = 22 in json-tree.js */
    line-height: 22px;
    white-space: nowrap;
    padding-right: 16px;
    box-sizing: border-box;
    display: block;
}
.jt-row:hover { background: rgba(255, 255, 255, 0.05); }

.jt-arr {
    display: inline-block;
    width: 14px;
    font-size: 9px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    color: #64748B;
    vertical-align: middle;
    transition: color 120ms ease;
}
.jt-arr:hover { color: #C4B5FD; }
.jt-spc { display: inline-block; width: 14px; }

/* Token colors */
.jt-k    { color: #C4B5FD; }
.jt-str  { color: #86EFAC; }
.jt-num  { color: #93C5FD; }
.jt-bool { color: #FCD34D; }
.jt-null { color: #94A3B8; }
.jt-b    { color: #F1F5F9; }
.jt-p    { color: #475569; }
.jt-sum  { color: #64748B; font-style: italic; padding: 0 5px; }

/* ── Tree toolbar ── */
.jt-search-panel {
    background: #141E2E;
    border-top: none;
    border-bottom: 1px solid #2D3748;
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.jt-search-row,
.jt-path-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
}

/* Use .jt-search-panel parent to beat shared.css input[type="text"] (0-1-1) specificity */
.jt-search-panel .jt-search-input,
.jt-search-panel .jt-path-input {
    flex: 1;
    min-width: 0;
    width: auto !important;
    background: #0F172A !important;
    border: 1px solid #334155 !important;
    border-radius: 4px !important;
    color: #E2E8F0 !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    font-family: 'JetBrains Mono', 'Consolas', monospace !important;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
    margin: 0 !important;
    resize: none;
    box-sizing: border-box;
    line-height: 1.4;
}
.jt-search-panel .jt-search-input:focus,
.jt-search-panel .jt-path-input:focus {
    border-color: #6366F1 !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
    outline: none !important;
}
.jt-search-panel .jt-search-input::placeholder,
.jt-search-panel .jt-path-input::placeholder { color: #475569; }

.jt-search-count {
    color: #64748B;
    font-size: 11px;
    white-space: nowrap;
    min-width: 40px;
    text-align: right;
}
.jt-search-count.has-matches { color: #A5B4FC; }

.jt-search-nav-btn,
.jt-search-clear-btn {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #94A3B8;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    padding: 4px 7px;
    transition: background 120ms, color 120ms;
    white-space: nowrap;
    flex-shrink: 0;
}
.jt-search-nav-btn:hover,
.jt-search-clear-btn:hover {
    background: #334155;
    color: #E2E8F0;
}

.jt-path-label {
    color: #64748B;
    font-family: monospace;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

.jt-path-go-btn {
    background: #312E81;
    border: 1px solid #4338CA;
    border-radius: 4px;
    color: #A5B4FC;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 120ms;
}
.jt-path-go-btn:hover { background: #3730A3; color: #C7D2FE; }

.jt-path-status { color: #64748B; font-size: 11px; white-space: nowrap; min-width: 0; }
.jt-path-status.error { color: #F87171; }
.jt-path-status.ok    { color: #86EFAC; }

.jt-large-badge {
    background: #422006;
    border: 1px solid #854D0E;
    border-radius: 3px;
    color: #FCD34D;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Streaming progress bar ── */
.stream-progress-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #141E2E;
    border-bottom: 1px solid #2D3748;
    font-size: 12px;
    color: #94A3B8;
}
.stream-progress-label {
    color: #94A3B8;
    white-space: nowrap;
}
.stream-progress-track {
    flex: 1;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    overflow: hidden;
}
.stream-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366F1, #818CF8);
    border-radius: 3px;
    transition: width 80ms ease-out;
}
.stream-progress-text {
    font-weight: 600;
    color: #A5B4FC;
    min-width: 3ch;
}

/* Row highlight states */
.jt-row.jt-hl        { background: rgba(250, 204, 21, 0.10); }
.jt-row.jt-hl-active {
    background: rgba(250, 204, 21, 0.28);
    outline: 1px solid rgba(234, 179, 8, 0.55);
    outline-offset: -1px;
}

/* ══════════════════════════════════════════════════════════
   SEO / Content sections
   ══════════════════════════════════════════════════════════ */

.related-tools { margin-bottom: 24px; }
.related-tools h3 { font-size: 0.95rem; font-weight: 600; color: #0F172A; margin-bottom: 14px; }

.tool-links { display: flex; gap: 10px; flex-wrap: wrap; }
.tool-links a {
    padding: 7px 14px;
    background: #F8FAFC;
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    color: #64748B;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: border-color 150ms, color 150ms, background 150ms;
}
.tool-links a:hover { border-color: #6366F1; color: #6366F1; background: #EEF2FF; }

.seo-content {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-left: 4px solid #6366F1;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.seo-content h2 { font-size: 1.1rem; color: #0F172A; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #F1F5F9; }
.seo-content h3 { font-size: 0.93rem; font-weight: 600; color: #1E293B; margin: 16px 0 6px; }
.seo-content p  { line-height: 1.8; margin-bottom: 10px; color: #64748B; font-size: 0.88rem; }
.seo-content ul, .seo-content ol { margin: 6px 0 10px 20px; color: #64748B; font-size: 0.88rem; }
.seo-content li { margin: 4px 0; line-height: 1.6; }
.seo-content strong { color: #1E293B; font-weight: 600; }
.seo-content pre {
    background: #1E293B; color: #E2E8F0;
    border-radius: 8px; padding: 14px; margin: 10px 0;
    font-size: 13px; border: none; min-height: auto; max-height: none;
}
