/* FlowTool - Dark theme styling */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #0a0a0a;
    color: #e0e0e0;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    padding: 20px 0;
    margin-bottom: 30px;
    position: relative;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    color: #888;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    height: calc(100vh - 200px);
    overflow: hidden;
}

/* Flow List Panel */
.flow-list-panel {
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.flow-list-panel h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
}

.flow-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flow-item {
    background-color: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flow-item:hover {
    background-color: #1a1a1a;
    border-color: #3a3a3a;
    transform: translateX(2px);
}

.flow-item.active {
    background-color: #1a2332;
    border-color: #2563eb;
}

.flow-item h3 {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 4px;
}

.flow-item .project {
    font-size: 12px;
    color: #666;
}

/* Flow Viewer Panel */
.flow-viewer-panel {
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.flow-header {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flow-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
}

.flow-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.flow-controls select {
    background-color: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.flow-controls select:hover {
    border-color: #4b5563;
}

.flow-controls label {
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
}

/* Flow Diagram */
.flow-diagram {
    flex: 1;
    position: relative;
    background-color: #0a0a0a;
    min-height: 400px;
    min-width: 100%;
    overflow: auto;
    /* Canvas size is set dynamically by layout calculator based on flow content */
    /* The container acts as viewport, canvas expands as needed */
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background-color: #3a3a3a;
    border-color: #4a4a4a;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 16px;
}

/* ReactFlow overrides for dark theme */
.react-flow {
    background-color: #0a0a0a;
}

.react-flow__node {
    font-size: 13px;
}

.react-flow__node-default {
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    color: #ffffff;
}

.react-flow__node-default.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.react-flow__edge-path {
    stroke: #4a4a4a;
}

.react-flow__edge-text {
    fill: #888;
    font-size: 12px;
}

.react-flow__controls {
    background-color: #1a1a1a;
    border: 1px solid #2a2a2a;
}

.react-flow__controls-button {
    background-color: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    color: #888;
}

.react-flow__controls-button:hover {
    background-color: #2a2a2a;
    color: #ffffff;
}

/* Custom node styles */
.custom-node {
    background-color: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 10px 15px;
    min-width: 150px;
    text-align: center;
}

.custom-node.process {
    border-color: #2563eb;
}

.custom-node.decision {
    border-color: #f59e0b;
    transform: rotate(45deg);
}

.custom-node.decision .node-label {
    transform: rotate(-45deg);
}

.custom-node.wallet {
    border-color: #8b5cf6;
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
}

.custom-node.start,
.custom-node.end {
    border-radius: 25px;
    border-color: #10b981;
}

.node-label {
    font-weight: 500;
    color: #ffffff;
}

.node-details {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

/* Header controls */
.header-controls {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.edit-mode-btn {
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #888;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-mode-btn:hover {
    background-color: #3a3a3a;
    border-color: #4a4a4a;
}

.edit-mode-btn.active {
    background-color: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Dialog styles */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog {
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dialog-wide {
    max-width: 800px;
}

.dialog-header {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.dialog-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-close:hover {
    color: #ffffff;
}

.dialog-tabs {
    display: flex;
    border-bottom: 1px solid #2a2a2a;
    background-color: #0a0a0a;
}

.tab-btn {
    background: none;
    border: none;
    color: #888;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    background-color: #1a1a1a;
    color: #ffffff;
}

.tab-btn.active {
    background-color: #1a1a1a;
    color: #2563eb;
    border-bottom: 2px solid #2563eb;
}

.dialog-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    background-color: #0a0a0a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #2a2a2a;
}

/* Button styles */
.btn-primary {
    background-color: #2563eb;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary:disabled:hover {
    background-color: #2563eb;
    transform: none;
}

.btn-secondary {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #4a4a4a;
    border-color: #5a5a5a;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

/* Edit mode indicators */
.flow-item.edit-mode {
    cursor: pointer;
    position: relative;
}

.flow-item.edit-mode::after {
    content: '✏️';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 12px;
}

.custom-node.edit-mode {
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.custom-node.edit-mode:hover {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
}

/* List items in dialogs */
.detail-item,
.alert-item {
    background-color: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-item:hover,
.alert-item:hover {
    background-color: #1a1a1a;
    border-color: #3a3a3a;
}

.detail-item .order,
.alert-item .order {
    font-size: 12px;
    color: #666;
    margin-right: 10px;
}

.alert-item .type {
    font-size: 12px;
    color: #2563eb;
    margin-left: 10px;
}

/* Position items */
.position-item {
    background-color: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
}

.position-item:hover {
    background-color: #1a1a1a;
    border-color: #3a3a3a;
}

.position-info {
    background-color: #1a2332;
    border: 1px solid #2563eb;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.position-info p {
    margin: 0;
    color: #94b8ff;
    font-size: 14px;
}

/* Fixed Dialog Dimensions for Consistent Experience */
.dialog-fixed-medium {
    width: 600px !important;
    height: 500px !important;
    max-width: 90vw;
    max-height: 90vh;
}

.dialog-fixed-large {
    width: 900px !important;
    height: 700px !important;
    max-width: 90vw;
    max-height: 90vh;
}

.dialog-fixed-small {
    width: 500px !important;
    min-height: 400px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Node Edit Dialog - Large fixed size for tabs */
#node-edit-dialog .dialog {
    width: 900px !important;
    height: 700px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Connection Configuration Dialog */
#join-config-dialog,
.connection-config-dialog {
    width: 550px !important;
    min-height: 500px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Alert/Detail Edit Dialogs */
#alert-edit-dialog .dialog,
#detail-edit-dialog .dialog {
    width: 650px !important;
    height: 550px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Project Edit Dialog */
#project-edit-dialog .dialog {
    width: 750px !important;
    height: 650px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Flow Edit Dialog */
#flow-edit-dialog .dialog {
    width: 800px !important;
    height: 600px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Position Editor Dialog */
#position-editor-dialog .dialog {
    width: 600px !important;
    min-height: 450px !important;
    max-width: 90vw;
    max-height: 90vh;
}

/* Flow Details Dialog Styles */
#flow-details-dialog .dialog {
    width: 900px !important;
    height: 600px !important;
    max-height: 90vh;
}

#flow-details-dialog .dialog-content {
    height: calc(100% - 140px);
    overflow-y: auto;
}

#flow-details-dialog .tab-content {
    min-height: 400px;
    display: none;
}

#flow-details-dialog .tab-content.active {
    display: block;
}

/* Node View Dialog Styles */
#node-view-dialog .dialog {
    width: 750px !important;
    height: 650px !important;
    max-width: 90vw;
    max-height: 90vh;
}

.flow-details-grid,
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.details-section {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
}

.details-section.full-width {
    grid-column: 1 / -1;
}

.details-section h3 {
    margin: 0 0 15px 0;
    color: #e0e0e0;
    font-size: 1.1rem;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 8px;
}

.details-table {
    width: 100%;
    font-size: 0.9rem;
}

.details-table td {
    padding: 5px 0;
}

.details-table .label {
    color: #999;
    width: 40%;
}

.scenario-box, .info-box {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #3a3a3a;
    min-height: 100px;
    white-space: pre-wrap;
    line-height: 1.6;
}

.filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-badge {
    background: #3498db;
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-badge .filter-label {
    font-weight: 500;
}

.filter-badge .filter-options {
    opacity: 0.8;
    font-size: 0.8rem;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.stats-table th {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #3a3a3a;
}

.stats-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #3a3a3a;
}

.stats-table tr:hover {
    background: rgba(52, 152, 219, 0.1);
}

/* Example Values Styles */
.example-values-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
}

.example-value-item {
    display: inline-flex;
    flex-direction: column;
    min-width: 100px;
    flex: 0 0 auto;
}

.example-value-key {
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.example-value-value {
    color: #3498db;
    font-size: 14px;
    font-weight: 500;
}

.domain-color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* Flow Edit Dialog List Items */
.list-item {
    background: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.list-item input[type="text"], .list-item textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 4px;
    font-family: inherit;
}

.list-item input[type="text"]:focus, .list-item textarea:focus {
    outline: 1px solid #3498db;
    background: #1a1a1a;
}

.list-item .key-input {
    width: 150px;
    flex: 0 0 150px;
}

.list-item .value-input {
    flex: 1;
}

.list-item .remove-btn {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    flex-shrink: 0;
}

.list-item .remove-btn:hover {
    color: #ef4444;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background-color: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 99999;
    min-width: 180px;
    /* Ensure menu appears above all containers */
    pointer-events: auto;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #2a2a2a;
}

.context-menu-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.context-menu-divider {
    height: 1px;
    background-color: #3a3a3a;
    margin: 4px 0;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}


/* Header navigation */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.9em;
}

.breadcrumb-link {
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: #5dade2;
}

.breadcrumb-separator {
    margin: 0 8px;
    color: #7f8c8d;
}

.breadcrumb-current {
    color: #bdc3c7;
    font-weight: 500;
}


/* Tab navigation */
.tab-nav {
    display: flex;
    border-bottom: 1px solid #444;
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    color: #bdc3c7;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.9em;
}

.tab-btn:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Improve dialog width for tabbed content */
.dialog-wide {
    max-width: 800px;
    width: 90vw;
}

/* Better spacing for form sections in tabs */
.tab-content .form-group {
    margin-bottom: 20px;
}

.tab-content .form-group:last-child {
    margin-bottom: 0;
}

/* Master-Detail Layout Styles */
.master-detail-layout {
    display: flex;
    gap: 20px;
    height: 400px;
    background: #0a0a0a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
}

.master-list {
    flex: 0 0 300px;
    border-right: 1px solid #3a3a3a;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    font-weight: 500;
    color: #e5e7eb;
    font-size: 14px;
}

.master-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.list-item:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

.list-item.selected {
    background: #1e3a5f;
    border-color: #2563eb;
}

.list-item-title {
    flex: 1;
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.detail-view {
    flex: 1;
    padding: 15px;
    background: #0a0a0a;
    overflow-y: auto;
}

.detail-editor {
    height: 100%;
}

.empty-state {
    color: #666;
    text-align: center;
    margin-top: 50px;
    font-style: italic;
}

/* Enhanced Tab Navigation Styles */
.tab-navigation {
    display: flex;
    gap: 0px;
    margin-bottom: 20px;
    border-bottom: 2px solid #3a3a3a;
    padding-bottom: 0;
    padding-left: 5px;
    align-items: flex-end;
}

.tab-button {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-bottom: none;
    color: #999;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: all 0.2s ease;
    border-radius: 8px 8px 0 0;
    margin-right: 2px;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.2);
}

.tab-button:hover {
    background: #2a2a2a;
    color: #e5e7eb;
    border-color: #4a4a4a;
    transform: translateY(-1px);
}

.tab-button.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #2563eb;
    border-bottom: 2px solid #1a1a1a;
    margin-bottom: -2px;
    z-index: 1;
    box-shadow: 0 -4px 8px rgba(37, 99, 235, 0.2);
}

.tab-badge {
    background: #2563eb;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    min-width: 16px;
    text-align: center;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

