/* ============================================================
 * taxonomy.css — Settings → Taxonomy panel layout
 * Uses CSS variables from styles.css; fully dark-mode aware.
 * WP10 — taxonomy-management-01KRKRMW
 * ============================================================ */

/* ── Root container ─────────────────────────────────────────── */
.tax-root {
    display: flex;
    gap: 0;
    height: calc(100vh - 220px);
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--surface);
    position: relative;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.tax-sidebar {
    width: 260px;
    min-width: 200px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background-color: var(--background);
    overflow: hidden;
}

.tax-sidebar-search {
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.tax-sidebar-search input {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.tax-sidebar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tax-resolve-box {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-bottom: 1px solid var(--border);
    font-size: var(--font-size-xs);
}

.tax-resolve-box label {
    display: block;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-size: var(--font-size-xs);
}

.tax-resolve-row {
    display: flex;
    gap: 4px;
}

.tax-resolve-row input {
    flex: 1;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
}

.tax-resolve-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tax-resolve-row button {
    padding: 3px 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
}

.tax-resolve-result {
    margin-top: 4px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 4px 6px;
    max-height: 80px;
    overflow-y: auto;
}

.tax-resolve-result .tax-resolve-canonical {
    font-weight: 600;
    color: var(--text-primary);
}

.tax-resolve-result .tax-resolve-implied {
    color: var(--text-muted);
    font-style: italic;
}

/* ── Category tree ───────────────────────────────────────────── */
#tax-tree {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xs) 0;
}

.tax-cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.tax-cat-item:hover {
    background-color: var(--surface);
}

.tax-cat-item.active {
    background-color: var(--surface);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.tax-cat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tax-cat-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-left: 4px;
    flex-shrink: 0;
}

.tax-search-results-header {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tax-search-results-header a {
    color: var(--primary-color);
    cursor: pointer;
    font-size: var(--font-size-xs);
    text-decoration: underline;
}

.tax-search-result-item {
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-size-xs);
    color: var(--text-primary);
}

.tax-search-result-item:hover {
    background-color: var(--surface);
}

.tax-search-result-item .tax-sr-canonical {
    font-weight: 500;
}

.tax-search-result-item .tax-sr-meta {
    color: var(--text-muted);
    font-size: 10px;
}

/* ── Sidebar footer ──────────────────────────────────────────── */
.tax-sidebar-footer {
    border-top: 1px solid var(--border);
    padding: var(--spacing-xs) var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.tax-version-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex: 1;
}

.tax-footer-btn {
    padding: 3px 8px;
    font-size: var(--font-size-xs);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: var(--surface);
    color: var(--text-secondary);
    transition: background-color 0.15s ease;
}

.tax-footer-btn:hover {
    background: var(--background);
    border-color: var(--secondary-color);
}

/* ── Main detail panel ───────────────────────────────────────── */
.tax-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#tax-detail {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.tax-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ── Category header ─────────────────────────────────────────── */
.tax-cat-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.tax-cat-header h3 {
    flex: 1;
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.tax-cat-actions {
    display: flex;
    gap: var(--spacing-xs);
}

/* ── Canonical term list ─────────────────────────────────────── */
.tax-terms-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tax-term-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease;
    border: 1px solid transparent;
}

.tax-term-row:hover {
    background-color: var(--background);
    border-color: var(--border);
}

.tax-term-row.active {
    background-color: var(--background);
    border-color: var(--primary-color);
}

.tax-term-name {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
}

.tax-term-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.tax-term-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tax-term-row:hover .tax-term-actions,
.tax-term-row.active .tax-term-actions {
    opacity: 1;
}

.tax-add-canonical-btn {
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    width: 100%;
    transition: all 0.15s ease;
}

.tax-add-canonical-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--background);
}

/* ── Canonical detail section ───────────────────────────────── */
.tax-canonical-detail {
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
    background: var(--surface);
}

.tax-canonical-detail-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.tax-inline-edit-name {
    flex: 1;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    background: transparent;
    transition: border-color 0.15s ease;
}

.tax-inline-edit-name:hover {
    border-color: var(--border);
    background: var(--background);
}

.tax-inline-edit-name.editing {
    border-color: var(--primary-color);
    outline: none;
    background: var(--surface);
}

.tax-conflict-banner {
    background: var(--error-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xs);
}

.tax-conflict-banner button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
}

/* ── Sub-sections (variants, implied) ───────────────────────── */
.tax-subsection {
    margin-top: var(--spacing-md);
}

.tax-subsection-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.tax-variant-list,
.tax-implied-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tax-variant-item,
.tax-implied-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    transition: background-color 0.1s ease;
    font-size: var(--font-size-sm);
}

.tax-variant-item:hover,
.tax-implied-item:hover {
    background-color: var(--background);
}

.tax-variant-text {
    flex: 1;
    color: var(--text-primary);
}

.tax-implied-text {
    flex: 1;
    color: var(--text-primary);
}

.tax-implied-reason {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
    display: block;
}

.tax-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    font-size: 12px;
    line-height: 1;
    transition: color 0.1s ease;
}

.tax-delete-btn:hover {
    color: var(--error-color);
}

/* ── Add-item inline forms ───────────────────────────────────── */
.tax-add-inline {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-xs);
}

.tax-add-inline input,
.tax-add-inline textarea {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
    font-family: inherit;
}

.tax-add-inline textarea {
    resize: vertical;
    min-height: 36px;
}

.tax-add-inline input:focus,
.tax-add-inline textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tax-add-inline button {
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: var(--font-size-xs);
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.tax-add-inline button:hover {
    background: var(--primary-hover);
}

.tax-add-inline button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tax-add-implied-form {
    margin-top: var(--spacing-xs);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.tax-add-implied-form input,
.tax-add-implied-form select,
.tax-add-implied-form textarea {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
    font-family: inherit;
}

.tax-add-implied-form input:focus,
.tax-add-implied-form select:focus,
.tax-add-implied-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tax-add-implied-form select option {
    background: var(--surface);
    color: var(--text-primary);
}

.tax-add-implied-row {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: flex-end;
}

.tax-inline-error {
    color: var(--error-color);
    font-size: var(--font-size-xs);
    padding: 4px 6px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 2px solid var(--error-color);
}

/* ── Canonical meta fields (sort_order, move category) ──────── */
.tax-canonical-meta {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.tax-meta-field {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.tax-meta-field label {
    font-weight: 500;
    color: var(--text-muted);
}

.tax-meta-field select,
.tax-meta-field input[type="number"] {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
}

/* ── Draft tray ──────────────────────────────────────────────── */
.tax-draft-tray {
    display: none;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--surface);
    border-top: 2px solid var(--warning-color);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.tax-draft-tray.visible {
    display: flex;
}

.tax-draft-tray-label {
    flex: 1;
    color: var(--warning-color);
    font-weight: 500;
}

/* ── Small action button (inline icon-text) ─────────────────── */
.tax-btn-sm {
    padding: 3px 10px;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tax-btn-sm:hover {
    background: var(--background);
    border-color: var(--secondary-color);
}

.tax-btn-sm.primary {
    background: var(--primary-color);
    color: white;
    border-color: transparent;
}

.tax-btn-sm.primary:hover {
    background: var(--primary-hover);
}

.tax-btn-sm.danger {
    color: var(--error-color);
    border-color: var(--error-color);
}

.tax-btn-sm.danger:hover {
    background: var(--error-color);
    color: white;
}

/* ── History drawer / modal ──────────────────────────────────── */
.tax-history-entry {
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.tax-history-entry:last-child {
    border-bottom: none;
}

.tax-history-meta {
    display: flex;
    gap: var(--spacing-sm);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tax-history-action {
    font-weight: 600;
    color: var(--text-secondary);
}

.tax-history-diff {
    display: flex;
    gap: var(--spacing-sm);
    font-size: var(--font-size-xs);
}

.tax-history-before,
.tax-history-after {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 4px 6px;
    overflow-x: auto;
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.tax-history-before {
    border-left: 2px solid var(--error-color);
    opacity: 0.8;
}

.tax-history-after {
    border-left: 2px solid var(--success-color);
}

/* ── Import diff preview ─────────────────────────────────────── */
.tax-import-diff {
    font-size: var(--font-size-xs);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.tax-import-diff-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 3px 6px;
    border-radius: var(--border-radius-sm);
    background: var(--background);
}

.tax-diff-added {
    color: var(--success-color);
    font-weight: 600;
}

.tax-diff-removed {
    color: var(--error-color);
    font-weight: 600;
}

.tax-diff-count {
    font-size: 11px;
    font-weight: 700;
    min-width: 24px;
    text-align: right;
}

/* ── Publish modal summary list ─────────────────────────────── */
.tax-publish-changes {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-xs);
}

.tax-publish-changes li {
    padding: 2px 0;
    list-style: disc;
    margin-left: var(--spacing-md);
    color: var(--text-secondary);
}

/* ── Loading / empty states ─────────────────────────────────── */
.tax-loading {
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    text-align: center;
}

.tax-error-block {
    padding: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--error-color);
    border-radius: var(--border-radius-sm);
    color: var(--error-color);
    font-size: var(--font-size-sm);
}

/* ── Category edit modal ─────────────────────────────────────── */
.tax-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tax-modal-box {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.tax-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.tax-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.tax-modal-body {
    padding: var(--spacing-lg);
}

.tax-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border);
}

.tax-form-group {
    margin-bottom: var(--spacing-md);
}

.tax-form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.tax-form-group input,
.tax-form-group textarea {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
}

.tax-form-group input:focus,
.tax-form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .tax-root {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .tax-sidebar {
        width: 100%;
        max-width: none;
        max-height: 200px;
    }

    #tax-tree {
        max-height: 120px;
    }
}
