/**
 * WP REST API Explorer - Plugins & Theme tab
 *
 * @package   JPKCom_Tools
 * @subpackage WP_API
 * @version   0.7.0
 */

/* Bootstrap's display utilities win over [hidden] (same trap as content.css / search.css) */
#tab-plugins [hidden] {
    display: none !important;
}

.wpapi-pl-list {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.wpapi-pl-list:empty {
    display: none;
}

.wpapi-pl-item {
    border-top: 1px solid var(--bs-border-color);
}

.wpapi-pl-item:first-child {
    border-top: none;
}

.wpapi-pl-item > summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.wpapi-pl-item > summary .badge {
    vertical-align: 0.1em;
}

.wpapi-pl-detail {
    padding: 0 0.75rem 0.75rem 1.75rem;
}

.wpapi-pl-detail code,
#wpapi-pl-unknown code,
#wpapi-pl-themes code,
#wpapi-pl-mu code {
    overflow-wrap: anywhere;
}

#wpapi-pl-themes td {
    min-width: 7rem;
}

.wpapi-pl-dl dt,
.wpapi-pl-dl dd {
    overflow-wrap: anywhere;
}

#wpapi-pl-license {
    max-height: 16rem;
    overflow: auto;
    white-space: pre-wrap;
}

/* ------------------------------------------------------------------
   UI check phase 5 (P5-6, 2026-10-29)
   ------------------------------------------------------------------ */

/* "No plugin is named by a signal." sat on the list border without padding */
.wpapi-pl-list > p {
    padding: 0.5rem 0.75rem;
}

/* Theme details: the .row of the <dl> had negative gutters (wider than its cell, 306 px in 298 px
   on a phone) and on desktop 5/7 columns of a wide cell put label and value 380 px apart — a
   two-column grid: label as wide as it needs, value next to it */
.wpapi-pl-dl.row {
    display: grid;
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
    column-gap: 1rem;
    margin-left: 0;
    margin-right: 0;
}

.wpapi-pl-dl.row > dt,
.wpapi-pl-dl.row > dd {
    width: auto;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

/* Phones: theme and namespace rows as stacked blocks — three columns at 298 px pushed the theme
   folder behind the inner scroller (and focus on "Read theme details" scrolled it out of view);
   the namespace button broke into three lines. Same pattern as the probe table in security.css */
@media (max-width: 575.98px) {

    #wpapi-pl-themes thead,
    #wpapi-pl-unknown thead {
        display: none;
    }

    #wpapi-pl-themes tr,
    #wpapi-pl-themes td,
    #wpapi-pl-unknown tr,
    #wpapi-pl-unknown td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    #wpapi-pl-themes td + td,
    #wpapi-pl-unknown td + td {
        border-top: none;
        padding-top: 0;
    }

    #wpapi-pl-unknown td.wpapi-num {
        text-align: left;
    }

    #wpapi-pl-themes td:nth-child(1)::before {
        content: "Theme folder: ";
        color: var(--bs-secondary-color);
    }

    #wpapi-pl-themes td:nth-child(2)::before {
        content: "Role: ";
        color: var(--bs-secondary-color);
    }

    /* Image review: the third value was the only one without a label */
    #wpapi-pl-themes td:nth-child(3)::before {
        content: "Details: ";
        color: var(--bs-secondary-color);
    }

    #wpapi-pl-unknown td:nth-child(2)::before {
        content: "Routes: ";
        color: var(--bs-secondary-color);
    }

}

/* ------------------------------------------------------------------
   List model (plan 12-build "Listenmodell", W1 2026-10-29): filters, views, Table, JSON tree —
   the same look as the findings list of the Security tab
   ------------------------------------------------------------------ */

.wpapi-pl-qwrap {
    flex: 1 1 14rem;
    min-width: 0;
}

/* JSON tree box: fixed height, the editor scrolls inside */
.wpapi-pl-jse {
    height: 60vh;
    min-height: 16rem;
}

.wpapi-pl-jse:empty {
    display: none;
}

#wpapi-pl-json-pre {
    max-height: 60vh;
    overflow: auto;
}

#wpapi-pl-table td {
    min-width: 6rem;
}

#wpapi-pl-table code,
.wpapi-pl-goto {
    overflow-wrap: anywhere;
}

.wpapi-pl-goto {
    text-align: start;
}

/* Up to md: Table rows as stacked blocks, each value with its column name (four columns with
   long names and namespaces squeezed each other at 600 px). The sort buttons stay as a strip
   above the rows, so sorting still works */
@media (max-width: 767.98px) {

    /* table, thead and tbody as blocks too: a table box kept the min-content width of the
       header row (336 px in 298 px on a phone) */
    #wpapi-pl-table,
    #wpapi-pl-table thead,
    #wpapi-pl-table tbody {
        display: block;
        width: 100%;
    }

    #wpapi-pl-table thead tr {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }

    #wpapi-pl-table thead th {
        border: none;
        padding: 0.25rem 0;
    }

    #wpapi-pl-table tbody tr,
    #wpapi-pl-table tbody td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    #wpapi-pl-table tbody td + td {
        border-top: none;
        padding-top: 0;
    }

    /* one line per entry, not per value */
    #wpapi-pl-table tbody td:not(:last-child) {
        border-bottom-width: 0;
    }

    #wpapi-pl-table tbody td[data-label]:not(:first-child)::before {
        content: attr(data-label) ": ";
        color: var(--bs-secondary-color);
    }

}

/* ------------------------------------------------------------------
   UI check phase 5 gaps (2026-10-29)
   ------------------------------------------------------------------ */

/* The options of "Confidence" follow the data: without a minimum width the select (and the
   filter beside it) changed size from site to site */
#wpapi-pl-conf {
    min-width: 9rem;
}

@media (max-width: 767.98px) {

    /* Sort buttons as pills with an arrow icon, set apart from the first entry (they looked like
       bold sub-headings of the entry below) */
    #wpapi-pl-table thead tr {
        margin-bottom: 0.5rem;
    }

    #wpapi-pl-table thead th .wpapi-sort {
        border: 1px solid var(--bs-border-color);
        border-radius: 50rem;
        padding: 0.125rem 0.625rem;
        font-weight: normal;
    }

    #wpapi-pl-table thead th .wpapi-sort::before {
        content: "\21C5\00A0";
    }

}

@media (max-width: 575.98px) {

    /* Stacked theme and namespace rows: one line per entry, not per value (as the plugin Table) */
    #wpapi-pl-themes tbody td:not(:last-child),
    #wpapi-pl-unknown tbody td:not(:last-child) {
        border-bottom-width: 0;
    }

    #wpapi-pl-unknown td:nth-child(3)::before {
        content: "Look up: ";
        color: var(--bs-secondary-color);
    }

    /* Signal lists: less indent, the detail column not indented twice (paths used half the card) */
    .wpapi-pl-detail {
        padding-left: 0.75rem;
    }

    .wpapi-pl-detail ul {
        padding-left: 1rem;
    }

    /* Paths under "Signals": fill the line instead of breaking at the hyphen of the plugin name */
    .wpapi-pl-detail li > ul code {
        word-break: break-all;
    }

}

/* ------------------------------------------------------------------
   Unknown post types and the "research" marker (user decisions 2026-10-29)
   ------------------------------------------------------------------ */

/* The type name is the site's: without spaces it must not widen every row */
#wpapi-pl-types td,
#wpapi-pl-types code,
#wpapi-pl-taxonomies td,
#wpapi-pl-taxonomies code {
    overflow-wrap: anywhere;
}

/* "not counted" stays on one line beside the type name */
#wpapi-pl-types td.wpapi-num,
#wpapi-pl-taxonomies td.wpapi-num {
    white-space: nowrap;
}

.wpapi-pl-item > summary .wpapi-pl-research,
#wpapi-pl-ambiguous li .wpapi-pl-research {
    vertical-align: 0.1em;
}

/* Phones: stacked like the namespace table above */
@media (max-width: 575.98px) {

    #wpapi-pl-types thead,
    #wpapi-pl-taxonomies thead {
        display: none;
    }

    /* Blocks too: a table box keeps the min-content width of its rows */
    #wpapi-pl-types,
    #wpapi-pl-types tbody,
    #wpapi-pl-taxonomies,
    #wpapi-pl-taxonomies tbody {
        display: block;
    }

    #wpapi-pl-types tr,
    #wpapi-pl-types td,
    #wpapi-pl-taxonomies tr,
    #wpapi-pl-taxonomies td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    #wpapi-pl-types td + td,
    #wpapi-pl-taxonomies td + td {
        border-top: none;
        padding-top: 0;
    }

    #wpapi-pl-types tbody td:not(:last-child),
    #wpapi-pl-taxonomies tbody td:not(:last-child) {
        border-bottom-width: 0;
    }

    #wpapi-pl-types td.wpapi-num,
    #wpapi-pl-taxonomies td.wpapi-num {
        text-align: left;
    }

    #wpapi-pl-types td:nth-child(2)::before {
        content: "Items: ";
        color: var(--bs-secondary-color);
    }

    #wpapi-pl-taxonomies td:nth-child(2)::before {
        content: "Terms: ";
        color: var(--bs-secondary-color);
    }

}

/* ------------------------------------------------------------------
   UI check phase 5 answers (2026-11-02)
   ------------------------------------------------------------------ */

/* The list box without entries (head line and the sections below say it all) */
.wpapi-pl-list:empty {
    display: none;
}

/* Fixed width of the longest option: the filter row stays the same on every site */
#wpapi-pl-conf {
    width: 11rem;
}

#wpapi-pl-unk {
    margin-top: 0;
}

.form-check:has(> #wpapi-pl-unk) {
    align-self: center;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-left: 0;
    margin-bottom: 0 !important;
}

.form-check:has(> #wpapi-pl-unk) .form-check-input {
    float: none;
    margin-left: 0;
}

/* Type rows: "not counted (…)" may wrap; research badge at the name, gaps instead of margins */
#wpapi-pl-types td.wpapi-num,
#wpapi-pl-taxonomies td.wpapi-num {
    white-space: normal;
}

#wpapi-pl-table td[data-label="Confidence"] {
    line-height: 1.8;
}

.wpapi-pl-item > summary .wpapi-pl-research {
    margin-left: .5rem;
}

/* The namespace buttons wrap at the start of the line like the text around them */
.wpapi-pl-detail button,
#wpapi-pl-unknown td button {
    text-align: start;
}

.wpapi-pl-needs {
    display: flex;
    align-items: baseline;
    gap: .5rem;
}

.wpapi-pl-needs .badge {
    flex: none;
}

@media (max-width: 575.98px) {

    /* The grey signal line as its own block: "Contact Form 7" + "files on the home page" read as
       "7 files" when the name wrapped */
    .wpapi-pl-item > summary > .text-body-secondary {
        display: block;
        margin-left: 0 !important;
    }

    .wpapi-pl-item > summary .wpapi-pl-research {
        margin-left: 0;
    }

    .wpapi-pl-item > summary > strong {
        margin-right: .5rem;
    }

}

/* Sort controls on phones: filled like the other small buttons, not round outlined pills */
@media (max-width: 767.98px) {

    #wpapi-pl-table thead th .wpapi-sort {
        background-color: var(--bs-secondary);
        border: 1px solid var(--bs-secondary);
        border-radius: 0;
        color: #fff;
        padding: .125rem .5rem;
    }

    #wpapi-pl-table thead th[aria-sort] .wpapi-sort {
        background-color: var(--tools-fill-primary);
        border-color: var(--tools-fill-primary);
    }

    /* The strip already has its arrow in ::before */
    #wpapi-pl-table thead th:not([aria-sort]) .wpapi-sort::after {
        content: none;
    }

}
