/* ═══════════════════════════════════════════════════════════════════
   pathways-v6 — scoped styles
   All selectors are prefixed with .pv5- to avoid conflicts with other
   pathway versions. Global classes (.sidebar, .toolbar, .canvas, etc.)
   are shared and not re-defined here.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Canvas drop area ────────────────────────────────────────────────── */
.pv5-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #fafafa;
    background-image:
        linear-gradient(rgba(0,0,0,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px);
    background-size: 32px 32px;
}

.final-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #22c55e;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    margin-top: 4px;
    letter-spacing: 0.03em;
}

.pv5-canvas-drag-over {
    background-color: #e8f4fd;
    outline: 2px dashed #3b82f6;
    outline-offset: -4px;
}

/* ── SVG overlay ─────────────────────────────────────────────────────── */
.pv5-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 11;
}

/* ── Empty state hint ────────────────────────────────────────────────── */
.pv5-empty-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #aaa;
    user-select: none;
    pointer-events: none;
}

.pv5-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.35;
}

/* ── Credential node ─────────────────────────────────────────────────── */
.pv5-node {
    position: absolute;
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: move;
    user-select: none;
    z-index: 10;
}

.pv5-node.pv5-node-menu-active {
    z-index: 200;
}

.pv5-node-img-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    transition: box-shadow 0.15s;
}

.pv5-node:hover .pv5-node-img-wrapper {
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.pv5-node-image {
    width: 100px;
    height: 100px;
    display: block;
    border-radius: 6px;
    object-fit: contain;
}

/* ── Eye icon button (top-left of credential image) ─────────────────── */
.pv5-node-eye-btn {
    position: absolute;
    top: -8px;
    left: 0px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d1d5db;
    border-radius: 50%;
    width: 16px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    z-index: 25;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.pv5-node-img-wrapper:hover .pv5-node-eye-btn {
    opacity: 1;
}

.pv5-node-eye-btn:hover {
    color: #3b82f6;
    border-color: #3b82f6;
}

/* ── Unlink button (top-right of credential image) ───────────────────── */
.pv5-node-unlink-btn {
    position: absolute;
    top: -8px;
    right: 0px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d1d5db;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.pv5-node-img-wrapper:hover .pv5-node-unlink-btn {
    opacity: 1;
}

.pv5-node-unlink-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
}

/* ── Duplicate sequence badge ────────────────────────────────────────── */
.pv5-node-seq-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    line-height: 1;
    pointer-events: none;
}

/* ── Gate sequence badge ─────────────────────────────────────────────── */
.pv5-gate-seq-badge {
    position: absolute;
    top: -10px;
    right: 2px;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    background: #16a34a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    line-height: 1;
    pointer-events: none;
}

/* ── Connector circles ───────────────────────────────────────────────── */
.pv5-connector {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid #9ca3af;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    cursor: crosshair;
    z-index: 20;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.pv5-connector-left  { left:  -7px; }
.pv5-connector-right { right: -7px; }

.pv5-connector:hover,
.pv5-connector-active {
    background: #3b82f6;
    border-color: #1d4ed8;
    transform: translateY(-50%) scale(1.3);
}

/* ── Node name label ─────────────────────────────────────────────────── */
.pv5-node-name {
    font-size: 11px;
    text-align: center;
    margin-top: 6px;
    max-width: 130px;
    word-break: break-word;
    color: #374151;
    line-height: 1.3;
}

/* ── Node inline label ───────────────────────────────────────────────── */
.pv5-node-label-area {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 20px;
    margin-top: 3px;
    width: 100%;
}

.pv5-node-label-view {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    max-width: 120px;
}

.pv5-node-label-text {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #1d4ed8;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 999px;
    padding: 2px 8px;
    max-width: 96px;
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
}

.pv5-node-label-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 2px 0;
    color: #6b7280;
    font-size: 11px;
    line-height: 1;
    opacity: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.pv5-node-label-edit-btn:hover {
    color: #3b82f6;
}

.pv5-node-label-input {
    width: 110px;
    font-size: 11px;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    padding: 2px 5px;
    outline: none;
    text-align: center;
    box-sizing: border-box;
    color: #374151;
}

/* ── Incoming connection labels below the node ───────────────────────── */
.pv5-node-conn-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    max-width: 145px;
    margin-top: 3px;
}

/* ── Node context-menu button ────────────────────────────────────────── */
.pv5-node-menu-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    z-index: 30;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.pv5-node:hover .pv5-node-menu-btn {
    opacity: 1;
}

/* ── Node context menu ───────────────────────────────────────────────── */
.pv5-node-menu {
    position: absolute;
    top: -10px;
    right: 20px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    padding: 6px 0;
    list-style: none;
    margin: 0;
    min-width: 160px;
    z-index: 100;
}

.pv5-node-menu li {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    color: #374151;
}

.pv5-node-menu li:hover {
    background: #f3f4f6;
    color: #ca0a0a;
}

/* ── Sidebar drag item ───────────────────────────────────────────────── */
.pv5-sidebar-drag-item {
    display: inline-block;
    cursor: grab;
}

.pv5-sidebar-drag-item:active {
    cursor: grabbing;
}

.pv5-add-btn {
    cursor: pointer;
    color: #374151;
}

.pv5-add-btn:hover {
    color: #22c55e;
}

/* ── Toolbar legend ──────────────────────────────────────────────────── */
.pv5-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    font-size: 11px;
    color: #6b7280;
}

.pv5-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pv5-legend-hint {
    font-style: italic;
    white-space: nowrap;
}

/* ── Dialog overlay ──────────────────────────────────────────────────── */
.pv5-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100010;
}

.pv5-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    min-width: 360px;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.pv5-dialog-error {
    border-top: 4px solid #ca0a0a;
}

.pv5-dialog-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 16px;
    color: #111;
}

.pv5-showpaths-dialog-overlay {
    position: fixed;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    top: 0px;
    left: 0px;
}

.pv5-form-group {
    margin-bottom: 18px;
}

.pv5-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.pv5-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.pv5-input:focus {
    border-color: #3b82f6;
}

.pv5-optional-badge {
    font-weight: normal;
    font-size: 10px;
    color: #9ca3af;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pv5-radio-group {
    display: inline-flex;
    border: 1.5px solid #d1d5db;
    border-radius: 999px;
    overflow: hidden;
}

.pv5-radio-label {
    display: flex;
    cursor: pointer;
    font-weight: normal;
}

.pv5-radio-label input[type="radio"] {
    display: none;
}

.pv5-radio-pill {
    border: none;
    border-radius: 0;
    padding: 5px 16px;
    font-size: 12px;
    color: #374151;
    background: transparent;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.pv5-radio-label + .pv5-radio-label .pv5-radio-pill {
    border-left: 1.5px solid #d1d5db;
}

.pv5-radio-label input[type="radio"]:checked + .pv5-radio-pill.mandatory {
    background: #16a34a;
    color: #fff;
}

.pv5-radio-label input[type="radio"]:checked + .pv5-radio-pill.optional {
    background: #2563eb;
    color: #fff;
}

.pv5-hint {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 6px;
    margin-bottom: 0;
}

.pv5-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ── Connection context menu ─────────────────────────────────────────── */
.pv5-conn-ctx-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    min-width: 140px;
    z-index: 100020;
    overflow: hidden;
}

.pv5-ctx-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    color: #374151;
    transition: background 0.12s;
}

.pv5-ctx-item:hover {
    background: #f3f4f6;
}

.pv5-ctx-item-danger {
    color: #ca0a0a;
}

.pv5-ctx-item-danger:hover {
    background: #fef2f2;
}

/* ── Large dialog ────────────────────────────────────────────────────── */
.pv5-dialog-large {
    min-width: 800px;
    max-width: 1000px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* ── Two-column layout ───────────────────────────────────────────────── */
.pv5-dialog-cols {
    display: flex;
    gap: 20px;
    min-height: 300px;
}

.pv5-dialog-col-left {
    flex: 0 0 75%;
    max-width: 75%;
    border-right: 1px solid #e5e7eb;
    padding-right: 20px;
    box-sizing: border-box;
}

.pv5-dialog-col-right {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    max-height: 460px;
}

/* ── Toggle switch ───────────────────────────────────────────────────── */
.pv5-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.pv5-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.pv5-toggle-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    transition: background 0.2s;
}

.pv5-toggle input:checked ~ .pv5-toggle-track {
    background: #22c55e;
}

.pv5-toggle.disabled .pv5-toggle-track {
    opacity: 0.45;
    cursor: not-allowed;
}

.pv5-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.pv5-toggle input:checked ~ .pv5-toggle-track .pv5-toggle-thumb {
    transform: translateX(18px);
}

/* ── Credential pick list ────────────────────────────────────────────── */
.pv5-cred-pick-list {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.pv5-cred-pick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
}

.pv5-cred-pick-item:last-child {
    border-bottom: none;
}

.pv5-cred-pick-item.disabled {
    opacity: 0.5;
}

.pv5-cred-pick-item.selected {
    background: #f0fdf4;
}

.pv5-cred-pick-img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.pv5-cred-pick-name {
    flex: 1;
    font-size: 13px;
    color: #374151;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Error message ───────────────────────────────────────────────────── */
.pv5-error-msg {
    color: #ca0a0a;
    font-size: 12px;
    margin-top: 6px;
    margin-bottom: 0;
}

/* ── Right panel ─────────────────────────────────────────────────────── */
.pv5-right-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px;
}

.pv5-right-conn-item {
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.pv5-right-conn-item:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.pv5-right-conn-item.active {
    border-color: #2563eb;
    background: #dbeafe;
}

.pv5-conn-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.pv5-badge-standard { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.pv5-badge-optional { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

.pv5-right-conn-cred {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
}

.pv5-right-conn-label {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
    display: block;
    margin-bottom: 4px;
}

/* ── Logic gate sidebar section ──────────────────────────────────────── */
.pv5-logic-gate-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.pv5-logic-gate-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.pv5-logic-gate-items {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.pv5-logic-gate-drag-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: grab;
    user-select: none;
}

.pv5-logic-gate-drag-item:active {
    cursor: grabbing;
}

.pv5-logic-gate-shape {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    transition: box-shadow 0.15s, transform 0.12s;
}

.pv5-logic-gate-drag-item:hover .pv5-logic-gate-shape {
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
    transform: translateY(-2px);
}

/* ── Elective gate — sidebar shape ───────────────────────────────────── */
.pv5-logic-gate-shape-elective {
    background: #f0fdf4;
    color: #166534;
    border: 2px solid #86efac;
}

.pv5-logic-gate-label {
    font-size: 10px;
    color: #6b7280;
}

/* ── Canvas elective gate node body ──────────────────────────────────── */
.pv5-logic-node-body {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    transition: box-shadow 0.15s;
}

.pv5-node:hover .pv5-logic-node-body {
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.pv5-node-logic {
    width: 130px;
}

.pv5-logic-node-body-elective {
    background: #f0fdf4;
    border: 1px dashed #22c55e;
    width: 130px;
    min-height: 80px;
    height: auto;
}

.pv5-gate-drop-active .pv5-logic-node-body-elective {
    background: #dcfce7;
    border: 2px solid #16a34a;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

/* ── Elective gate inner layout ──────────────────────────────────────── */
.pv5-logic-elective-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 10px 0;
    box-sizing: border-box;
    width: 100%;
}

/* ── Embedded credential nodes inside elective gate ─────────────────── */
.pv5-elective-embedded-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
    position: relative;
}

.pv5-elective-embedded-node:last-child {
    margin-bottom: 0;
}

.pv5-logic-elective-badge {
    font-size: 9px;
    font-weight: 800;
    color: #166534;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 2px;
    text-align: center;
}

.pv5-logic-elective-empty {
    font-size: 10px;
    color: #16a34a;
    opacity: 0.7;
    padding: 6px 0;
    text-align: center;
}

/* ── Elective credential items inside canvas node ────────────────────── */
.pv5-logic-elective-cred-item {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    box-sizing: border-box;
}

.pv5-logic-elective-cred-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
    border: 1px solid #86efac;
}

.pv5-logic-elective-cred-name {
    font-size: 10px;
    color: #78350f;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    max-width: 110px;
    padding: 2px;
    text-wrap: auto;
}

/* ── Paths Check modal ───────────────────────────────────────────────── */
.pv5-paths-dialog {
    min-width: 700px;
    max-width: 1100px;
    width: 85vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.pv5-dialog-subtitle {
    font-size: 13px;
    font-weight: normal;
    color: #6b7280;
    margin-left: 6px;
}
.pv5-paths-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    padding: 4px 2px;
}
.pv5-path-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fafafa;
}
.pv5-path-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 10px;
}
.pv5-path-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.pv5-path-step-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pv5-path-step {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
}
.pv5-path-step-elective {
    border-left: 3px solid #22c55e;
    background: #f0fdf4;
}
.pv5-path-step-no-img {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 4px;
    color: #166534;
    font-size: 14px;
    flex-shrink: 0;
}
.pv5-path-step-info {
    display: flex;
    flex-direction: column;
    max-width: 160px;
}
.pv5-path-step-name {
    font-size: 13px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pv5-path-step-elective-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #166534;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 999px;
    padding: 1px 6px;
    margin-top: 2px;
    line-height: 1.4;
}
.pv5-path-step-label {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
    margin-top: 2px;
}
.pv5-path-arrow {
    color: #9ca3af;
    font-size: 14px;
    flex-shrink: 0;
}
