/* Flow Renderer Styles */
/* All styles for flow diagram elements: steps, branches, arrows, CTAs */

/* CSS Variables for consistent sizing */
:root {
    --step-size: 16rem;
    --step-size-px: 256px;
    --row-spacing: 4rem;
    --row-spacing-px: 64px;
    --column-spacing: 4rem;
    --column-spacing-px: 64px;
}

/* =================
   FLOW CONTAINER
   ================= */

.flow-container {
    /* NAME: FlowContainer */
    /* PURPOSE: Main container for the flow diagram */
    /* Note: Positioning and styling now handled by components.css */
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Pixi renderer removed — SVG renderers are now the standard. */

/* Step Menu Dropdown - Vertical (default, used for right-click) */
.step-menu-dropdown {
    position: absolute;
    display: flex;
    flex-direction: row;
    background: var(--bg-base);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    z-index: 1000;
    pointer-events: auto;
    width: fit-content;
}

/* Branch Menu Dropdown */
.branch-menu-dropdown {
    position: absolute;
    display: flex;
    flex-direction: row;
    gap: 0;
    background: var(--bg-base);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    z-index: 1000;
    pointer-events: auto;
}

/* Insert Step Button */
.insert-step-button {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--grey-lighter, #ccc);
    background: var(--grey-near-white, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: var(--font-weight-bold);
    color: var(--grey-silver, #666);
    transition: all 0.15s;
    z-index: 500;
}

.insert-step-button:hover {
    border-color: var(--color-slate-500, #6877a6);
    color: var(--color-slate-500, #6877a6);
    transform: scale(1.1);
}

/* Add Step Button */
.add-step-button {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px dashed var(--grey-lighter, #ccc);
    background: var(--grey-near-white, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: var(--font-weight-bold);
    color: var(--grey-light, #999);
    transition: all 0.15s;
    z-index: 500;
}

.add-step-button:hover {
    border-color: var(--color-slate-500, #6877a6);
    color: var(--color-slate-500, #6877a6);
    border-style: solid;
}

/* Loop Mode Overlay */
#loop-mode-overlay {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-slate-500, #6877a6);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
}

#loop-mode-overlay button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

#loop-mode-overlay button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.flow-container.panel-open {
    /* NAME: FlowContainerPanelOpen */
    /* PURPOSE: Flow container when details panel is open */
    margin-right: 512px;
}


/* Step Content Elements */
.step-content {
    /* NAME: StepContent */
    /* PURPOSE: Step name/content text - vertically centered */
    margin: 0 1rem;
    padding-bottom: 1rem; /* Slight offset upward from true center */
    word-wrap: break-word;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Step Meta Bottom Container - holds actor and location stacked */
.step-meta-bottom {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 6;
}

.step-meta-icon {
    font-size: 0.7rem;
    margin-right: 0.25rem;
    opacity: 0.8;
}

.step-actor,
.step-location {
    /* NAME: StepMeta */
    /* PURPOSE: Actor and location display with icons - stacked at bottom */
    font-size: var(--text-xsmall);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =================
   BRANCH ELEMENTS
   ================= */

.branch-header {
    /* NAME: BranchHeader */
    /* PURPOSE: Header showing branch letter and name */
    position: absolute;
    min-width: 120px;
    text-align: left;
    color: var(--text-muted);
    padding-left: 1rem;
    z-index: 30; /* Above add-step buttons (z-index: 25) so menu dropdown works */
    cursor: pointer;
}

.branch-letter {
    /* NAME: BranchLetter */
    /* PURPOSE: Branch letter (A, B, C, etc.) */
    font-size: var(--text-small);
    font-weight: var(--font-weight-bold);
}

.branch-name {
    /* NAME: BranchName */
    /* PURPOSE: Branch name text */
    font-size: var(--text-small);
    font-weight: var(--font-weight-medium);
}

/* Branch Button - now uses standard .btn .btn-secondary compact classes */

.loop-button {
    /* NAME: LoopButton */
    /* PURPOSE: Small button on steps to create loops - uses .btn .btn-sm */
    position: absolute;
    bottom: 0.25rem;
    right: 2.75rem; /* Position to the left of branch button */
    z-index: 10;
    line-height: 1;
}

/* =================
   STEP SELECTION MODE
   ================= */

#step-selection-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.step-selection-banner {
    background: var(--blue-border);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.cancel-loop {
    color: white !important;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: background-color 0.2s;
}

.cancel-loop:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none !important;
}

#loop-success-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    animation: slideDown 0.3s ease-out;
}

.loop-success-banner {
    background: #28a745;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Step selection states now handled by canvas rendering */
.step-selectable {
    cursor: pointer !important;
    transition: all 0.2s ease;
    /* Visual styling now handled by canvas */
}

.step-selectable:hover {
    /* Hover effects now handled by canvas */
    transform: scale(1.02);
}

.step-not-selectable {
    cursor: not-allowed !important;
    /* Visual styling now handled by canvas */
}

.step-not-selectable:hover {
    transform: none !important;
}

/* Insert point styles */
.insert-point {
    position: absolute;
    z-index: 25; /* Higher than giant canvas (15) */
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: all; /* Always allow interaction */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Show insert point only when hovering directly over it */
.insert-point:hover {
    opacity: 1;
}

.insert-button {
    /* Uses .btn .btn-secondary .circular */
    background-color: var(--grey-dim);
    border-color: var(--grey-dim);
    color: white;
    box-shadow: var(--shadow-raised);
}

.insert-button:hover {
    background-color: var(--grey-dark);
    border-color: var(--grey-dark);
}

.insert-icon {
    line-height: 1;
}

/* Add Step button styling (circular button, always visible) */
.add-step-button {
    /* Uses .btn .btn-secondary .circular */
    background-color: var(--grey-dim);
    border-color: var(--grey-dim);
    color: white;
    box-shadow: var(--shadow-raised);
    opacity: 1; /* Always visible unlike insert buttons */
}

.add-step-button:hover {
    background-color: var(--grey-dark);
    border-color: var(--grey-dark);
}

.add-step-icon {
    line-height: 1;
}

/* Close Branch button - now uses standard .btn .btn-secondary compact classes */


/* Add Step CTA container styling (square container, button aligned left) */
.add-step-cta-container {
    position: absolute;
    z-index: 25; /* Same as insert points */
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align button to left of container */
    cursor: default; /* Override any inherited pointer cursor */
}

.cta-options {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align buttons to left */
    gap: 8px; /* Space between Add Step and Close Branch buttons */
}

/* =================
   LOOP ARROWS (SVG)
   ================= */

.loop-arrows-svg {
    pointer-events: none;
}

.loop-arrow {
    transition: all 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
}

.loop-arrow:hover {
    stroke-width: 3;
    stroke: #ff4500;
    z-index: 1000;
    filter: drop-shadow(0 0 4px rgba(255, 107, 53, 0.5));
}

/* Arrowhead styling */
#loop-arrowhead polygon {
    transition: fill 0.3s ease;
}

.loop-arrow:hover ~ defs #loop-arrowhead polygon,
.loop-arrow:hover + defs #loop-arrowhead polygon {
    fill: #ff4500;
}

/* =================
   ADD STEP CTA
   ================= */

/* Old add-step-cta styles removed - using new add-step-button styles */

/* =================
   ADD STEP FORM
   ================= */

.add-step-form {
    /* NAME: AddStepForm */
    /* PURPOSE: Form for adding new steps */
    width: 260px;
    height: auto;
    background: var(--bg-raised, white);
    border: 2px solid var(--blue-border);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0.75rem;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform-origin: top left;
}

.step-form-header {
    /* NAME: StepFormHeader */
    /* PURPOSE: Header showing step ID being edited */
    font-size: var(--text-small);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color-light);
    margin-bottom: 0.25rem;
}

.checkbox-label-inline {
    /* NAME: CheckboxLabelInline */
    /* PURPOSE: Compact inline checkbox label */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-xsmall);
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label-inline input[type="checkbox"] {
    margin: 0;
}

.step-name-input {
    /* NAME: StepNameInput */
    /* PURPOSE: Input field for new step name */
    width: 100%;
    padding: 0.375rem;
    border: var(--border-ui);
    border-radius: 0.25rem;
    font-size: var(--text-small);
}

.step-name-input:focus {
    outline: none;
    border-color: var(--blue-border);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-buttons {
    /* NAME: FormButtons */
    /* PURPOSE: Container for form action buttons */
    display: flex;
    gap: 0.5rem;
}

/* =================
   INDICATORS
   ================= */

.note-indicator {
    /* NAME: NoteIndicator */
    /* PURPOSE: Shows note count on steps/branches */
    position: absolute;
    bottom: 0.25rem;
    left: 0.25rem;
    background: #fff3cd;
    color: #856404;
    font-size: 0.75rem;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-weight: var(--font-weight-bold);
    z-index: 10;
    border: 1px solid #ffeaa7;
    min-width: 1.5rem;
    text-align: center;
}

.task-indicator {
    /* NAME: TaskIndicator */
    /* PURPOSE: Shows task count badge on steps */
    position: absolute;
    bottom: 0.25rem;
    right: 0.25rem;
    background: var(--accent-primary, #4a9eff);
    color: white;
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.75rem;
    font-weight: var(--font-weight-bold);
    z-index: 10;
    min-width: 1.5rem;
    text-align: center;
    transition: background 0.2s ease;
}

.task-indicator:hover {
    background: var(--accent-primary-hover, #3a8eef);
    filter: brightness(1.15);
}

.nested-story-indicator {
    /* NAME: NestedStoryIndicator */
    /* PURPOSE: Shows step has nested story (clickable link) - DEPRECATED, use .nested-story-toggle */
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 0.75rem;
    padding: 0.125rem 0.25rem;
    z-index: 10;
    cursor: pointer;
    color: var(--blue-border);
    background: var(--blue-subtle);
    border-radius: 0.25rem;
    border: 1px solid var(--blue-strong);
    text-decoration: none;
}

.nested-story-indicator:hover {
    color: var(--blue-strong);
    background: var(--blue-subtle);
    text-decoration: none;
}

/* =================
   NESTED STORY EXPAND/COLLAPSE
   ================= */

.nested-story-toggle {
    /* NAME: NestedStoryToggle */
    /* PURPOSE: Expand/collapse button for nested stories */
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.625rem;
    padding: 0;
    z-index: 10;
    cursor: pointer;
    color: var(--blue-strong);
    background: var(--blue-subtle);
    border-radius: 0.25rem;
    border: 1px solid var(--blue-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.nested-story-toggle:hover {
    color: white;
    background: var(--blue-strong);
    border-color: var(--blue-strong);
}

.nested-story-toggle.expanded {
    color: white;
    background: var(--blue-strong);
    border-color: var(--blue-strong);
}

.nested-story-toggle .toggle-icon {
    font-size: 0.625rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.nested-story-toggle.expanded .toggle-icon {
    transform: rotate(0deg);
}

/* Nested story container - renders inline below step */
.nested-story-container {
    /* NAME: NestedStoryContainer */
    /* PURPOSE: Container for inline nested story rendering */
    position: absolute;
    left: 0;
    top: calc(100% + 0.5rem);
    min-width: 100%;
    background: var(--surface-secondary);
    border: 2px solid var(--blue-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nested-story-container.loading {
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nested-story-container.error {
    border-color: var(--red-border, #dc2626);
    background: var(--red-subtle, #fef2f2);
}

.nested-story-header {
    /* NAME: NestedStoryHeader */
    /* PURPOSE: Header showing nested story name */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--grey-soft);
}

.nested-story-header .story-name {
    font-weight: var(--font-weight-bold);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.nested-story-header .story-badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    background: var(--blue-subtle);
    color: var(--blue-strong);
    border-radius: 0.25rem;
    text-transform: uppercase;
    font-weight: var(--font-weight-bold);
}

.nested-story-content {
    /* NAME: NestedStoryContent */
    /* PURPOSE: Content area for nested flow steps */
    position: relative;
    min-height: 2rem;
}

.nested-story-steps {
    /* NAME: NestedStorySteps */
    /* PURPOSE: List of steps from nested story */
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nested-step-item {
    /* NAME: NestedStepItem */
    /* PURPOSE: Individual step in nested story summary */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: var(--surface-primary);
    border-radius: 0.25rem;
    font-size: 0.8125rem;
    border: var(--border-default);
}

.nested-step-item .step-number {
    font-weight: var(--font-weight-bold);
    color: var(--text-secondary);
    min-width: 1.5rem;
}

.nested-step-item .step-name {
    flex: 1;
    color: var(--text-primary);
}

.nested-step-item .step-actor {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.nested-step-item.has-children {
    border-left: 3px solid var(--blue-border);
}

.nested-story-empty {
    /* NAME: NestedStoryEmpty */
    /* PURPOSE: Empty state for nested story with no steps */
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    padding: 1rem;
}

.nested-story-error {
    /* NAME: NestedStoryError */
    /* PURPOSE: Error state when nested story fails to load */
    text-align: center;
    color: var(--red-strong, #dc2626);
    font-size: 0.8125rem;
    padding: 1rem;
}

.nested-story-loading {
    /* NAME: NestedStoryLoading */
    /* PURPOSE: Loading spinner for nested story */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
}

.nested-story-loading .spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--grey-soft);
    border-top-color: var(--blue-strong);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.create-story-button {
    /* NAME: CreateStoryButton */
    /* PURPOSE: Button to create nested story from step - uses .btn .btn-sm */
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 10;
    color: var(--text-muted);
}

.create-story-button:hover {
    color: var(--blue-border);
}

/* Nested story button - uses standard .btn .icon-only .btn-sm */
/* Only minimal overrides needed */
.step-header-right [data-role="create-nested-story"],
.step-header-right [data-role="nested-story-toggle"] {
    opacity: 0.5;
}

.step-element:hover .step-header-right [data-role="create-nested-story"],
.step-element:hover .step-header-right [data-role="nested-story-toggle"] {
    opacity: 1;
}

/* =================
   NESTED STORY INLINE FLOW CONTAINER
   ================= */

.nested-story-flow-container {
    /* NAME: NestedStoryFlowContainer */
    /* PURPOSE: Container for inline nested story flow rendering */
    /* NOTE: Visual styling (background, border) is handled by giant canvas */
    position: absolute;
    background: transparent;
    border: none;
    border-radius: 12px;
    z-index: 15;
    overflow: visible;
}

.nested-story-flow-container.nesting-level-1,
.nested-story-flow-container.nesting-level-2,
.nested-story-flow-container.nesting-level-3 {
    /* Canvas handles the visual distinction */
    background: transparent;
    border: none;
}

.nested-story-flow-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
}

.nested-story-flow-container.empty {
    display: flex;
    flex-direction: column;
}

.nested-story-flow-header {
    /* NAME: NestedStoryFlowHeader */
    /* PURPOSE: Header bar for nested story container */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px 10px 0 0;
    position: relative;
    z-index: 2; /* Above canvas but part of UI */
}

/* All nesting levels use same subtle grey */
.nesting-level-1 .nested-story-flow-header,
.nesting-level-2 .nested-story-flow-header,
.nesting-level-3 .nested-story-flow-header {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

.nested-story-collapse-btn {
    /* NAME: NestedStoryCollapseBtn */
    /* PURPOSE: Collapse button in nested story header */
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    background: var(--bg-raised, white);
    border: var(--border-default);
    border-radius: 4px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    transition: all 0.15s ease;
}

.nested-story-collapse-btn:hover {
    background: var(--blue-strong, #3b82f6);
    border-color: var(--blue-strong, #3b82f6);
    color: white;
}

.nested-story-flow-title {
    /* NAME: NestedStoryFlowTitle */
    /* PURPOSE: Title of nested story in header */
    flex: 1;
    margin: 0;
    font-size: 0.875rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nested-story-open-btn {
    /* NAME: NestedStoryOpenBtn */
    /* PURPOSE: Button to open nested story in full view */
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    background: transparent;
    border: var(--border-default);
    border-radius: 4px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.nested-story-open-btn:hover {
    background: var(--bg-muted, #f3f4f6);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.nested-story-flow-content {
    /* NAME: NestedStoryFlowContent */
    /* PURPOSE: Content area for nested steps */
    position: relative;
    padding: 0.75rem;
}

.nested-story-flow-content .step-element {
    /* Nested steps use absolute positioning within container */
    position: absolute;
}

.nested-story-flow-content .step-element.nested-step {
    /* Visual styling (background, border) is handled by giant canvas */
    /* HTML element is transparent overlay for content and interactivity */
    background: transparent;
    border: none;
    box-shadow: none;
}

.nested-story-loading-content {
    /* NAME: NestedStoryLoadingContent */
    /* PURPOSE: Loading state content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.8125rem;
}

.loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--grey-soft);
    border-top-color: var(--blue-strong, #3b82f6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.nested-story-empty-content {
    /* NAME: NestedStoryEmptyContent */
    /* PURPOSE: Empty state content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    text-align: center;
}

.nested-story-empty-content p {
    margin: 0;
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.8125rem;
}

.nested-story-empty-content .btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

/* =================
   ARROWS/CONNECTIONS
   ================= */

.arrow-canvas {
    /* NAME: ArrowCanvas */
    /* PURPOSE: Canvas element for drawing connection arrows */
    pointer-events: none;
    z-index: 10;
}

/* =================
   EMPTY STATE
   ================= */

.flow-empty-state {
    /* NAME: FlowEmptyState */
    /* PURPOSE: Empty state when no flow content exists */
    width: 800px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    border: 2px dashed var(--grey-light);
    border-radius: 8px;
}

.flow-empty-content {
    /* NAME: FlowEmptyContent */
    /* PURPOSE: Content within empty state */
    text-align: center;
    color: var(--text-secondary);
}

.flow-empty-content h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.flow-empty-content p {
    margin-bottom: 0.5rem;
}

/* =================
   ERROR STATES
   ================= */

.flow-error {
    /* NAME: FlowError */
    /* PURPOSE: Error display in flow renderer */
    background: var(--color-error-bg);
    border: 1px solid var(--color-error);
    border-radius: 6px;
    padding: 1rem;
    color: var(--color-error);
    text-align: center;
    margin: 1rem 0;
}

/* =================
   ADD STEP CTA
   ================= */

/* Old duplicate add-step-cta styles removed - using new add-step-button styles */

/* =================
   EDIT STEP FORM
   ================= */

/* Step Form Containers - positioning for add/edit forms */
.add-step-form-container,
.edit-step-form-container {
    position: absolute;
    z-index: 100;
}

/* =================
   EDIT BRANCH FORM
   ================= */

/* Edit Branch Form Container - uses same .add-step-form styles */
.edit-branch-form-container {
    position: absolute;
    z-index: 100;
}

/* Branch Name Input - matches step-name-input styling */
.branch-name-input {
    width: 100%;
    padding: 0.375rem;
    border: var(--border-ui);
    border-radius: 0.25rem;
    font-size: var(--text-small);
}

.branch-name-input:focus {
    outline: none;
    border-color: var(--blue-border);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Branch Note Indicator - inline positioning after branch text */
.branch-note-indicator {
    margin-left: 0.5rem;
    font-size: var(--text-xsmall);
    color: var(--text-secondary);
    display: inline;
}

/* ========================================
   STEP ELEMENTS & COMPONENTS
   ======================================== */

/* Step Element - Main Container */
.step-element {
    /* NAME: StepElement */
    /* PURPOSE: Individual step in the flow diagram */
    position: absolute;
    width: var(--step-size);
    height: var(--step-size);
    /* background: removed - now provided by canvas */
    /* border: removed - now provided by canvas */
    /* border-radius: removed - now provided by canvas */
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-small);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all 0.2s;
    flex-direction: column;
    text-align: center;
    padding: 0.5rem;
    z-index: 2; /* Above canvas (z-index: 1) but below modals */
}

.step-element:hover {
    /* Visual feedback handled by canvas - no box-shadow (doesn't work with diamond shape) */
}

.step-element.selected {
    /* Selection styling now handled by canvas or other means */
    /* Note: May need to implement canvas-based selection highlighting */
}

/* AI Navigation Highlight */
.step-element.ai-highlight {
    /* NAME: AIHighlight */
    /* PURPOSE: Temporary highlight when AI points to a step */
    animation: ai-pulse 0.5s ease-in-out 3;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 
                0 0 20px rgba(59, 130, 246, 0.3);
    z-index: 100;
}

@keyframes ai-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5), 
                    0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3), 
                    0 0 30px rgba(59, 130, 246, 0.4);
    }
}

/* Nested step AI highlight */
.nested-step.ai-highlight {
    animation: ai-pulse 0.5s ease-in-out 3;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

.step-element.decision {
    /* Decision steps need content offset upward due to diamond shape */
}

.step-element.decision .step-content {
    /* Extra upward offset for diamond shape centering */
    padding-bottom: 2.5rem;
}

/* Step Buttons Container */
.step-buttons {
    position: relative;
    width: 100%;
    display: flex; /* v0.6: Show branch buttons again */
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem; /* Small gap between buttons */
}

/* Step Header Layout */
.step-header {
    width: 100%;
    padding: 0.5rem 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 1;
}

.step-header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.step-header-right {
    display: flex;
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* Step Identifier (A1, B2, etc.) */
.step-identifier {
    /* NAME: StepIdentifier */
    /* PURPOSE: Step position/ID display (A1, B2, etc.) - top left corner */
    font-size: var(--text-xsmall);
    font-weight: var(--font-weight-bold);
    color: var(--text-muted);
}

/* Step Menu Container */
.step-menu-container {
    position: relative;
    display: inline-block;
}

/* Step Menu Trigger - uses standard .btn .icon-only .btn-sm */
/* Only minimal overrides needed */
.step-header-right [data-role="step-menu-trigger"] {
    opacity: 0.5;
}

.step-element:hover .step-header-right [data-role="step-menu-trigger"] {
    opacity: 1;
}

/* =================
   EDIT OVERLAY
   ================= */

/* Base edit overlay - positioned via JS, styled via CSS */
.edit-overlay {
    position: fixed;
    display: none;
    pointer-events: auto;
    z-index: 50; /* Below header (z-index: 100) so overlay doesn't cover navigation */
    box-sizing: border-box;
    background: transparent;
    border: none;
    box-shadow: none;
    outline: none;
    padding: 0;
    margin: 0;
}

/* Edit mode - inline editing, transparent container */
.edit-overlay.edit-mode {
    display: flex;
    flex-direction: column;
}

/* Actor label - uses CSS custom properties set by JS for zoom-scaled values */
.edit-overlay .edit-actor {
    font-family: var(--edit-font-family, var(--font-family-base));
    font-size: var(--edit-actor-font-size, 10px);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    padding-left: var(--edit-padding-left, 10px);
    padding-top: var(--edit-actor-padding-top, 8px);
    background: transparent;
}

/* Editable text input - uses CSS custom properties */
.edit-overlay .edit-input {
    font-family: var(--edit-font-family, var(--font-family-base));
    font-size: var(--edit-action-font-size, 13px);
    font-weight: var(--font-weight-medium);
    line-height: 1.3;
    color: var(--text-primary);
    padding-left: var(--edit-padding-left, 10px);
    padding-top: var(--edit-input-padding-top, 0);
    padding-right: var(--edit-padding-left, 10px);
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    resize: none;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
}

/* Target label */
.edit-overlay .edit-target {
    position: absolute;
    top: var(--edit-target-top, 54px);
    font-family: var(--edit-font-family, var(--font-family-base));
    font-size: var(--edit-actor-font-size, 10px);
    font-weight: var(--font-weight-medium);
    color: var(--fractal-step-border-nested, #6877a6);
    padding-left: var(--edit-padding-left, 10px);
    background: transparent;
}

/* Chips container */
.edit-overlay .edit-chips {
    display: flex;
    gap: var(--edit-chip-gap, 6px);
    position: absolute;
    bottom: var(--edit-chip-bottom, 22px);
    left: var(--edit-padding-left, 10px);
    background: transparent;
}

/* Individual chip */
.edit-overlay .edit-chip {
    font-size: var(--edit-chip-font-size, 9px);
    font-weight: var(--font-weight-bold);
    padding: var(--edit-chip-padding, 2px 6px);
    border-radius: 4px;
}

.edit-overlay .chip-decision {
    background: var(--fractal-chip-decision-bg, rgba(255, 179, 71, 0.15));
    color: var(--fractal-chip-decision-text, #b8860b);
}

.edit-overlay .chip-nested {
    background: var(--fractal-chip-nested-bg, rgba(104, 119, 166, 0.15));
    color: var(--fractal-chip-nested-text, #6877a6);
}

.edit-overlay .chip-loop {
    background: rgba(255, 71, 105, 0.15);
    color: var(--color-red-400);
}

/* Selectable text overlay - transparent overlay for text selection
   Canvas shows the step shape/border underneath, DOM overlay shows only text */
.edit-overlay.selectable-mode {
    /* NAME: SelectableOverlay */
    /* PURPOSE: Transparent overlay for text selection - canvas shows shape */
    display: flex;
    flex-direction: column;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.edit-overlay.selectable-mode .selectable-actor,
.edit-overlay.selectable-mode .selectable-action,
.edit-overlay.selectable-mode .selectable-target,
.edit-overlay.selectable-mode .selectable-chips,
.edit-overlay.selectable-mode .selectable-chip {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

/* Selection highlight color */
.edit-overlay.selectable-mode ::selection {
    background: var(--color-slate-200, rgba(104, 119, 166, 0.3));
    color: inherit;
}

.edit-overlay.selectable-mode ::-moz-selection {
    background: var(--color-slate-200, rgba(104, 119, 166, 0.3));
    color: inherit;
}

/* Dark mode - overlay stays transparent, canvas handles dark styling */
.dark-mode .edit-overlay.selectable-mode {
    background: transparent !important;
    border: none !important;
}

.dark-mode .edit-overlay.selectable-mode .selectable-actor {
    color: var(--grey-light, #aaa);
}

.dark-mode .edit-overlay.selectable-mode .selectable-action {
    color: var(--grey-lightest, #fff);
}

