/*
 * admin.css — Decision Tree Navigator editor UI
 */

/* ── Layout ──────────────────────────────────────────────────────────────── */
.dtnav-admin-wrap {
    max-width: 1400px;
}

.dtnav-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 12px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
    gap: 16px;
}

.dtnav-admin-header__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1d2327;
}

.dtnav-admin-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dtnav-save-status {
    font-size: 13px;
    font-weight: 600;
    transition: color 0.2s;
}

.dtnav-save-status.is-success { color: #00a32a; }
.dtnav-save-status.is-error   { color: #d63638; }

/* ── Editor split layout ─────────────────────────────────────────────────── */
.dtnav-editor {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    border: 1px solid #ddd;
    background: #fff;
    min-height: 600px;
}

/* ── Tree panel (left) ───────────────────────────────────────────────────── */
.dtnav-editor__tree {
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    background: #f6f7f7;
}

.dtnav-editor__tree-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid #ddd;
}

.dtnav-editor__panel-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #50575e;
    margin: 0 0 4px;
}

.dtnav-editor__panel-desc {
    font-size: 12px;
    color: #787c82;
    margin: 0;
}

.dtnav-editor__section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #787c82;
    padding: 12px 16px 6px;
    margin: 0;
}

.dtnav-tree-section {
    padding: 0;
}

/* ── Tree node buttons ───────────────────────────────────────────────────── */
.dtnav-tree-node {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 16px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    color: #1d2327;
    transition: background 0.1s;
}

.dtnav-tree-node:hover {
    background: #fff;
}

.dtnav-tree-node.is-active {
    background: #fff;
    border-left: 3px solid #b31b1b;
    color: #b31b1b;
    font-weight: 600;
}

.dtnav-tree-node__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dtnav-tree-node__type-badge {
    font-size: 10px;
    letter-spacing: 0.03em;
    color: #787c82;
    background: #f0f0f1;
    padding: 1px 5px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Node list (nested) ──────────────────────────────────────────────────── */
.dtnav-node-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dtnav-node-list__item {
    position: relative;
}

.dtnav-node-list--children {
    padding-left: 0;
}

/* Depth indentation via CSS custom property */
.dtnav-node-list--children .dtnav-tree-node {
    padding-left: calc(16px + var(--depth, 1) * 16px);
}

/* Vertical tree lines */
.dtnav-node-list--children .dtnav-node-list__item::before {
    content: '';
    position: absolute;
    left: calc(var(--depth, 1) * 16px + 8px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: #ddd;
    pointer-events: none;
}

.dtnav-node-list__orphan-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
}

.dtnav-node-list__orphan-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #b32d2e;
    padding: 4px 16px 0;
}

.dtnav-node-list__orphan-tip {
    display: block;
    font-size: 10px;
    color: #787c82;
    padding: 0 16px 6px;
    line-height: 1.3;
}

/* Add node buttons */
.dtnav-add-node-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #ddd;
    flex-wrap: wrap;
    margin-top: auto;
}

.dtnav-add-node-row .button {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

/* ── Detail panel (right) ────────────────────────────────────────────────── */
.dtnav-editor__detail {
    padding: 24px 28px;
    overflow-y: auto;
}

.dtnav-editor__detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #787c82;
    font-size: 14px;
}

/* ── Form sections ───────────────────────────────────────────────────────── */
.dtnav-form-section__header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ddd;
}

.dtnav-form-section__title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #1d2327;
}

.dtnav-form-section__slug {
    font-size: 12px;
    color: #787c82;
    font-family: monospace;
    background: #f6f7f7;
    padding: 2px 6px;
    border: 1px solid #ddd;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.dtnav-field {
    margin-bottom: 16px;
}

.dtnav-field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #1d2327;
}

.dtnav-field__label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.dtnav-field__label-row .dtnav-field__label {
    margin-bottom: 0;
}

.dtnav-field__desc {
    font-size: 12px;
    color: #646970;
    margin: 4px 0 0;
}

.dtnav-field__optional {
    font-weight: 400;
    color: #787c82;
}

.dtnav-field--inline {
    flex: 1;
    min-width: 0;
}

/* Fieldsets */
.dtnav-fieldset {
    border: 1px solid #ddd;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.dtnav-fieldset legend.dtnav-field__label {
    padding: 0 4px;
}

.dtnav-fieldset__row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Choice items ────────────────────────────────────────────────────────── */
.dtnav-choice-list,
.dtnav-resource-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dtnav-choice-item,
.dtnav-resource-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #f6f7f7;
    border: 1px solid #ddd;
    padding: 10px 12px;
}

.dtnav-choice-item__grip,
.dtnav-resource-item__grip {
    color: #787c82;
    cursor: grab;
    margin-top: 6px;
    flex-shrink: 0;
}

.dtnav-choice-item__grip:active,
.dtnav-resource-item__grip:active {
    cursor: grabbing;
}

.dtnav-choice-item__fields,
.dtnav-resource-item__fields {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dtnav-choice-item__row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dtnav-choice-item__remove,
.dtnav-resource-item__remove {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    color: #787c82;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    margin-top: 2px;
    transition: color 0.1s;
}

.dtnav-choice-item__remove:hover,
.dtnav-resource-item__remove:hover {
    color: #d63638;
}

/* ── Badge preview ───────────────────────────────────────────────────────── */
.dtnav-badge-preview {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    margin-left: 8px;
    border: 1px solid;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

/* Reuse same colour tokens as frontend design.css */
.dtnav-badge-preview.navy { background: #e4f0f3; color: #073949; border-color: #b0ced7; }
.dtnav-badge-preview.blue { background: #e0eef8; color: #005581; border-color: #9cc4e0; }
.dtnav-badge-preview.grn  { background: #eaf4e2; color: #3d6622; border-color: #b0d49c; }
.dtnav-badge-preview.org  { background: #fdf0e0; color: #7a3d00; border-color: #e0b880; }
.dtnav-badge-preview.wm   { background: #f2efeb; color: #5c5248; border-color: #c4bbb4; }
.dtnav-badge-preview.red  { background: #fdf4f4; color: #b31b1b; border-color: #f0d0d0; }
.dtnav-badge-preview.prp  { background: #f4ecf7; color: #5b2c6f; border-color: #d2b4de; }

/* ── Danger zone ─────────────────────────────────────────────────────────── */
.dtnav-form-section__danger {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

.dtnav-delete-node-btn {
    color: #d63638 !important;
    border-color: #d63638 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dtnav-delete-node-btn:hover {
    background: #d63638 !important;
    color: #fff !important;
}

/* ── Sortable placeholder ────────────────────────────────────────────────── */
.ui-sortable-placeholder {
    background: #e8f0fe;
    border: 2px dashed #2271b1;
    visibility: visible !important;
    height: 44px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
    .dtnav-editor {
        grid-template-columns: 1fr;
    }

    .dtnav-editor__tree {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
}

/* ── Settings page ───────────────────────────────────────────────────────── */
.dtnav-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 40px;
    align-items: start;
    margin-top: 20px;
}

.dtnav-settings-section {
    background: #fff;
    border: 1px solid #ddd;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.dtnav-settings-section__title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dtnav-css-editor-section .dtnav-settings-section__title {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.dtnav-guide-list,
.dtnav-tips-list {
    margin: 12px 0;
    padding: 0;
    list-style: none;
}

.dtnav-guide-list li,
.dtnav-tips-list li {
    position: relative;
    padding-left: 0;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.5;
    color: #1d2327;
}

.dtnav-guide-list li strong,
.dtnav-tips-list li strong {
    display: block;
    color: #1d2327;
    margin-bottom: 2px;
}

.dtnav-tips-list {
    padding: 0 16px 16px;
}

.dtnav-tips-list li {
    font-size: 12px;
    margin-bottom: 10px;
    color: #50575e;
}

.dtnav-tips-list li em {
    font-style: italic;
    color: #b31b1b;
}

.dtnav-editor__tips {
    margin-top: 10px;
    border-top: 1px solid #ddd;
    background: #fff;
}

.dtnav-settings-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    cursor: pointer;
}

.dtnav-css-editor-wrap {
    margin-top: 10px;
}

.dtnav-css-editor-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.dtnav-css-editor {
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 12px !important;
    line-height: 1.6 !important;
    background: #1e1e1e !important;
    color: #d4d4d4 !important;
    border-color: #555 !important;
    resize: vertical;
}

/* ── Trees table ─────────────────────────────────────────────────────────── */
.dtnav-trees-table td {
    vertical-align: middle;
}

.dtnav-shortcode-display {
    font-size: 11px;
    background: #f0f0f1;
    padding: 2px 6px;
    border: 1px solid #ddd;
    display: inline-block;
    word-break: break-all;
}

.dtnav-tree-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.dtnav-delete-tree-link {
    color: #d63638 !important;
}

/* ── Admin header extended ───────────────────────────────────────────────── */
.dtnav-admin-header {
    flex-wrap: wrap;
}

.dtnav-admin-header__left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dtnav-admin-header__tree-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.dtnav-admin-header__tree-label {
    color: #787c82;
}

.dtnav-tree-name-display {
    font-weight: 600;
    color: #1d2327;
}

.dtnav-rename-btn {
    font-size: 12px;
    color: #2271b1;
    text-decoration: none;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.dtnav-rename-btn:hover {
    text-decoration: underline;
}

.dtnav-admin-header__shortcode {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .dtnav-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Design page ─────────────────────────────────────────────────────────── */
.dtnav-design-header__desc {
    font-size: 13px;
    color: #50575e;
    margin: 4px 0 0;
}

.dtnav-design-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 2px;
}

.dtnav-design-status--factory {
    background: #f0f0f1;
    color: #50575e;
    border: 1px solid #c3c4c7;
}

.dtnav-design-status--custom {
    background: #eaf4e2;
    color: #3d6622;
    border: 1px solid #b0d49c;
}

.dtnav-design-editor-wrap {
    margin-top: 16px;
    border: 1px solid #ddd;
    background: #fff;
}

/* CodeMirror overrides */
.dtnav-design-editor-wrap .CodeMirror {
    height: calc(100vh - 190px);
    min-height: 400px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.dtnav-design-editor-wrap .CodeMirror-scroll {
    min-height: 400px;
}

/* Fallback plain textarea (when CodeMirror not available) */
.dtnav-design-editor-wrap textarea.dtnav-css-editor {
    height: calc(100vh - 190px);
    min-height: 400px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    border: none;
    display: block;
    width: 100%;
    padding: 12px;
}

/* ── Unified Dashboard (Settings) ────────────────────────────────────────── */
.dtnav-settings-wrap {
    background: #f0f0f1;
    min-height: calc(100vh - 64px);
    padding: 2px 20px 40px;
}

.dtnav-settings-bar {
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 12px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.dtnav-dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dtnav-manage-table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: #646970;
}

.dtnav-manage-table td {
    padding: 12px 15px !important;
}

.dtnav-manage-table .col-shortcode {
    width: 24% !important;
}

.dtnav-manage-table .col-toggle {
    text-align: center;
    width: 90px;
    padding: 12px 5px !important;
}

.dtnav-manage-table .col-toggle input[type="checkbox"] {
    margin: 0;
    transform: scale(1.1);
    cursor: pointer;
}

.dtnav-manage-table .col-actions {
    width: auto;
    min-width: 160px;
}

.dtnav-sc-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dtnav-sc-box code {
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    padding: 3px 8px;
    font-size: 12px;
    color: #1d2327;
}

/* Dashboard Actions */
.dtnav-row-actions {
    margin-top: 6px;
    font-size: 12px;
    color: #a7aaad;
}

.dtnav-row-actions .button-link {
    font-size: 12px;
    text-decoration: none;
    padding: 0;
}

.dtnav-delete-link {
    color: #d63638 !important;
}

.dtnav-manage-table .col-toggle {
    text-align: center;
    width: 60px;
}

.dtnav-manage-table .col-toggle input[type="checkbox"] {
    margin: 0;
    transform: scale(1.1);
}

.dtnav-css-editor-section {
    border: 2px solid #2271b1 !important;
    animation: dtnav-fade-in 0.3s ease-out;
}

@keyframes dtnav-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dtnav-inline-css-editor__header {
    margin-bottom: 20px;
    padding-bottom: 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dtnav-inline-css-editor__title {
    margin: 0;
    font-size: 14px;
}

.dtnav-inline-css-editor__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dtnav-inline-css-editor__body {
    padding: 15px 20px 20px;
}

.dtnav-css-save-status {
    font-size: 12px;
    font-weight: 600;
}

.dtnav-css-save-status.is-success { color: #00a32a; }
.dtnav-css-save-status.is-error   { color: #d63638; }

.dtnav-inline-css-editor .CodeMirror {
    height: 400px;
    border: 1px solid #ddd;
    resize: vertical;
    overflow: auto !important;
}

.dtnav-settings-sub-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dtnav-guide-list.mini li {
    margin-bottom: 8px;
}

.dtnav-empty-state {
    padding: 60px 20px;
    text-align: center;
    background: #fff;
    border: 1px dashed #ccd0d4;
}
