/**
 * AIEO Category Extras — admin term-edit panel.
 *
 * The panel is rendered inside a <tr>...<th colspan=2>...</th></tr> at the
 * bottom of the WP term edit form. We reset the th's default styling so the
 * panel reads as a self-contained card, then layer tabs + grids inside.
 */

.form-table tr.aieo-ce-panel-row > th {
    padding: 0 !important;
    background: transparent;
    font-weight: normal;
}

.aieo-ce-panel {
    border: 1px solid var(--aieo-input, #c3c4c7);
    border-radius: 6px;
    background: var(--aieo-card, #fff);
    margin: 18px 0 6px;
    /* NO `overflow: hidden` HERE. It was only ever doing one job — clipping
       the grey header to the rounded corners — and it paid for that by
       clipping every absolutely-positioned child as well, which is what cut
       the Related tab's supplier autocomplete off at the card edge. No
       z-index can escape an `overflow: hidden` ancestor (the dropdown was
       already at 9000), so the radius clipping moves to the head and the
       foot, which are the only children that touch a corner. */
}

.aieo-ce-panel-head {
    padding: 14px 18px;
    background: var(--aieo-muted, #f6f7f7);
    border-bottom: 1px solid var(--aieo-border, #dcdcde);
    /* Was inherited from the panel's clip; now owned here. */
    border-radius: 5px 5px 0 0;
}
/* The last pane paints no background of its own, but a child that does (a
   table, a coloured notice) would otherwise square off the bottom corners. */
.aieo-ce-panel > :last-child {
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}
.aieo-ce-panel-head h2 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}
.aieo-ce-panel-head .description { margin: 0; color: var(--aieo-tone-secondary, #50575e); }

/* ── Tabs ───────────────────────────────────────────────────────────── */

.aieo-ce-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--aieo-border, #dcdcde);
    background: var(--aieo-row-hover, #fafafa);
    padding: 0 12px;
}
.aieo-ce-tab {
    appearance: none;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font: inherit;
    font-weight: 500;
    color: var(--aieo-tone-secondary, #50575e);
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease;
}
.aieo-ce-tab:hover { color: var(--aieo-foreground, #1d2327); }
.aieo-ce-tab.is-active {
    color: var(--aieo-primary, #2271b1);
    border-bottom-color: var(--aieo-primary, #2271b1);
}
.aieo-ce-tab:focus {
    outline: 2px solid var(--aieo-primary, #2271b1);
    outline-offset: -2px;
}

.aieo-ce-tabpanel {
    display: none;
    padding: 18px;
}
.aieo-ce-tabpanel.is-active { display: block; }

/* Rich-editor field — give wp_editor instances breathing room and make
   the toolbar wrap nicely when the panel is narrower than core admin. */
.aieo-ce-rich-field .wp-editor-wrap {
    margin-top: 6px;
}
.aieo-ce-rich-field .wp-editor-tabs {
    float: none;
    text-align: right;
}

/* ── Field layout ───────────────────────────────────────────────────── */

.aieo-ce-field {
    margin-bottom: 18px;
}
.aieo-ce-field:last-child { margin-bottom: 0; }
.aieo-ce-field > label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}
.aieo-ce-field .description {
    margin: 4px 0 0;
    color: var(--aieo-tone-secondary, #50575e);
    font-style: normal;
}

.aieo-ce-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
.aieo-ce-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
@media (max-width: 700px) {
    .aieo-ce-grid-2,
    .aieo-ce-grid-3 { grid-template-columns: 1fr; }
}

/* ── Image uploader ─────────────────────────────────────────────────── */

.aieo-ce-image-preview {
    width: 100%;
    max-width: 280px;
    margin: 6px 0 8px;
    border: 1px solid var(--aieo-border, #dcdcde);
    border-radius: 4px;
    overflow: hidden;
    background: var(--aieo-muted, #f6f7f7);
}
.aieo-ce-image-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 160px;
    object-fit: contain;
}
.aieo-ce-image-clear {
    margin-left: 8px !important;
    color: var(--aieo-tone-danger, #b32d2e) !important;
    text-decoration: none;
}

/* ── Chip picker (related posts / campaigns) ────────────────────────── */

.aieo-ce-search-field {
    position: relative;
}
.aieo-ce-search-input {
    margin-bottom: 6px;
}
.aieo-ce-search-results {
    position: absolute;
    /* 5 was enough only while the panel clipped everything anyway. Now that
       the dropdown can leave the card it has to out-rank whatever it lands
       on, so it matches the Related tab's picker rather than undercutting it. */
    z-index: 9000;
    left: 0;
    right: 0;
    top: 56px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--aieo-card, #fff);
    border: 1px solid var(--aieo-input, #c3c4c7);
    border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    max-height: 220px;
    overflow-y: auto;
}
.aieo-ce-search-result {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
}
.aieo-ce-search-result:hover { background: var(--aieo-primary-soft, #f0f6fc); color: var(--aieo-primary, #2271b1); }
.aieo-ce-search-empty {
    padding: 10px 12px;
    color: #8c8f94;
    font-style: italic;
    font-size: 13px;
}

.aieo-ce-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}
/* THE LOOK IS THE CHROME'S on a chrome screen (admin chrome 0.30.0, adopt/rooster-one.css, UI-PLAN Phase 3, D3b); these
   rules stay for core's screens (the term and product editors), where the chrome is absent. */
.aieo-ce-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: var(--aieo-primary-soft, #f0f6fc);
    border: 1px solid var(--aieo-primary-soft, #c5d9ed);
    border-radius: 16px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--aieo-foreground, #1d2327);
}
.aieo-ce-chip-remove {
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--aieo-tone-secondary, #50575e);
    font-size: 14px;
    line-height: 1;
    padding: 0 4px;
}
.aieo-ce-chip-remove:hover { color: var(--aieo-tone-danger, #b32d2e); }

/* Markup round (R5): what the panel and the settings screen styled inline. */
.aieo-ce-panel-th{padding:0}
.aieo-ce-image-preview[hidden],.aieo-ce-image-clear[hidden]{display:none}
.aieo-ce-mt-intro{margin-bottom:14px}
.aieo-ce-marketplace-tax + .aieo-ce-marketplace-tax{margin-top:24px}
.aieo-ce-marketplace-tax h3{margin:6px 0 4px}
.aieo-ce-marketplace-tax h3 + .description{margin-top:0}
.aieo-ce-mt-results{margin-top:6px}
.aieo-ce-mt-cascade{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap}
.aieo-ce-migrate-status,.aieo-ce-h3-migrate-status,.aieo-ce-chips-status{margin-left:8px}
.aieo-ce-done{margin:0}
