/* Main Layout */
#cf-app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 32px);
    /* Subtract WP Admin Bar */
    background: #f3f4f6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#cf-toolbar {
    height: 50px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

#cf-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
#cf-sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.cf-sidebar-header,
.cf-inspector-header {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

#cf-node-palette {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.cf-palette-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.cf-palette-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cf-palette-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 16px;
}

.cf-palette-label {
    font-weight: 500;
    color: #1f2937;
    font-size: 14px;
}

/* Canvas */
#cf-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
}

#cf-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    width: 10000px;
    /* Huge canvas */
    height: 10000px;
}

#cf-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    /* Let clicks pass through to nodes unless stroke */
}

/* Nodes - Swift Parity (Small Colored Chips) */
.cf-node {
    position: absolute;
    width: 140px;
    /* Slightly wider than 120 for HTML text safety */
    min-height: 70px;
    border-radius: 14px;
    /* Exact match */
    z-index: 2;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.1s, box-shadow 0.2s;
    /* Gradient backgrounds handled by JS inline styles or classes */
    color: white;
    cursor: default;
}

.cf-node.selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #2563eb, 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    transform: scale(1.02);
}

.cf-node-inner {
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    pointer-events: none;
    /* Let clicks pass to drag handler */
}

.cf-node-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.cf-node-label {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Connectors (Ports) - Absolute positioning relative to chip */
.cf-node-inputs,
.cf-node-outputs {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.cf-port-input {
    /* Main input - Left side, centered vertical? Or adaptive? */
    /* Swift: "activeInputSide == .left" used most common. */
    width: 12px;
    height: 12px;
    background: #9ca3af;
    /* Gray default */
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    left: -6px;
    /* Center on edge */
    top: 50%;
    margin-top: -6px;
    pointer-events: auto;
    cursor: crosshair;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cf-port-output {
    width: 12px;
    height: 12px;
    background: white;
    /* Will be colored by JS */
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    right: -6px;
    top: 50%;
    margin-top: -6px;
    pointer-events: auto;
    cursor: crosshair;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Multiple outputs stack vertically on the right */
.cf-node-outputs .cf-port-row {
    position: absolute;
    right: -8px;
    height: 16px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

/* We need to position rows via inline styles in JS for stacks */

/* Inspector */
#cf-inspector {
    width: 320px;
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

#cf-inspector-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.cf-form-group {
    margin-bottom: 16px;
}

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

.cf-form-group input,
.cf-form-group select,
.cf-form-group textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    /* Matched radius */
    padding: 8px 12px;
    font-size: 14px;
    box-sizing: border-box;
}

.cf-form-group input:focus,
.cf-form-group textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.cf-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    cursor: pointer;
    font-size: 13px;
}

.cf-btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.cf-day-picker {
    display: flex;
    gap: 4px;
}

.cf-day-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border: 1px solid transparent;
}

.cf-day-btn.active {
    background: #4f46e5;
    color: white;
}

/* Audio Player Stub */
.cf-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
}

/* Helper */
.cf-help-box {
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    padding: 12px;
    font-size: 13px;
    color: #1e40af;
    display: flex;
    gap: 8px;
    margin-top: 20px;
}