/* --- Import Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

/* --- Color & Style Palette --- */
:root {
    /* Base & Backgrounds */
    --bg-primary: #111827;      /* Deep, cool-toned charcoal */
    --bg-secondary: #1F2937;    /* Lighter slate for panels/inputs */
    --bg-tertiary: #374151;     /* Medium grey for interaction */
    --border-color: #374151;     /* Softer, less distracting border */

    /* Text */
    --text-primary: #F9FAFB;     /* Soft off-white, easy on the eyes */
    --text-secondary: #9CA3AF;   /* Muted grey for labels/placeholders */

    /* Accent */
    --accent-primary: #3B82F6;   /* Vibrant, modern blue */
    --accent-primary-hover: #2563EB; /* Darker blue for hover */

    /* JSON Syntax Highlighting */
    --json-key: #A5B4FC;         /* Soft Indigo */
    --json-string: #FBCFE8;      /* Subtle Rose */
    --json-number: #A7F3D0;      /* Mint Green */
    --json-boolean: #FDE68A;     /* Pale Yellow */
    --json-null: #FDA4AF;         /* Soft Coral */

    /* Other */
    --highlight-bg: rgba(59, 130, 246, 0.3); /* Semi-transparent accent for search */
    --highlight-text: var(--text-primary);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.15);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.2);
    --radius: 8px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Menlo', 'Consolas', monospace;
}

/* --- General & Reset --- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent-primary); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--accent-primary-hover); text-decoration: none; }
code {
    background-color: var(--bg-secondary);
    padding: 3px 6px;
    border-radius: 5px;
    font-family: var(--font-mono);
    color: var(--json-string);
    font-size: 0.9em;
}

/* --- Main Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* OLD .app-header rules are removed */

.hero-section {
    /* Further reduced padding for a super compact header */
    padding: 16px 24px; 
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Reduced margin-bottom as the paragraph is closer now */
    margin-bottom: 12px; 
}

.hero-section h2 {
    /* This makes the title centered in the available space */
    flex-grow: 1;
    text-align: center;
    /* Remove default margins and add a little horizontal space */
    margin: 0 24px; 
    font-size: 20px; /* Slightly smaller to fit nicely */
    font-weight: 600; /* A bit lighter than before */
    color: var(--text-secondary); /* Muted color to act as a subtitle */
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 18px;
}
.logo i {
    font-size: 26px;
    color: var(--accent-primary);
}
.hero-header nav {
    display: flex;
    gap: 8px;
}
.hero-header nav a {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.hero-header nav a:hover {
    color: var(--text-primary);
}
.hero-section h2 {
    font-size: 24px;
    margin: 0 0 8px 0;
    font-weight: 700;
    text-align: center;
}
.hero-section p {
    margin: 0;
    color: var(--text-secondary);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
    text-align: center;
}

.main-content {
    display: flex;
    flex-grow: 1;
}
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}
.input-panel { border-right: 1px solid var(--border-color); background-color: var(--bg-secondary); }
.output-panel { background-color: var(--bg-primary); }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-header h3 { margin: 0; font-size: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }
.input-controls { display: flex; align-items: center; gap: 10px; }
/* ADD THESE THREE NEW RULES */

/* 1. Shared Styles for both buttons and the select box */
.control-btn,
.control-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    height: 38px;
    padding: 0 14px; /* Vertical padding is now controlled by height */
}
.control-btn:hover, 
.control-select:hover { 
    background-color: #4B5563; 
    border-color: #6B7280; 
}
.control-btn:active { 
    transform: scale(0.97); 
}

/* 2. Styles specific to Buttons */
.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* 3. Styles specific to the Select dropdown */
.control-select {
    /* This removes the native OS "3D" styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* This adds our own custom arrow using an embedded SVG */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239CA3AF' viewBox='0 0 256 256'%3E%3Cpath d='M215.39,92.61l-80,80a8,8,0,0,1-11.32,0l-80-80a8,8,0,0,1,11.32-11.32L128,154.69l74.07-73.4a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 1em;

    /* This adds space on the right so text doesn't overlap our new arrow */
    padding-right: 36px;
}
/*
.control-btn, .control-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    height: 38px;
}

.control-btn i { font-size: 18px; }
.control-btn:hover, .control-select:hover { background-color: #4B5563; border-color: #6B7280; }
.control-btn:active { transform: scale(0.97); }
*/
textarea#json-input {
    flex-grow: 1;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
textarea#json-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* --- Tab System --- */
.tab-switcher { display: flex; border-bottom: 1px solid var(--border-color); flex-shrink: 0; padding: 0 8px; }
.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    padding: 12px 16px;
    margin-bottom: -1px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }
.tab-content-area { overflow-y: auto; flex-grow: 1; padding-top: 24px; }
.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }
.placeholder-text { color: var(--text-secondary); padding: 16px; text-align: center; }
.placeholder-text.error { color: var(--json-null); }


/* --- Tree View Styling --- */
.tree-view-toolbar {
    background-color: var(--bg-secondary);
    padding: 8px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
}
.search-box { display: flex; align-items: center; flex-grow: 1; }
.search-box i { margin: 0 12px; color: var(--text-secondary); }
.search-box input { background: none; border: none; color: var(--text-primary); padding: 8px 0; outline: none; width: 100%; font-size: 15px; }
.search-count { color: var(--text-secondary); font-size: 13px; white-space: nowrap; padding-right: 8px; }

.path-breadcrumbs {
    display: none;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    margin-bottom: 16px;
}
.path-breadcrumbs:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }
.path-breadcrumbs.hidden {
    display: none;
}
#json-viewer {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
}
#json-viewer ul { list-style-type: none; padding-left: 28px; border-left: 1px solid #2a3547; margin: 4px 0; }
#json-viewer .root-level { padding-left: 4px; border-left: none; }
.tree-node { position: relative; }
.tree-node .key { color: var(--json-key); cursor: pointer; user-select: none; font-weight: 500; }
.tree-node .value { margin-left: 10px; }
.toggle {
    cursor: pointer;
    position: absolute;
    left: -22px;
    top: 4px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.toggle::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 7px;
    border-color: transparent transparent transparent currentColor;
    transition: transform 0.2s ease;
}
.collapsed > .key > .toggle { transform: rotate(-90deg); }
.collapsed > ul { display: none; }

.value-string { color: var(--json-string); }
.value-number { color: var(--json-number); }
.value-boolean { color: var(--json-boolean); font-weight: bold; }
.value-null { color: var(--json-null); font-style: italic; }
.highlight { background-color: var(--highlight-bg); color: var(--highlight-text); border-radius: 4px; padding: 2px 4px; }

/* --- Docs and Insights --- */
.docs-content { line-height: 1.7; padding: 0 16px; }
.docs-content h3 { border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-top: 32px; display: flex; align-items: center; gap: 10px; font-size: 1.3em; }
.insight-card { background-color: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.insight-card h4 { margin: 0 0 16px 0; color: var(--text-primary); display: flex; align-items: center; gap: 10px; font-size: 1.1em; font-weight: 600; }
.insight-card h5 { margin: 20px 0 10px 0; color: var(--text-secondary); text-transform: uppercase; font-size: 0.9em; letter-spacing: 0.05em; }
.insight-card ul { margin: 0; padding-left: 20px; line-height: 1.8; }
.insight-card li { margin-bottom: 4px; }
.insight-card .text-muted { color: var(--text-secondary); font-size: 0.9em; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; font-size: 15px; }
.stats-grid > div > strong { font-weight: 500; color: var(--text-secondary); }

.insight-card-issue {
    background-color: var(--issue-bg);
    border-color: var(--issue-border);
}
.insight-card-issue h4 {
    color: var(--issue-border); /* Make the heading text match the border for emphasis */
}

/* --- Footer --- */
.app-footer { text-align: center; padding: 16px; font-size: 13px; color: var(--text-secondary); border-top: 1px solid var(--border-color); flex-shrink: 0; background-color: var(--bg-secondary); }

/* --- Notice Bar --- */
.notice-bar {
    display: none;
    align-items: center;
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}
.notice-bar.visible { display: flex; }
.notice-bar i { font-size: 20px; color: var(--accent-primary); margin-right: 12px; flex-shrink: 0; }
.notice-bar span { flex-grow: 1; color: #D1D5DB; }
.notice-bar button { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 4px; margin-left: 12px; flex-shrink: 0; border-radius: 50%; display:flex; align-items:center; justify-content:center; }
.notice-bar button:hover { color: var(--text-primary); background-color: rgba(255,255,255,0.1); }

/* --- Focus Mode Styles --- */
.focus-mode .hero-section {
    display: none;
}

.focus-mode .main-content {
    /* When focused, the main content should be the full screen height */
    height: 100vh;
    min-height: 100vh;
}

.focus-mode #focus-mode-btn {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.focus-mode #focus-mode-btn i {
    /* Changes the icon to "corners-in" when active */
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%23F9FAFB' viewBox='0 0 256 256'%3E%3Cpath d='M216,96V64a8,8,0,0,0-8-8H176a8,8,0,0,0,0,16h24V96a8,8,0,0,0,16,0ZM80,56H48V80a8,8,0,0,1-16,0V48a8,8,0,0,1,8-8H80a8,8,0,0,1,0,16Zm128,112H176a8,8,0,0,0,0,16h32v32a8,8,0,0,0,16,0V176A8,8,0,0,0,208,168ZM80,184a8,8,0,0,0-8,8v24H48a8,8,0,0,0,0,16H80a8,8,0,0,0,8-8V184A8,8,0,0,0,80,184Z'%3E%3C/path%3E%3C/svg%3E");
}