/* ─── Entity Creator / Rig Mode Styles ─────────────────────────────────────── */

/* ── Toolbar: Rig Mode toggle button ── */
#toolbar .tool-btn[data-tool="rig-mode"] {
    position: relative;
}

#toolbar .tool-btn[data-tool="rig-mode"].rig-active {
    background: rgba(255, 140, 0, 0.25);
    color: #ff8c00;
    border-color: rgba(255, 140, 0, 0.5);
    box-shadow: 0 0 0 1px rgba(255, 140, 0, 0.4);
}

/* Rig mode global indicator bar */
#rig-mode-bar {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff8c00, #ffb347);
    z-index: 100;
    pointer-events: none;
}

#rig-mode-bar.visible {
    display: block;
}

/* ── Entity Creator Panel ── */
#entity-creator-panel {
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    padding: 0;
}

.ec-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 6px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.ec-header-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.55;
    flex: 0 0 auto;
}

.ec-name-input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: inherit;
    font-size: 12px;
    padding: 3px 6px;
    min-width: 0;
}

.ec-name-input:focus {
    outline: none;
    border-color: rgba(255, 140, 0, 0.5);
    background: rgba(255, 140, 0, 0.08);
}

.ec-save-btn {
    padding: 3px 8px;
    font-size: 11px;
    background: rgba(255, 140, 0, 0.15);
    color: #ff8c00;
    border: 1px solid rgba(255, 140, 0, 0.3);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}

.ec-save-btn:hover {
    background: rgba(255, 140, 0, 0.25);
}

/* ── Node Tree ── */
.ec-tree {
    padding: 6px 0;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.ec-tree-empty {
    padding: 12px;
    text-align: center;
    opacity: 0.4;
    font-size: 11px;
    font-style: italic;
}

.ec-tree-node {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 3px;
    margin: 1px 4px;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
}

.ec-tree-node:hover {
    background: rgba(255,255,255,0.06);
}

.ec-tree-node.selected {
    background: rgba(255, 140, 0, 0.15);
    color: #ff8c00;
}

.ec-tree-indent {
    display: inline-block;
    width: 12px;
    flex: 0 0 auto;
}

.ec-tree-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    flex: 0 0 auto;
    opacity: 0.7;
}

.ec-tree-node.is-root .ec-tree-icon {
    background: currentColor;
}

.ec-tree-node.is-ik .ec-tree-icon {
    border-color: #4fc3f7;
    box-shadow: 0 0 4px rgba(79,195,247,0.5);
}

.ec-tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
}

.ec-tree-badge {
    font-size: 9px;
    opacity: 0.55;
    flex: 0 0 auto;
}

/* ── Node Properties (Rig Mode) ── */
.ec-node-props {
    padding: 8px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ec-node-props-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.45;
    margin-bottom: 2px;
}

.ec-prop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.ec-prop-label {
    width: 90px;
    flex: 0 0 90px;
    opacity: 0.65;
    font-size: 11px;
}

.ec-prop-control {
    flex: 1;
    min-width: 0;
}

.ec-prop-control input[type="text"],
.ec-prop-control input[type="number"],
.ec-prop-control select {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: inherit;
    font-size: 12px;
    padding: 3px 6px;
}

.ec-prop-control input[type="text"]:focus,
.ec-prop-control input[type="number"]:focus,
.ec-prop-control select:focus {
    outline: none;
    border-color: rgba(255, 140, 0, 0.4);
}

.ec-prop-control input[type="range"] {
    width: 100%;
    accent-color: #ff8c00;
}

.ec-prop-control input[type="color"] {
    width: 100%;
    height: 26px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 1px;
}

.ec-prop-control input[type="checkbox"] {
    accent-color: #ff8c00;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.ec-prop-range-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.ec-prop-range-row span {
    width: 32px;
    text-align: right;
    opacity: 0.6;
    flex: 0 0 32px;
}

.ec-node-action-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.ec-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: inherit;
    cursor: pointer;
}

.ec-btn:hover {
    background: rgba(255,255,255,0.1);
}

.ec-btn.danger {
    border-color: rgba(233,69,96,0.35);
    color: #e94560;
    background: rgba(233,69,96,0.08);
}

.ec-btn.danger:hover {
    background: rgba(233,69,96,0.18);
}

.ec-btn.primary {
    border-color: rgba(255,140,0,0.35);
    color: #ff8c00;
    background: rgba(255,140,0,0.08);
}

.ec-btn.primary:hover {
    background: rgba(255,140,0,0.18);
}

/* ── Footer ── */
.ec-footer {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.ec-footer .ec-btn {
    font-size: 11px;
}

/* Hide the file input, triggered via label */
.ec-file-input {
    display: none;
}

/* ── Rig mode cursor style on canvas ── */
body.rig-mode #canvasContainer .canvas-container .upper-canvas {
    cursor: crosshair !important;
}

/* ── Hint text shown below tree ── */
.ec-hint {
    padding: 6px 12px;
    font-size: 10px;
    opacity: 0.35;
    line-height: 1.4;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* ─── Validation strip ────────────────────────────────────────────────────── */

.ec-validation {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
    min-height: 28px;
    align-items: center;
}

.ec-valid {
    font-size: 10px;
    color: #4caf50;
    opacity: 0.85;
}

.ec-error-chip,
.ec-warning-chip {
    display: inline-block;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 10px;
    line-height: 1.4;
    cursor: default;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ec-error-chip {
    background: rgba(220, 50, 50, 0.25);
    color: #ff6b6b;
    border: 1px solid rgba(220, 50, 50, 0.4);
}

.ec-warning-chip {
    background: rgba(255, 180, 0, 0.15);
    color: #ffc107;
    border: 1px solid rgba(255, 180, 0, 0.35);
}

/* Panel hint-pulse animation (wizard:hint 'drag-from-node') */
@keyframes ec-pulse-border {
    0%   { box-shadow: 0 0 0 0 rgba(255,140,0,0.7); }
    60%  { box-shadow: 0 0 0 6px rgba(255,140,0,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,140,0,0); }
}
.ec-hint-pulse {
    animation: ec-pulse-border 0.7s ease-out 2;
}

/* ─── Rig Wizard floating panel ───────────────────────────────────────────── */

#rig-wizard {
    position: absolute;
    bottom: 80px;
    left: 14px;
    z-index: 60;
    width: 240px;
    background: #1e2030;
    border: 1px solid rgba(255,140,0,0.35);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.55);
    padding: 12px 14px;
    color: #e0e0e0;
    font-size: 12px;
    pointer-events: all;
    transition: opacity 0.2s;
}

.rwiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rwiz-progress {
    display: flex;
    gap: 5px;
    align-items: center;
}

.rwiz-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: background 0.2s;
}
.rwiz-dot.done   { background: rgba(255,140,0,0.55); }
.rwiz-dot.active { background: #ff8c00; box-shadow: 0 0 0 2px rgba(255,140,0,0.3); }

.rwiz-skip {
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}
.rwiz-skip:hover { color: rgba(255,255,255,0.75); }

.rwiz-title {
    font-size: 11px;
    font-weight: 600;
    color: #ff8c00;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.rwiz-body {
    font-size: 11.5px;
    line-height: 1.55;
    color: #c8c8c8;
}
.rwiz-body strong { color: #fff; }
.rwiz-body em     { color: #ffb74d; font-style: normal; }

.rwiz-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.rwiz-btn {
    padding: 4px 12px;
    border-radius: 5px;
    font-size: 11px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
    color: #e0e0e0;
    cursor: pointer;
    transition: background 0.15s;
}
.rwiz-btn:hover   { background: rgba(255,255,255,0.14); }
.rwiz-btn.primary {
    background: rgba(255,140,0,0.25);
    border-color: rgba(255,140,0,0.5);
    color: #ffa726;
}
.rwiz-btn.primary:hover { background: rgba(255,140,0,0.40); }

/* ─── Wizard tooltip bubble ───────────────────────────────────────────────── */

#rig-wizard-tip {
    position: absolute;
    z-index: 61;
    background: rgba(255,140,0,0.9);
    color: #1a1a1a;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px 4px 8px;
    border-radius: 14px;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    margin-top: -6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

#rig-wizard-tip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(255,140,0,0.9);
    border-bottom: none;
}

