/* ═══════════════════════════════════════════════════════════════
   pathways-v3 — scoped styles
   All selectors are prefixed with .pv3- except where re-using
   global classes that already exist (e.g. .pathway-container,
   .sidebar, .toolbar, .canvas, .cred-tabs, etc.)
   ═══════════════════════════════════════════════════════════════ */

/* ── Canvas drop area ──────────────────────────────────────────── */
.pv3-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;
}

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

/* ── SVG overlay ───────────────────────────────────────────────── */
.pv3-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;   /* connections re-enable click via JS */
    overflow: visible;
}

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

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

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

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

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

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

/* ── Connector circles ─────────────────────────────────────────── */
.pv3-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;
}

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

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

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

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

/* ── Node context-menu button ──────────────────────────────────── */
.pv3-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;
}

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

/* ── Node context menu ─────────────────────────────────────────── */
.pv3-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: 130px;
    z-index: 100;
}

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

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

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

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

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

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

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

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

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

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

.pv3-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);
}

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

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

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

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

.pv3-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;
}

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

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

.pv3-radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pv3-radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
}

.pv3-radio-label input[type="radio"] {
    margin: 0;
}

.pv3-radio-pill {
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 4px 14px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

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

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

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

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

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

/* ── Connection context menu (floating at click position) ──────── */
.pv3-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;
}

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

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

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

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

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

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

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

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

/* ── Inline form row ───────────────────────────────────────────── */
.pv3-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

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

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

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

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

.pv3-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);
}

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

.pv3-toggle-status {
    font-size: 12px;
    color: #6b7280;
}

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

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

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

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

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

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

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

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

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

.pv3-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;
}

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

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

.pv3-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;
}

.pv3-badge-standard { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.pv3-badge-or       { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.pv3-badge-and      { background: #fdf4ff; color: #7c3aed; border: 1px solid #e9d5ff; }
.pv3-badge-optional { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

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

.pv3-right-conn-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.pv3-right-conn-label {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
}

.pv3-conn-status {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
}

.status-on  { background: #f0fdf4; color: #16a34a; }
.status-off { background: #f9fafb; color: #9ca3af; }

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

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

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

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

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

.pv3-logic-gate-shape {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    transition: box-shadow 0.15s, transform 0.12s;
}

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

.pv3-logic-gate-shape-and {
    background: #fdf4ff;
    color: #7c3aed;
    border: 2px solid #d8b4fe;
}

.pv3-logic-gate-shape-or {
    background: #eff6ff;
    color: #2563eb;
    border: 2px solid #93c5fd;
}

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

/* ── Canvas logic gate node ────────────────────────────────────── */
.pv3-logic-node-body {
    position: relative;
    width: 80px;
    height: 100px;
    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;
}

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

.pv3-logic-node-body-and {
    background: #fdf4ff;
    border: 3px solid #a855f7;
}

.pv3-logic-node-body-or {
    background: #eff6ff;
    border: 3px solid #3b82f6;
    height: auto;
    min-height: 120px;
}

.pv3-logic-node-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.05em;
    user-select: none;
}

.pv3-logic-node-text-and { color: #7c3aed; }
.pv3-logic-node-text-or  { color: #2563eb; }

/* ── OR gate inner layout ──────────────────────────────────────── */
.pv3-logic-or-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 8px;
    box-sizing: border-box;
    width: 100%;
}

.pv3-logic-or-badge {
    font-size: 12px;
    font-weight: 800;
    color: #2563eb;
    letter-spacing: 0.06em;
    line-height: 1;
}

.pv3-logic-or-slot {
    font-size: 9px;
    font-weight: 600;
    color: #2563eb;
    background: #dbeafe;
    border: 1px dashed #93c5fd;
    border-radius: 4px;
    padding: 3px 5px;
    text-align: center;
    width: 88px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.pv3-logic-or-cred-icon {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    object-fit: contain;
    flex-shrink: 0;
}

.pv3-logic-or-cred-name {
    font-size: 9px;
    color: #1d4ed8;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}
