/**
 * JSON Formatter & Validator — Tool Interface Styles
 * Scoped under .jf-* prefix to avoid conflicts with global styles.
 * Tool accent color: #06B6D4 (cyan)
 */

/* ============================================================
   SECTION WRAPPER
   ============================================================ */
.jf-tool-section {
    padding: 60px 0 70px;
    background: #FFFFFF;
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.jf-section-header {
    text-align: center;
    margin-bottom: 32px;
}

.jf-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(14, 165, 233, 0.08) 100%);
    border: 1px solid rgba(6, 182, 212, 0.22);
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0891b2;
    margin-bottom: 14px;
}

.jf-badge i {
    font-size: 17px;
}

.jf-section-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 580px;
    margin: 0 auto;
    line-height: 1.65;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.jf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
}

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

.jf-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.jf-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jf-toolbar-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* -- Indent Buttons -- */
.jf-indent-btns {
    display: flex;
    align-items: center;
    gap: 4px;
}

.jf-indent-btn {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.jf-indent-btn input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.jf-indent-btn span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 28px;
    padding: 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #fff;
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.jf-indent-btn input[type="radio"]:checked+span {
    background: #06B6D4;
    color: #fff;
    border-color: #06B6D4;
}

/* -- Auto-format Toggle -- */
.jf-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.jf-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.jf-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 20px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.jf-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: left 0.2s ease;
}

.jf-toggle input:checked~.jf-toggle-track {
    background: #06B6D4;
}

.jf-toggle input:checked~.jf-toggle-track .jf-toggle-thumb {
    left: 18px;
}

.jf-toggle-text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* -- Upload Button -- */
.jf-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #fff;
    border: 1px solid rgba(100, 116, 139, 0.22);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.jf-upload-btn:hover {
    background: #f1f5f9;
    border-color: #06B6D4;
    color: #0891b2;
}

/* ============================================================
   DROP ZONE + TEXTAREA
   ============================================================ */
.jf-drop-zone {
    position: relative;
    border: 1px solid rgba(100, 116, 139, 0.18);
    border-radius: 0;
    background: #fff;
    transition: border-color 0.2s ease;
}

.jf-drop-zone:focus-within {
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.07);
}

.jf-drop-zone.jf-dragging {
    border-color: #06B6D4;
    background: rgba(6, 182, 212, 0.03);
}

.jf-drop-zone.jf-dragging .jf-drop-overlay {
    display: flex;
}

.jf-textarea {
    display: block;
    width: 100%;
    min-height: 340px;
    padding: 18px 20px;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.65;
    color: #1e293b;
    background: transparent;
    border: none;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
    tab-size: 2;
}

.jf-textarea::placeholder {
    color: #94a3b8;
    font-family: inherit;
}

/* Drag overlay */
.jf-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(6, 182, 212, 0.06);
    border: 2px dashed #06B6D4;
    border-radius: inherit;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    z-index: 2;
}

.jf-drop-overlay i {
    font-size: 2.4rem;
    color: #06B6D4;
}

.jf-drop-overlay span {
    font-size: 1rem;
    font-weight: 600;
    color: #0891b2;
}

/* ============================================================
   URL FETCH ROW
   ============================================================ */
.jf-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-top: none;
}

.jf-url-input {
    flex: 1;
    padding: 7px 12px;
    font-size: 0.8125rem;
    color: #1e293b;
    background: #fff;
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.jf-url-input::placeholder {
    color: #94a3b8;
}

.jf-url-input:focus {
    border-color: #06B6D4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

/* ============================================================
   STATS BAR
   ============================================================ */
.jf-stats-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-top: none;
    border-radius: 0 0 14px 14px;
    margin-bottom: 16px;
}

.jf-stat {
    font-size: 0.775rem;
    color: #94a3b8;
    font-weight: 500;
}

.jf-stat--hint {
    margin-left: auto;
    font-style: italic;
}

/* ============================================================
   ACTION BUTTONS
   ============================================================ */
.jf-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

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

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

/* ---- Base Button ---- */
.jf-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
}

.jf-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.jf-btn i {
    font-size: 16px;
    flex-shrink: 0;
}

.jf-btn:active:not(:disabled) {
    transform: translateY(1px);
}

/* Primary */
.jf-btn--primary {
    background: #06B6D4;
    color: #fff;
    border-color: #06B6D4;
}

.jf-btn--primary:hover:not(:disabled) {
    background: #0891b2;
    border-color: #0891b2;
}

/* Secondary */
.jf-btn--secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: rgba(100, 116, 139, 0.22);
}

.jf-btn--secondary:hover:not(:disabled) {
    background: #e2e8f0;
    color: #334155;
    border-color: rgba(100, 116, 139, 0.3);
}

/* Ghost */
.jf-btn--ghost {
    background: transparent;
    color: #64748b;
    border-color: rgba(100, 116, 139, 0.22);
}

.jf-btn--ghost:hover:not(:disabled) {
    background: #f1f5f9;
    color: #334155;
    border-color: rgba(100, 116, 139, 0.3);
}

/* Small */
.jf-btn--sm {
    padding: 6px 13px;
    font-size: 0.8125rem;
}

/* Extra small */
.jf-btn--xs {
    padding: 5px 11px;
    font-size: 0.775rem;
}

/* ============================================================
   STATUS AREA
   ============================================================ */
.jf-status {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.55;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.jf-status i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.jf-status--success {
    background: rgba(16, 185, 129, 0.07);
    border-color: rgba(16, 185, 129, 0.25);
    color: #065f46;
}

.jf-status--success i {
    color: #10b981;
}

.jf-status--error {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.22);
    color: #7f1d1d;
}

.jf-status--error i {
    color: #ef4444;
}

.jf-status--info {
    background: rgba(6, 182, 212, 0.07);
    border-color: rgba(6, 182, 212, 0.22);
    color: #164e63;
}

.jf-status--info i {
    color: #06B6D4;
}

/* ============================================================
   TREE VIEW PANEL
   ============================================================ */
.jf-tree-panel {
    border: 1px solid rgba(100, 116, 139, 0.16);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    margin-top: 4px;
}

.jf-tree-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 13px 18px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(100, 116, 139, 0.14);
}

.jf-tree-panel-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
}

.jf-tree-panel-title i {
    font-size: 17px;
    color: #06B6D4;
}

.jf-tree-panel-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---- Tree Root ---- */
.jf-tree-root {
    padding: 16px 20px;
    max-height: 540px;
    overflow-y: auto;
    overflow-x: auto;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* ---- Tree Node ---- */
.jf-tree-node {
    position: relative;
    padding-left: 20px;
}

.jf-tree-node-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px;
    cursor: pointer;
    border-radius: 6px;
    padding: 2px 6px 2px 0;
    transition: background 0.12s ease;
    user-select: none;
}

.jf-tree-node-header:hover {
    background: rgba(6, 182, 212, 0.06);
}

/* Leaf rows are not clickable — override */
.jf-tree-leaf {
    cursor: default;
}

.jf-tree-leaf:hover {
    background: transparent;
}

/* ---- Toggle Arrow ---- */
.jf-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 2px;
    color: #94a3b8;
    transition: color 0.12s;
}

.jf-tree-node-header:hover .jf-tree-toggle {
    color: #06B6D4;
}

/* ---- Key / Bracket / Values ---- */
.jf-k {
    color: #0c4a6e;
    font-weight: 600;
}

.jf-tree-colon {
    color: #64748b;
}

.jf-tree-bracket {
    color: #475569;
    font-weight: 700;
}

.jf-tree-summary {
    display: none;
    font-size: 0.775rem;
    color: #94a3b8;
    font-weight: 500;
    margin: 0 4px;
    font-style: italic;
}

/* ---- Value Colors ---- */
.jf-v--str {
    color: #166534;
}

/* green */
.jf-v--num {
    color: #9a3412;
}

/* orange */
.jf-v--bool {
    color: #6d28d9;
}

/* purple */
.jf-v--null {
    color: #94a3b8;
    font-style: italic;
}

/* gray */

/* ---- Children ---- */
.jf-tree-children {
    border-left: 1.5px solid rgba(100, 116, 139, 0.15);
    margin-left: 6px;
    padding-left: 14px;
}

/* ---- Collapsed state ---- */
.jf-tree-node[data-collapsed="true"]>.jf-tree-children,
.jf-tree-node[data-collapsed="true"]>.jf-tree-bracket-bottom {
    display: none;
}

.jf-tree-node[data-collapsed="true"]>.jf-tree-node-header .jf-tree-summary {
    display: inline;
}

/* ---- Bottom-bracket (closing bracket after children) ---- */
.jf-tree-bracket-bottom {
    padding-left: 4px;
    color: #475569;
    font-weight: 700;
    display: block;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* ---- Root level: no left padding ---- */
.jf-tree-root>.jf-tree-node {
    padding-left: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .jf-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .jf-toolbar-right {
        justify-content: flex-start;
    }

    .jf-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .jf-actions-left,
    .jf-actions-right {
        justify-content: flex-start;
    }

    .jf-textarea {
        min-height: 240px;
        font-size: 0.8125rem;
    }

    .jf-tree-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .jf-stat--hint {
        display: none;
    }
}