﻿
/* === MODIFICATION 1: Global Box Sizing Reset === */
/* This is the key fix for the width/padding issue. It tells the browser */
/* to include padding and borders *inside* an element's total width. */
*, *::before, *::after {
    box-sizing: border-box;
}


body {
    margin: 0;
    /*font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;*/
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

h1 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
    color: var(--heading-color);
}

#searchBox {
    width: 100%;
    flex-grow: 1;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid var(--input-border-color);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--input-bg-color);
    color: var(--input-text-color);
}

    #searchBox:focus {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px var(--accent-focus-shadow);
        outline: none;
    }

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface-bg-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px var(--shadow-color);
}

thead {
    background-color: var(--accent-color);
    color: var(--accent-text-color);
}

    thead th {
        text-align: left;
        padding: 0.75rem 1rem;
        font-weight: 600;
    }

tbody tr {
    border-bottom: 1px solid var(--border-color);
}

    tbody tr:hover {
        background-color: var(--hover-bg-color);
    }

    /*    tbody tr.cursor-active > td:first-child::before {
        content: '>>> ';
    }
*/
    tbody tr.cursor-active {
        box-shadow: inset 0px 0px 9px 7px var(--search-highlight);
    }

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    /* === ADDITION: Prevent long strings from breaking table layout === */
    word-break: break-word;
}

/* === MODIFICATION 2: Responsive Sticky Header === */
.sticky-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    z-index: 100;
    /* Consistent padding with the content views below */
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px -1px var(--sticky-shadow-color);
}

.control-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 1.0rem;
}

#searchView, #blueprintView {
    padding: 2rem; /* Simplified padding */
}

#blueprintView {
    display: flex;
    max-height: calc(100vh - 200px);
}

#bp-content {
    flex-grow: 1;
}

#bp-references {
    padding-left: 1rem;
    min-width: fit-content;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#bp-content,
#bp-references {
    overflow-y: auto;
    overflow-x: hidden;
}

    #bp-references > a {
        display: block;
    }

.json-view,
#blueprintView,
.bp-root {
    box-shadow: 0px 11px 11px 3px var(--sticky-shadow-color);
}

/*.bp-row {
    display: grid;*/
/*font-family: Consolas, monospace;*/
/*line-height: 1.4;
    padding: 2px 5px;
    border-bottom: 1px solid var(--bp-row-border);
    grid-template-columns: 32px 200px 1fr;
}*/

.bp-node:last-child > .bp-row {
    border-bottom: initial;
}

.bp-row:hover {
    background-color: var(--bp-row-hover-bg);
}


.bp-type {
    font-weight: bold;
}

.bp-key {
    font-weight: bold;
    color: var(--bp-key-color);
    user-select: all;
    margin-right: 1em;
}

    .bp-key::after {
        content: ':';
    }

.bp-val {
    user-select: all;
}

.bp-row {
    --indent-per-level: 30px; /* Or your preferred indent */
    --key-column-width: 350px; /* A fixed width for all keys */
}

@media (max-width: 768px) {
    .bp-row {
        --key-column-width: 260px;
    }
}

.bp-row {
    display: flex;
    align-items: baseline; /* Aligns text across different spans */
    line-height: 1.4;
    padding: 2px 5px;
    border-bottom: 1px solid var(--bp-row-border);
    /* The magic: Calculate indentation based on depth */
}

    /* Give toggle and key fixed widths so they don't shrink */
    .bp-row > .bp-toggle,
    .bp-row > .bp-toggle-placeholder {
        flex-shrink: 0;
        width: 20px;
    }

    .bp-row > .bp-key {
        flex-shrink: 0;
        width: var(--key-column-width);
        /* Optional: for long keys */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* The value and type will now naturally fall into place */
    .bp-row > .bp-val,
    .bp-row > .bp-type,
    .bp-row > .bp-link {
        /* No special styling needed */
        margin-left: calc(-1 * var(--depth, 0) * var(--indent-per-level));
        /*calc(1 * var(--depth, 0) * var(--indent-per-level));*/
    }

.bp-link {
    color: var(--bp-link-color);
    text-decoration: underline;
    cursor: pointer;
}

    .bp-link:hover {
        background-color: var(--bp-link-hover-bg);
    }

/* General Button Styles */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    background-color: var(--btn-bg);
    color: var(--btn-text-color);
}

    .btn:hover {
        background-color: var(--btn-hover-bg);
    }

    .btn:active {
        background-color: var(--btn-active-bg);
        transform: translateY(1px);
    }

    .btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px var(--accent-focus-shadow);
    }

    .btn:disabled {
        opacity: 0.7;
        pointer-events: none;
    }

/* Primary Button Modifier */
.btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text-color);
}

    .btn-primary:hover {
        background-color: var(--btn-primary-hover-bg);
    }

.toggle-active > .btn {
    box-shadow: inset 0px 0px 4px 4px var(--toggle-highlight);
}

.toggle-inactive > .btn {
}


.bp-toggle {
    background-color: var(--btn-bg);
    border: 1px solid var(--border-color);
    color: var(--btn-text-color);
    border-radius: 3px;
    height: 20px;
    width: 20px;
    line-height: 20px;
    text-align: center;
    vertical-align: middle;
    margin-right: 4px;
    cursor: pointer;
    user-select: none;
    display: inline-block;
    transition: background-color 0.25s ease-in-out, border-color 0.25s ease-in-out, transform 0.07s;
    transition-property: background-color, transform;
}

    .bp-toggle:hover {
        background-color: var(--btn-hover-bg);
        border-color: var(--input-border-color);
    }

    .bp-toggle.collapsed {
        transform: rotate(-90deg);
    }

    .bp-toggle.disabled {
        opacity: 0.4;
        pointer-events: none;
    }

.bp-toggle-placeholder {
    display: inline-block;
    width: 20px;
    height: 22px;
    margin-right: 4px;
    vertical-align: middle;
}

.bp-children-container {
    background: linear-gradient( to bottom, var(--bp-row-border) calc(100% - 1.2rem), transparent calc(100% - 0.2rem) ) 4px / 1px no-repeat;
    padding-left: 19px;
    margin-left: 10px;
}

    .bp-children-container.hide {
        display: none;
    }

a {
    color: inherit;
}

#theme-toggle-label::after {
    content: "Dark/Light";
}

#show-help-label::after {
    content: "Help";
}

.title-bar {
    display: flex;
    align-items: center;
    gap: 20px;
}

    .title-bar > button {
        max-height: 40px;
    }

#currentTitle {
    flex-grow: 1;
}

.json-view {
    white-space: pre;
    font-family: Consolas, monospace;
    line-height: 1.4;
}

#back-button-label::after {
    content: '← Back to Search'
}

#copy-raw-label::after {
    content: 'Copy Raw'
}

#show-raw-label::after {
    content: 'Raw'
}

#toggle-references-label::after {
    content: 'References'
}

.hide {
    display: none !important;
}

@media (max-width: 1280px) {
    .col-priority-2,
    .col-priority-3 {
        display: none;
    }

    #back-button-label::after {
        content: '←'
    }

    #copy-raw-label::after {
        content: 'c'
    }

    #show-raw-label::after {
        content: 'j'
    }

    #toggle-references-label::after {
        content: 'r'
    }
}

/* === ADDITION 3: Responsive Styles for Mobile & Tablets === */
/* These rules apply only when the screen width is 768px or less. */
@media (max-width: 768px) {

    /* 1. Reduce overall padding to give content more room */
    .sticky-header,
    #searchView,
    #blueprintView {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #blueprintView {
        padding-top: 0.2rem;
        margin-top: 0.2rem;
    }

    .sticky-header {
        padding-bottom: 0.2rem;
        margin-bottom: 0.2rem;
    }

    #bp-content {
        font-size: 0.7rem;
        overflow-x: auto;
    }

        /* 2. Hide the main title because it gets squished */
        .sticky-header > h1 {
            display: none;
        }

    #theme-toggle-label::after {
        content: "d/l";
    }

    #show-help-label::after {
        content: "?";
    }

    /* 3. Make the search box take up the full width */
    #searchBox {
        max-width: initial;
        flex-grow: 1;
        margin-bottom: 0;
    }

    /* 4. Slightly smaller font for main headings on mobile */
    h1 {
        font-size: 1.5rem;
    }

    /* 5. Reduce padding in table cells for more space */
    thead th,
    tbody td {
        padding: 0.6rem 0.75rem;
    }

    .col-priority-1 {
        display: none;
    }

    .title-bar {
        /* Allow flex items to wrap to the next line */
        flex-wrap: wrap;
        row-gap: 4px;
        justify-content: center;
    }

    .title-bar button {
        max-height: 30px;
        min-width: 30px;
        padding: 5px;
    }

    #currentTitle {
        /* Force the title to take up the full width, pushing buttons to the next line */
        flex-basis: 100%;
        /* Optional: center the title text when it's on its own line */
        text-align: center;
        font-size: 1.1rem;

        margin-top: 0px;
        margin-bottom: 0px;
    }
}

