/**
 * BTM Taxonomy Editor Styles
 */

/* Main Layout */
.btm-taxonomy-manager {
    margin: 20px 0;
    position: relative;
}

.btm-main-container {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    position: relative; /* For absolute positioning of controls */
}

/* Header Controls */
.btm-taxonomy-controls {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 12px 0;
    padding: 8px 12px;
}

.btm-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btm-taxonomy-select {
    min-width: 177px;
}

#term-search {
    width: 200px;
    padding: 5px 8px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
}

/* Tree Controls (Expand/Collapse All) */
.btm-tree-controls {
    z-index: 100;
    gap: 5px;
    text-align: right;
    margin-top: 0;
    margin-bottom: 0;
    margin-right: 4px;
}

.btm-tree-controls .button {
    display: inline-block;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    text-align: center;
    line-height: 28px;
    cursor: pointer;
}

.btm-tree-controls .button:hover {
    background-color: #f0f0f1;
}

/* Text-size (A-/A+) buttons */
.btm-tree-controls .btm-font-btn {
    font-weight: 600;
    padding: 0 9px;
    min-width: 32px;
}

/* Terms Tree */
.btm-terms-tree {
    /* Base term text size; adjusted live by the A-/A+ controls (JS sets this
       inline). Row height tracks it so a smaller size fits more terms. */
    --btm-font: 12px;
    flex: 2;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    overflow: auto;
    padding: 10px;
    position: relative;
}

/* Term List Structure */
.btm-term-list {
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 10px; /* Ensures lists are droppable even when empty */
}

.btm-term-list ul,
.btm-term-list .btm-term-list {
    margin-left: 16px !important;
    padding-left: 10px !important;
    border-left: 1px dashed #ccd0d4;
}

.btm-term-list > li {
    margin-bottom: 1px;
}

/* Term Row */
.btm-term-row {
    position: relative;
    margin-left: 0 !important;
    padding-left: 0 !important;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.btm-term-row:hover {
    border-color: #2271b1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btm-term-content {
    display: flex;
    align-items: center;
    padding: 2px 10px;
    min-height: calc(var(--btm-font, 12px) + 12px);
    gap: 6px;
}

/* Drag Handle */
.btm-term-handle {
    width: 20px;
    height: 20px;
    cursor: move;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btm-term-handle:hover {
    color: #2271b1;
}

.btm-term-handle .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Term Information */
.btm-term-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btm-term-name {
    font-size: var(--btm-font, 12px);
    font-weight: 500;
}

.btm-term-count {
    color: #666;
    font-size: calc(var(--btm-font, 12px) - 1px);
    background: #f0f0f0;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

/* Toggle Children Button */
.btm-toggle-children {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #1d2327;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: all 0.2s ease;
}

.btm-toggle-children:hover {
    color: #2271b1;
}

.btm-toggle-children .dashicons {
    transition: transform 0.2s ease;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.btm-toggle-children.expanded .dashicons {
    transform: rotate(90deg);
}

/* Term Actions */
.btm-term-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    gap: 5px;
}

.btm-term-content:hover .btm-term-actions {
    opacity: 1;
}

/* Compact, font-scaled icon buttons so rows stay short (these occupy layout
   height even while hidden, so their size drives the minimum row height). */
.btm-term-actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    height: calc(var(--btm-font, 12px) + 12px);
    padding: 0 6px;
    line-height: 1;
}

.btm-term-actions .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
    margin: 0;
}

/* Drag and Drop States */
.btm-term-row.is-dragging {
    opacity: 0.7;
    background: #f8f9fa;
    border: 2px dashed #2271b1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Visual indicator for potential parent */
.btm-term-row.potential-parent {
    background-color: #f0f7fc;
    border: 2px solid #2271b1;
    border-bottom: none;
    position: relative;
}

.btm-term-row.potential-parent::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background-color: #2271b1;
    z-index: 1;
}

/* Helper text for nesting indication */
.nesting-helper {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #2271b1;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0.9;
    pointer-events: none;
    z-index: 2;
    animation: fadeIn 0.2s ease-in-out;
}

/* Temporary Drop Containers */
.temp-drop-container {
    height: 0;
    opacity: 0;
    transition: all 0.2s ease;
    background: rgba(34, 113, 177, 0.05);
    border-left: 2px dashed #2271b1;
    margin-left: 20px;
    padding: 0;
}

.temp-drop-container.active {
    height: 32px;
    opacity: 1;
    margin-left: 20px !important;
    padding-left: 12px !important;
}

/* Placeholder Styling */
.btm-term-placeholder {
    border: 2px dashed #2271b1;
    margin-left:20px;
    height: 32px !important;
    border-radius: 3px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.btm-term-placeholder.is-child-indent {
    margin-left: 40px !important;
    border-left: 4px solid #2271b1;
    background: rgba(34, 113, 177, 0.1);
    position: relative;
}

.btm-term-placeholder.is-child-indent::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    width: 16px;
    height: 2px;
    background-color: #2271b1;
}

/* Drop Zone Indicators */
.btm-term-row.show-drop-zone::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30%;
    background: linear-gradient(90deg, transparent, rgba(34, 113, 177, 0.1));
    pointer-events: none;
    z-index: 1;
}

/* Term Editor Sidebar */
.btm-term-editor {
    flex: 1;
    min-width: 322px;
    max-width: 400px;
    min-height: 0; /* allow the content region to scroll within a fixed-height row */
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.btm-term-editor-header {
    background: #f8f9fa;
    border-bottom: 1px solid #ccd0d4;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btm-term-editor-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.btm-term-editor-content {
    flex: 1 1 auto;
    min-height: 0;
    /* Small horizontal padding so field borders / focus rings aren't clipped by
       overflow-x:hidden (they would otherwise sit flush on the clip boundary). */
    padding: 14px 3px 0;
    overflow-y: auto;
    overflow-x: hidden; /* no horizontal scrollbar when the panel is narrow */
}

.btm-form-actions .dashicons {
    margin-top:4px;
}

/* Form Fields */
.btm-form-field {
    margin-bottom: 14px;
}

.btm-form-field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.btm-form-field input[type="text"],
.btm-form-field textarea,
.btm-form-field select {
    width: 100%;
    box-sizing: border-box; /* width:100% includes padding+border — no overflow */
    padding: 6px 8px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
}

.btm-form-field input[type="text"]:focus,
.btm-form-field textarea:focus,
.btm-form-field select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.btm-form-field .description {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
}

/* OpenAI Controls */
.openai-controls {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #eee;
}

#generate-description {
    width: 100%;
    margin-top: 6px;
}

.dashicons-editor-spellcheck {
    margin-top: 6px;
    margin-right: 6px;
}

/* Form Actions */
.btm-form-actions {
    display: flex;
    flex-wrap: wrap; /* buttons wrap instead of overflowing a narrow editor */
    justify-content: space-between;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #eee;
    gap: 10px;
}

/* Loading Overlay */
.btm-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.btm-loading-overlay .spinner {
    float: none;
    visibility: visible;
    margin: 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 0.9;
        transform: translateY(-50%);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* RTL Support */
.rtl .btm-term-list ul {
    margin-right: 24px;
    margin-left: 0;
    border-right: 1px dashed #ccd0d4;
    border-left: none;
    padding-right: 12px;
    padding-left: 0;
}

.rtl .nesting-helper {
    left: 10px;
    right: auto;
}

/* Accessibility */
.btm-taxonomy-manager .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.btm-taxonomy-manager button:focus,
.btm-taxonomy-manager input:focus,
.btm-taxonomy-manager select:focus,
.btm-taxonomy-manager textarea:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

/* Responsive Design */
@media screen and (max-width: 782px) {
    .btm-main-container {
        flex-direction: column;
    }

    .btm-term-editor {
        max-width: none;
    }

    .btm-taxonomy-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btm-control-group {
        flex-direction: column;
    }

    #term-search,
    .btm-taxonomy-select {
        width: 100%;
    }

    .nesting-helper {
        display: none; /* Hide helper text on mobile */
    }
}

/* Hierarchy controls styling for non-hierarchical taxonomies */
.btm-flat-taxonomy .btm-term-handle {
    opacity: 0.3;
    cursor: not-allowed;
}

.btm-flat-taxonomy .btm-term-handle:hover {
    background-color: transparent;
}

.btm-flat-taxonomy .btm-term-row {
    padding-left: 10px; /* Reduce indentation for flat taxonomies */
}

.btm-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Notification Banner System - Updated with more visibility */
.btm-notification-container {
    position: fixed;
    top: 50px; /* Increased to be more visible */
    right: 20px;
    z-index: 10000; /* Increased z-index to ensure it's on top */
    max-width: 400px;
}

.btm-notification {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Enhanced shadow */
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: btm-slide-in 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(50px);
}

.btm-notification.btm-fadeout {
    animation: btm-fade-out 0.5s ease-out forwards;
}

.btm-notification-success {
    background-color: #dff2bf;
    color: #4F8A10;
    border-left: 4px solid #4F8A10;
    font-weight: bold; /* Made success messages more prominent */
}

.btm-notification-error {
    background-color: #ffbaba;
    color: #D8000C;
    border-left: 4px solid #D8000C;
}

.btm-notification-warning {
    background-color: #feefb3;
    color: #9F6000;
    border-left: 4px solid #9F6000;
}

.btm-notification-info {
    background-color: #bde5f8;
    color: #00529B;
    border-left: 4px solid #00529B;
}

.btm-notification-close {
    margin-left: 15px;
    cursor: pointer;
    font-size: 20px;
    line-height: 20px;
    opacity: 0.7;
}

.btm-notification-close:hover {
    opacity: 1;
}

.btm-notification-content {
    flex: 1;
}

@keyframes btm-slide-in {
    0% {
        opacity: 0;
        transform: translateX(50px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes btm-fade-out {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(50px);
    }
}
/* ==========================================================================
   Term action buttons (View archive / Info) + posts info modal
   ========================================================================== */
.btm-term-actions .btm-view-term,
.btm-term-actions .btm-term-info {
    text-decoration: none;
}
.btm-term-actions .btm-view-term .dashicons,
.btm-term-actions .btm-term-info .dashicons {
    line-height: 16px;
}

.btm-modal {
    position: fixed;
    inset: 0;
    z-index: 100050;
}
.btm-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.btm-modal-dialog {
    position: relative;
    max-width: 860px;
    margin: 60px auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}
.btm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #dcdcde;
}
.btm-modal-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
}
.btm-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #50575e;
    padding: 4px;
    line-height: 1;
}
.btm-modal-close:hover {
    color: #d63638;
}
.btm-modal-body {
    padding: 16px 20px;
    overflow: auto;
}
/* Bulk action modal (Move / Merge) */
.btm-modal-dialog--sm { max-width: 460px; }
.btm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #dcdcde;
}
.btm-merge-opts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 6px 0;
    max-height: 280px;
    overflow: auto;
}
.btm-merge-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #f0f0f1;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.btm-merge-opt:hover { background: #f6f9fc; }
.btm-modal-warn { color: #b32d2e; font-weight: 600; }
.btm-affected-list { margin: 4px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; color: #50575e; font-size: 12.5px; }
.btm-affected-list li { margin: 1px 0; }
.btm-modal-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #50575e;
}
.btm-posts-table {
    width: 100%;
    border-collapse: collapse;
}
.btm-posts-table th,
.btm-posts-table td {
    text-align: left;
    padding: 8px 10px;
    vertical-align: middle;
}
.btm-posts-table th {
    font-weight: 600;
}
.btm-modal-empty,
.btm-modal-error,
.btm-modal-note {
    color: #50575e;
    margin: 4px 0;
}
.btm-modal-error {
    color: #d63638;
}
.btm-modal-note {
    margin-top: 12px;
    font-style: italic;
    font-size: 12px;
}

/* Posts modal pagination */
.btm-posts-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-end;
}
.btm-posts-pagination .displaying-num {
    margin-right: auto;
    color: #50575e;
}
.btm-posts-page-info {
    color: #50575e;
}

/* ==========================================================================
   Multi-view taxonomy manager — design system + layouts
   (Compact List / Columns / Cards / Tree). Tokens scoped to .btm-tx so they
   don't leak into the rest of wp-admin. Derived from the Claude Design
   "Taxonomy Manager — Variations" handoff.
   ========================================================================== */
.btm-tx {
    --wp-blue: #2271b1;
    --wp-blue-hover: #135e96;
    --wp-blue-50: #f0f6fc;
    --wp-blue-100: #e3effb;
    --ink: #1d2327;
    --ink-2: #2c3338;
    --slate: #50575e;
    --muted: #646970;
    --line: #dcdcde;
    --line-2: #c3c4c7;
    --panel: #ffffff;
    --badge: #f0f0f1;
    --badge-ink: #50575e;
    --danger: #b32d2e;
    --tx-mono: "SF Mono", ui-monospace, "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}

/* ---- page header restyle to match the design (bordered blue actions) ---- */
.btm-tx .btm-import-export-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.btm-tx .btm-import-export-controls .page-title-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    border-radius: 4px;
    border: 1px solid var(--wp-blue);
    background: var(--panel);
    color: var(--wp-blue);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    box-shadow: none;
}
.btm-tx .btm-import-export-controls .page-title-action:hover {
    background: var(--wp-blue-50);
    color: var(--wp-blue-hover);
    border-color: var(--wp-blue-hover);
}
.btm-tx .btm-import-export-controls .page-title-action .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

/* ---- shared button primitives ---- */
.btm-tx .tx-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid var(--wp-blue);
    color: var(--wp-blue);
    background: var(--panel);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}
.btm-tx .tx-btn:hover { background: var(--wp-blue-50); }
.btm-tx .tx-btn .dashicons { font-size: 16px; width: 16px; height: 16px; line-height: 16px; flex: 0 0 auto; }
.btm-tx .tx-btn--primary { background: var(--wp-blue); color: #fff; border-color: var(--wp-blue); }
.btm-tx .tx-btn--primary:hover { background: var(--wp-blue-hover); border-color: var(--wp-blue-hover); }
.btm-tx .tx-btn--ghost { border-color: var(--line-2); color: var(--slate); background: var(--panel); }
.btm-tx .tx-btn--ghost:hover { background: #f6f7f7; border-color: var(--muted); }
.btm-tx .tx-btn--sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btm-tx .tx-btn--danger { border-color: var(--danger); color: var(--danger); }
.btm-tx .tx-btn--danger:hover { background: #fbeaea; }
.btm-tx .tx-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- inputs / select ---- */
.btm-tx .tx-select {
    height: 34px;
    padding: 0 30px 0 11px;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    font-size: 13px;
    color: var(--ink);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 8l3-3.5' fill='none' stroke='%2350575e' stroke-width='1.5'/%3E%3C/svg%3E") right 9px center/12px no-repeat;
    appearance: none;
}
.btm-tx .tx-input {
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    width: 100%;
}
.btm-tx .tx-input::placeholder { color: #8c8f94; }
.btm-tx .tx-input:focus,
.btm-tx .tx-select:focus { outline: none; border-color: var(--wp-blue); box-shadow: 0 0 0 1px var(--wp-blue); }

/* ---- badge / hint / grip / caret / scroll ---- */
.btm-tx .tx-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px;
    background: var(--badge); color: var(--badge-ink);
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.btm-tx .tx-hint { font-size: 12px; color: var(--muted); }
.btm-tx .tx-grip { color: #a7aaad; cursor: grab; display: inline-flex; align-items: center; }
.btm-tx .tx-grip:hover { color: var(--muted); }
.btm-tx .tx-caret {
    width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); border: 0; background: none; padding: 0; transition: transform .12s ease; flex: 0 0 auto; cursor: pointer;
}
.btm-tx .tx-caret.open { transform: rotate(90deg); }
.btm-tx .tx-scroll { overflow: auto; overscroll-behavior: contain; }

/* ---- toolbar ---- */
.btm-tx .btm-toolbar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0 14px;
}
.btm-tx .btm-toolbar-sp { flex: 1; }
.btm-tx .btm-search-wrap { position: relative; width: 220px; }
.btm-tx .btm-search-ic {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    font-size: 16px; width: 16px; height: 16px; color: #8c8f94; pointer-events: none;
}
/* The id selector #term-search (legacy) would otherwise win on padding and put
   the text behind the icon — beat it with id+class specificity. */
.btm-tx #term-search.btm-search-input { padding-left: 32px; width: 100%; }

/* ---- view switcher (segmented control) ---- */
.btm-tx .btm-view-switch {
    display: inline-flex;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}
.btm-tx .btm-view-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 12px;
    border: 0; border-left: 1px solid var(--line);
    background: #fff; color: var(--slate);
    font-size: 12.5px; font-weight: 500; cursor: pointer; line-height: 1;
}
.btm-tx .btm-view-btn:first-child { border-left: 0; }
.btm-tx .btm-view-btn .dashicons { font-size: 16px; width: 16px; height: 16px; line-height: 16px; }
.btm-tx .btm-view-btn:hover { background: var(--wp-blue-50); color: var(--wp-blue); }
.btm-tx .btm-view-btn.active { background: var(--wp-blue); color: #fff; border-left-color: var(--wp-blue); }
/* Hide the next segment's seam where it meets the active (blue) segment. */
.btm-tx .btm-view-btn.active + .btm-view-btn { border-left-color: var(--wp-blue); }
.btm-tx .btm-tree-controls { display: flex; gap: 6px; margin: 0; }

/* ---- view host (the active layout renders inside this; keep it transparent
        so each layout's own panels/borders show). Height is set inline by
        adjustViewportHeight(); min-height is the no-JS / pre-resize fallback. ---- */
.btm-tx .btm-main-container { min-height: 460px; }
.btm-tx .btm-view-host {
    flex: 2;
    position: relative; /* anchors .btm-loading-overlay */
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    overflow: visible;
    min-height: 0;
    min-width: 0; /* never let a view's min-content width starve the editor */
}
.btm-tx #taxonomy-terms-tree { height: 100%; }
.btm-tx .btm-view { height: 100%; display: flex; flex-direction: column; min-height: 0; }

/* =========================================================
   B — Compact Power List (default)
   ========================================================= */
/* The Compact List wrapper sizes to its content so a short list leaves no empty
   white panel below it (the container is set to height:auto for view B). */
.btm-tx .btm-view.btm-view-list { height: auto; }
.btm-tx .v2-list {
    background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
    /* Size to content (no stretch / white space below short lists), but cap at
       the available viewport height and scroll once longer. --btm-avail is set
       on .btm-main-container by adjustViewportHeight(). */
    flex: 0 1 auto; min-height: 0; max-height: var(--btm-avail, 70vh); font-size: 12.5px;
}
.btm-tx .v2-row {
    display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px 0 8px;
    border-bottom: 1px solid #f4f4f5; position: relative;
}
.btm-tx .v2-row:hover { background: #f6f9fc; }
.btm-tx .v2-row.sel { background: var(--wp-blue-50); }
/* drag-to-reparent (drop a row onto another to nest under it) */
.btm-tx .v2-row.v2-drop-target { background: var(--wp-blue-50); box-shadow: inset 0 0 0 2px var(--wp-blue); }
.btm-tx .v2-row-drag {
    width: 320px; max-width: 92%;
    background: #fff; border: 1px solid var(--wp-blue); border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0,0,0,.18); opacity: .96;
}
.btm-tx .v2-row.sel::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--wp-blue); }
.btm-tx .v2-check {
    width: 15px; height: 15px; border: 1.5px solid var(--line-2); border-radius: 3px;
    display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: 0 0 auto;
    background: #fff; padding: 0; cursor: pointer;
}
.btm-tx .v2-check.on { background: var(--wp-blue); border-color: var(--wp-blue); }
.btm-tx .v2-check svg { width: 11px; height: 11px; }
.btm-tx .v2-indent { display: flex; align-items: center; }
.btm-tx .v2-name { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.btm-tx .v2-name:hover { color: var(--wp-blue); }
.btm-tx .v2-row.parent .v2-name { font-weight: 700; }
.btm-tx .v2-count { color: var(--muted); font-family: var(--tx-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.btm-tx .v2-bulkbar {
    display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff;
    border-radius: 4px; padding: 9px 12px; margin-bottom: 12px; font-size: 13px;
}
.btm-tx .v2-bulkbar .tx-btn { height: 28px; border-color: rgba(255,255,255,.3); color: #fff; background: transparent; }
.btm-tx .v2-bulkbar .tx-btn:hover { background: rgba(255,255,255,.12); }
.btm-tx .v2-bulkbar .tx-btn--danger { border-color: #f0a8a8; color: #ffc9c9; }
.btm-tx .v2-bulkbar .tx-btn[disabled]:hover { background: transparent; }
.btm-tx .v2-bulkbar .v2-mini { color: #a7aaad; }
.btm-tx .v2-bulkbar .btm-toolbar-sp { flex: 1; }

/* =========================================================
   D — Miller Columns
   ========================================================= */
/* Columns size to content (no empty space under short columns) and cap at the
   available viewport height; --btm-avail is set on .btm-main-container by
   adjustViewportHeight(). */
.btm-tx .btm-view.btm-view-cols { height: auto; }
.btm-tx .v4-cols {
    display: flex; flex: 0 1 auto; min-height: 0; max-height: var(--btm-avail, 70vh); border: 1px solid var(--line); border-radius: 6px;
    overflow-x: auto; overflow-y: hidden; background: var(--panel);
}
.btm-tx .v4-col { width: 248px; flex: 0 0 248px; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.btm-tx .v4-col:last-child { border-right: 0; flex: 1; }
.btm-tx .v4-colhead {
    font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600;
    padding: 10px 12px 8px; border-bottom: 1px solid #f1f1f2; background: #fbfbfc; display: flex; justify-content: space-between;
}
.btm-tx .v4-row { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 12px; cursor: pointer; }
.btm-tx .v4-row:hover { background: #f1f5fa; }
.btm-tx .v4-row.active { background: var(--wp-blue); }
.btm-tx .v4-row.active .v4-name, .btm-tx .v4-row.active .v4-chev { color: #fff; }
.btm-tx .v4-row.active .tx-badge { background: rgba(255,255,255,.25); color: #fff; }
.btm-tx .v4-row.v4-result { height: auto; min-height: 34px; padding: 6px 8px 6px 12px; }
.btm-tx .v4-row.v4-result .v4-name { white-space: normal; }
.btm-tx .v4-name { font-size: 13px; font-weight: 500; color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.btm-tx .v4-chev { color: #b0b3b8; display: inline-flex; }
.btm-tx .v4-preview { padding: 18px; }
.btm-tx .v4-preview-ic { width: 44px; height: 44px; border-radius: 10px; background: var(--wp-blue-50); color: var(--wp-blue); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.btm-tx .v4-preview-name { font-size: 18px; font-weight: 700; }
.btm-tx .v4-preview-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; align-items: flex-start; }

/* =========================================================
   E — Spacious Cards
   ========================================================= */
.btm-tx .v5-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; flex: 1; min-height: 0; align-content: start; padding-right: 2px; }
.btm-tx .v5-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.btm-tx .v5-cardhead { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid #f1f1f2; }
.btm-tx .v5-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.btm-tx .v5-cardname { font-size: 14.5px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.btm-tx .v5-cardmeta { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Breadcrumb header (drill path) */
.btm-tx .v5-crumbs { display: inline-flex; align-items: center; gap: 3px; flex: 1; min-width: 0; flex-wrap: wrap; }
.btm-tx .v5-crumb { border: 0; background: none; padding: 0 2px; font: inherit; font-size: 14.5px; font-weight: 700; color: var(--muted); cursor: pointer; border-radius: 3px; letter-spacing: -.01em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btm-tx .v5-crumb:not(.current):hover { color: var(--wp-blue); text-decoration: underline; }
.btm-tx .v5-crumb.current { color: var(--ink); cursor: default; }
.btm-tx .v5-crumb-sep { color: var(--line-2); font-weight: 400; font-size: 13px; }
.btm-tx .v5-cardedit { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; display: inline-flex; align-items: center; flex: 0 0 auto; }
.btm-tx .v5-cardedit:hover { color: var(--wp-blue); background: var(--wp-blue-50); }
.btm-tx .v5-cardedit svg { width: 14px; height: 14px; }
.btm-tx .v5-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; }
.btm-tx .v5-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px;
    border-radius: 6px; background: #f6f7f8; border: 1px solid #eceded; color: var(--ink-2);
    font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.btm-tx .v5-chip:hover { background: var(--wp-blue-50); border-color: #bcd6ef; }
.btm-tx .v5-chip b { font-weight: 600; }
.btm-tx .v5-chip .dashicons { font-size: 12px; width: 12px; height: 12px; line-height: 12px; color: var(--muted); }
.btm-tx .v5-chipn { font-family: var(--tx-mono); font-size: 10.5px; color: var(--muted); background: #fff; border-radius: 4px; padding: 1px 5px; }
.btm-tx .v5-add { color: var(--wp-blue); border-style: dashed; border-color: #bcd6ef; background: #fff; padding: 0 10px; cursor: pointer; }
.btm-tx .v5-empty { color: var(--muted); font-size: 12px; padding: 2px 0; }
/* Folder chips drill into their children */
.btm-tx .v5-folder b { font-weight: 700; }
.btm-tx .v5-folder-go { display: inline-flex; color: var(--muted); margin-left: -1px; }
.btm-tx .v5-folder-go svg { width: 11px; height: 11px; }
.btm-tx .v5-folder:hover { background: var(--wp-blue-50); border-color: #bcd6ef; }
.btm-tx .v5-folder:hover .v5-folder-go { color: var(--wp-blue); }
/* Drag-and-drop reparenting (a child chip can be dragged onto another group). */
.btm-tx .v5-chip:not(.v5-add) { cursor: grab; }
.btm-tx .v5-chip.ui-sortable-helper { cursor: grabbing; box-shadow: 0 4px 12px rgba(0,0,0,.18); opacity: .95; }
.btm-tx .v5-chip-placeholder {
    display: inline-flex; align-items: center; height: 26px; min-width: 64px;
    border: 1px dashed var(--wp-blue); border-radius: 6px; background: var(--wp-blue-50);
    margin: 0; vertical-align: middle;
}
.btm-tx .v5-chips.ui-sortable-over { outline: 2px dashed #bcd6ef; outline-offset: 3px; border-radius: 8px; }

/* ---- Manual ordering (drag-to-reorder) ---- */
/* Cursor-following "where will this land" note (appended to <body>, so unscoped). */
.btm-drag-note {
    position: absolute; z-index: 100000; pointer-events: none;
    background: #1d2327; color: #fff; font-size: 12px; line-height: 1.4;
    padding: 4px 9px; border-radius: 5px; white-space: nowrap; max-width: 320px;
    overflow: hidden; text-overflow: ellipsis;
    box-shadow: 0 3px 10px rgba(0,0,0,.28);
}
.btm-tx .v4-grip { color: #b0b3b8; flex: none; }
.btm-tx .v4-row:hover .v4-grip { color: var(--muted); }
.btm-tx .v2-row-placeholder { height: 34px; border: 1px dashed var(--wp-blue); background: var(--wp-blue-50); border-radius: 6px; margin: 1px 0; box-sizing: border-box; }
.btm-tx .v4-row-placeholder { height: 34px; border: 1px dashed var(--wp-blue); background: var(--wp-blue-50); border-radius: 6px; box-sizing: border-box; }
.btm-tx .v5-card-placeholder { border: 1px dashed var(--wp-blue); background: var(--wp-blue-50); border-radius: 12px; }
.btm-tx .v2-row.ui-sortable-helper,
.btm-tx .v4-row.ui-sortable-helper,
.btm-tx .v5-card.ui-sortable-helper { box-shadow: 0 6px 18px rgba(0,0,0,.18); opacity: .97; }

/* =========================================================
   F — Tree Diagram
   ========================================================= */
.btm-tx .v6-stage {
    flex: 0 1 auto; min-height: 0; max-height: 100%; border: 1px solid var(--line); border-radius: 6px; position: relative;
    background:
        radial-gradient(circle at 1px 1px, rgba(0,0,0,.05) 1px, transparent 0) 0 0/18px 18px,
        var(--panel);
}
.btm-tx .v6-node {
    position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px;
    background: #fff; border: 1.5px solid var(--line-2); border-radius: 8px; padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.05); white-space: nowrap;
}
.btm-tx .v6-node.root { border-color: var(--wp-blue); background: var(--wp-blue); color: #fff; font-weight: 700; }
.btm-tx .v6-node.root .tx-badge { background: rgba(255,255,255,.25); color: #fff; }
.btm-tx .v6-node.l1 { border-color: #9ec3e6; cursor: pointer; }
.btm-tx .v6-node.l1 .v6-nname { font-weight: 700; }
.btm-tx .v6-node.active-branch { border-color: var(--wp-blue); box-shadow: 0 2px 10px rgba(34,113,177,.22); }
.btm-tx .v6-node.child { cursor: pointer; }
.btm-tx .v6-node.child:hover { border-color: #9ec3e6; }
.btm-tx .v6-node.v6-match { border-color: #f0b849; box-shadow: 0 0 0 2px rgba(240,184,73,.55); background: #fff8e5; }
.btm-tx .v6-node.v6-match.root { background: var(--wp-blue); }
.btm-tx .v6-node.l1, .btm-tx .v6-node.child { cursor: grab; }
.btm-tx .v6-node.v6-drop-target { border-color: var(--wp-blue); box-shadow: 0 0 0 2px var(--wp-blue); background: var(--wp-blue-50); }
.btm-tx .v6-node.v6-node-drag { z-index: 1000; box-shadow: 0 6px 18px rgba(0,0,0,.18); opacity: .95; }
.btm-tx .v6-node .dashicons { font-size: 13px; width: 13px; height: 13px; line-height: 13px; color: var(--muted); }
.btm-tx .v6-node.root .dashicons { color: #fff; }
.btm-tx .v6-nname { font-size: 13px; font-weight: 500; }
.btm-tx .v6-tag { font-size: 11px; color: var(--muted); font-family: var(--tx-mono); }

/* empty / loading states inside a view */
.btm-tx .btm-view-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- Compact List per-row actions (View archive + Posts info), hover-revealed ---- */
.btm-tx .v2-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .12s; margin-right: 6px; }
.btm-tx .v2-row:hover .v2-actions,
.btm-tx .v2-row:focus-within .v2-actions { opacity: 1; }
.btm-tx .v2-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line);
    background: #fff; color: var(--slate); text-decoration: none; cursor: pointer; padding: 0;
}
.btm-tx .v2-iconbtn:hover { color: var(--wp-blue); border-color: var(--wp-blue); background: var(--wp-blue-50); }
.btm-tx .v2-iconbtn svg { width: 13px; height: 13px; }

/* ---- keyboard focus: visible ring on every interactive control in the new UI ---- */
.btm-tx .tx-btn:focus-visible,
.btm-tx .btm-view-btn:focus-visible,
.btm-tx .v2-check:focus-visible,
.btm-tx .v2-caret:focus-visible,
.btm-tx .v2-iconbtn:focus-visible,
.btm-tx .v2-name:focus-visible,
.btm-tx .v4-row:focus-visible,
.btm-tx .v5-chip:focus-visible,
.btm-tx .v5-crumb:focus-visible,
.btm-tx .v5-cardedit:focus-visible,
.btm-tx .v6-node:focus-visible,
.btm-tx .tx-select:focus-visible,
.btm-tx .tx-input:focus-visible {
    outline: 2px solid var(--wp-blue);
    outline-offset: 1px;
    border-radius: 4px;
}
.btm-tx .v2-name { border-radius: 3px; }

/* ---- page-title lockup (match the design header weight) ---- */
.btm-tx .wp-heading-inline { font-weight: 400; letter-spacing: -.01em; }
.btm-tx .wp-heading-inline .btm-current-tax-suffix { font-weight: 600; }

/* ---- loading overlay: anchor to the content column, adapt to folded / mobile menus ---- */
.btm-loading-screen {
    position: fixed; top: 0; left: 160px; width: calc(100% - 160px); height: 100%;
    background: #fff; z-index: 100000;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.3s ease-out;
}
body.folded .btm-loading-screen { left: 36px; width: calc(100% - 36px); }
body.auto-fold .btm-loading-screen { left: 36px; width: calc(100% - 36px); }
@media screen and (max-width: 960px) { body.auto-fold .btm-loading-screen { left: 36px; width: calc(100% - 36px); } }
@media screen and (max-width: 782px) { .btm-loading-screen { left: 0; width: 100%; } }

/* responsive */
@media screen and (max-width: 1400px) {
    /* Tighter Miller columns + a slimmer editor so more levels fit on mid-size
       screens, especially while the editor is open. */
    .btm-tx .v4-col { width: 212px; flex-basis: 212px; }
    .btm-tx .btm-term-editor { min-width: 300px; max-width: 360px; }
}
/* Mobile / skinny screens: stack the layout and give the Edit Term box the full
   width instead of a cramped side panel. */
@media screen and (max-width: 960px) {
    .btm-tx .btm-main-container { flex-direction: column; height: auto; }
    .btm-tx .btm-view { height: auto; }
    .btm-tx .btm-term-editor {
        max-width: none;
        min-width: 0;
        width: 100%;
        margin-top: 14px;
    }
    /* Columns / Tree need a usable minimum height on small screens; the Compact
       List must keep sizing to its content (no forced empty space). */
    .btm-tx .v6-stage { min-height: 360px; }
}
@media screen and (max-width: 1100px) {
    .btm-tx .v5-board { grid-template-columns: repeat(2, 1fr); }
}
@media screen and (max-width: 782px) {
    .btm-tx .v5-board { grid-template-columns: 1fr; }
    .btm-tx .btm-main-container { height: auto; }
    .btm-tx .btm-view { height: auto; }
    .btm-tx .v6-stage { min-height: 360px; }
}
